• Stars
    star
    178
  • Rank 210,708 (Top 5 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created about 3 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

API for Real World App project (Conduit) using Node.js + TS with Functional Programming

Conduit API

API for Real World App (Conduit) using Node.js + TypeScript with Functional Programming

Required global dependencies

  • Node.js v16
  • Yarn v1

Up & Running

  1. Install local dependencies:
yarn
  1. Tests (watch mode):
yarn test:watch
  1. Get the server and database up:
yarn dev

To stop the server watch, just press Ctrl + c.

  1. Stop docker after get server down:
yarn docker:down
  1. Destroy all data from DB:
yarn docker:destroy

Scripts

Script Description
yarn start Run production server
yarn dev Get database up and run dev server
yarn server Run only dev server
yarn docker:up Get docker configuration up
yarn docker:down Get docker configuration down
yarn docker:destroy Destroy database and all docker data
yarn migrate <name> Run Prisma migration (You must provide a name)
yarn migration Run existent Prisma migrations
yarn migration:prod Run existent Prisma migrations on production
yarn test Run unit and integration tests once (great to be used in CI)
yarn test:unit Run unit tests once
yarn test:watch Run unit tests in watch mode
yarn test:integration Run integration tests once
yarn test:integration:watch Run integration tests in watch mode
yarn lint Run linter
yarn lint:fix Fix lint errors
yarn type-check TS typechecking
yarn prepare Not suposed to be manually used. It's just to configure husky
yarn build Generates production build
yarn ci Run lint, typechecking and tests (meant to be used in a CI)
yarn update-deps Update both dependencies and devDependencies

Tree structure

This project uses Hexagonal Architecture (Ports & Adapters) with Functional Programming.

.
β”œβ”€β”€ src
β”‚Β Β  β”œβ”€β”€ config
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ tests
β”‚Β Β  β”‚Β Β  β”‚Β Β  └── fixtures
β”‚Β Β  β”‚Β Β  └── module-alias.ts
β”‚Β Β  β”œβ”€β”€ core
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ <domain / entity>
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ use-cases
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ <use-case>-adapter.ts
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ <use-case>.test.ts
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ <use-case>.ts
β”‚Β Β  β”‚Β Β  β”‚Β Β  └── types.ts
β”‚Β Β  β”‚Β Β  └── types
β”‚Β Β  β”‚Β Β      β”œβ”€β”€ <type>.test.ts
β”‚Β Β  β”‚Β Β      └── <type>.ts
β”‚Β Β  β”œβ”€β”€ ports
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ adapters
β”‚Β Β  β”‚Β Β  β”‚Β Β  └── <port-adapter>
β”‚Β Β  β”‚Β Β  └── <port>
β”‚Β Β  β”œβ”€β”€ app.ts
β”‚Β Β  └── index.ts
β”œβ”€β”€ .env.example
β”œβ”€β”€ jest.config.integration.js
└── jest.config.js

Directory / File Description
src All source code write in TypeScript must be in this directory.
src/index.ts Main entry point for initial configuration of the project. Do not edit this file. Start with src/app.ts.
src/app.ts Project entry point. You can call your first port here and boot your providers that should start before your server.
src/config All configurations can live here.
src/config/tests/fixtures Helpers for using in tests.
src/config/module-alias.ts Module configurations for using @/ instead of ../../ on dev, tests and production environments.
src/core Pure domain implementations. core files must not know any port or adapter, nor anything ouside core directory.
src/core/<domain/entity> Inside the core directory, you can organize your files by domain or entity.
src/core/<domain/entity>/types Start point for modelling your domain / entity with TypeScript types.
src/core/<domain/entity>/use-cases Here you can put your functions with business rules for this specific domain / entity, and the adapters that ports will use.
src/core/types Here you can put the types that are not related with any of your domains or entities.
src/helpers Here you can put your global helpers.
src/ports Anything with external world contact. When you need to access something on core, you must use an adapter.
src/ports/adapters Adapters for ports. For example: You can have a database adapter that can use Postgres or MariaDB. An http adapter that can consume express or fastify.
src/ports/<port> Here you can create your raw ports with real implementation: express / fastify as http server, postgres / mariadb as databases, etc.
.env.example List of Environment Variables. Please, copy this file and create a new .env file to use Env Vars.
jest.config.integration.js Jest configuration file for integration tests.
jest.config.js Main Jest configuration file.

Important usage information

Environment Variables

You can use env vars by copying the .env.example file to a new .env file on the root of the project. To document all used env vars, and get autocomplete when use the function env('YOU_VAR'), just put all your env vars on file src/helpers/env.ts.

Global import

All files and dirs inside src directory can be imported using @/. Prefer using this way over local import (../../).

License

MIT

More Repositories

1

ajax

Ajax module in Vanilla JS
JavaScript
748
star
2

workflow-reactjs

My workflow with ReactJS + Webpack 3+
JavaScript
146
star
3

boilerplate-vite-react

Create a new project with React.js, TypeScript and jest with Vite
TypeScript
97
star
4

hmh

πŸ•™ How many hours?
JavaScript
90
star
5

strclass

A ~200b library to apply CSS classes as strings from objects
JavaScript
84
star
6

dotfiles

My configuration files for zsh, neovim and tmux.
Vim Script
63
star
7

hoost

Easily manage your virtual hosts
JavaScript
62
star
8

talks

Palestras.
JavaScript
57
star
9

nodejs-ports-adapters-fp

Node.js Ports & Adapters Architecture for Functional Programming with TypeScript and fp-ts
JavaScript
48
star
10

install-linux

Softwares to install on Linux
Shell
48
star
11

react-ff

Feature Flag component for React
TypeScript
44
star
12

react-trianglify

React Wrapper Component for trianglify
CSS
38
star
13

iscpf

Validate CPF numbers (for NodeJS and browsers)
TypeScript
37
star
14

most-voted

See the most voted subjects in an event
JavaScript
33
star
15

use-timer

React Hook to easily create decremental timers.
JavaScript
28
star
16

is

Typechecker in Vanilla JS
JavaScript
26
star
17

clima

β˜€οΈ Get city weather from wttr.in
Shell
24
star
18

boilerplate-nodejs-typescript-serverless

WIP - Boilerplate for Node.js + TypeScript + Prisma + Serverless
TypeScript
18
star
19

fdaciuk

Fernando Daciuk, the person.
JavaScript
18
star
20

jaiminho

Rest application for zip codes from Brazil.
JavaScript
16
star
21

sls-rust

A Serverless framework plugin for Rust applications
JavaScript
16
star
22

hmh-cli

πŸ•™ How many hours?
JavaScript
16
star
23

load-async

Load React components asynchronously
JavaScript
16
star
24

getmodule

Include local NodeJS modules relative to your root path
JavaScript
15
star
25

workflow-reactjs-parcel

My workflow with ReactJS + Parcel
JavaScript
15
star
26

avit-da2k

πŸ’² oh-my-zsh theme based on avit theme
14
star
27

cargo-v

Update the version of your package easily
Rust
13
star
28

workflow-requirejs

Workflow with RequireJS
JavaScript
13
star
29

dont-stop-grooveshark

Google Chrome Extension that doesn't leave Grooveshark stop playing.
JavaScript
13
star
30

rust-serverless-examples

Examples of how to use Rust with Serverless Framework, Lambda, API Gateway v1 and v2, SQS, GraphQL, etc
Rust
13
star
31

severino

ReScript
12
star
32

fdaciuk.github.io

11
star
33

github2twitter

JavaScript
10
star
34

spawn-webpack-plugin

Run terminal commands with webpack
JavaScript
10
star
35

nostalgia

10
star
36

boleto

Generates new bar code, adding due date and value.
JavaScript
9
star
37

react-lazy-img

JavaScript
8
star
38

crypto-zombies-frontend

TypeScript
8
star
39

js-components

Javascript components to use on your web project
JavaScript
8
star
40

sorteio

Script bestinha de sorteio
JavaScript
8
star
41

workflow-nextjs

My workflow to create apps with Next.js
JavaScript
7
star
42

Passport-Facebook-Express-4

Boilerplate to authenticate with Passport Facebook + Express 4
JavaScript
7
star
43

mg-ui

React Components with Milligram
JavaScript
6
star
44

sexyforms

jQuery plugin to style form fields: select, radio, checkbox and file.
JavaScript
6
star
45

wordpress-base-theme-da2k.com.br

Este tema estΓ‘ sendo desenvolvido a partir da sΓ©rie "Como criar temas para WordPress", no link:
PHP
6
star
46

docker-stream

Live stream in more than one source at a time
5
star
47

Exemplos-Guia-essencial-do-HTML5

Exemplos do livro "O Guia essencial do HTML5 - Usando jogos para aprender HTML5 e Javascript".
JavaScript
5
star
48

freeproxies-crawler

Get proxies addresses from http://www.freeproxylists.net/
JavaScript
4
star
49

rick-and-morty-faker

Elixir
4
star
50

gatsby-starter-netlify-cms

JavaScript
3
star
51

gifs-wall-backend

JavaScript
3
star
52

reactjs-workflow

DEPRECATED - Use this instead: https://github.com/fdaciuk/workflow-reactjs
JavaScript
3
star
53

stream-adventure

Playing with streams in NodeJS
JavaScript
3
star
54

workflow-javascript

My Workflow Javascript with Module Pattern
JavaScript
3
star
55

obs-overlay

Twitch Overlay para minhas lives.
TypeScript
3
star
56

workout-webapp

https://treino.netlify.app
JavaScript
2
star
57

gifs-wall-frontend

TypeScript
2
star
58

css2json-cli

Convert CSS string to JSON
JavaScript
2
star
59

Desafios-CSS

Desafios CSS que participei
2
star
60

Google-Adwords-Broad-Matching

Add a "+" before each word.
JavaScript
2
star
61

api-loterias

TypeScript
2
star
62

node-rest

Simple Rest with Node + Express 4
JavaScript
1
star
63

i18n-example

Example of i18n on frontend
HTML
1
star
64

fillca

JavaScript
1
star
65

crypto-zombies-backend

Smart Contracts for Crypto Zombies game
Solidity
1
star
66

workout-webapp-rescript

ReScript version of Workout App
JavaScript
1
star
67

Github-Webapp-with-ReactJS

Exemplo Github API com ReactJS
JavaScript
1
star
68

da2k-grid

Grid dinΓ’mico com SASS para deixar seu HTML limpo :)
1
star
69

doty

My dotfiles. Made in NodeJS.
1
star
70

snake-game

It's an universal implementation of snake game.
1
star
71

vagrant-php-nodejs

My Vagrant Environment with PuPHPet
Puppet
1
star
72

vow

1
star
73

send-mail-post-pending

Plugin para WordPress que envia um e-mail ao administrador do site/blog para avisar quando hΓ‘ novos posts para revisΓ£o.
PHP
1
star