★ wanayoo — archive 1999 https://github.com/Lucastrike/example_node_apiNouvelle recherche | Portail wanayoo
Skip to content
master
Go to file
Code
This branch is 9 commits behind nabby27:master.

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
src
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

Node DDD API Example

Commands

Start docker services

docker-compose up -d

This will start the Node and PostgreSQL docker services.

If haver error be sure that your local services are stopped.

Down docker services

docker-compose down

Run project

docker-compose exec app npm run dev

This will run nodemon with typescript in dev environment.

Run project compile

docker-compose exec app npm run start

This will compile typescript in ./dist folder and run nodemon with js transpiled.

Build project

docker-compose exec app npm run build

This will only compile the typscript

Run tslint

docker-compose exec app npm run tslint

This will execute tslint to standard code.

Run unit test

docker-compose exec app npm run test:unit

This will execute unit tests


Migrations

Run migrations up

docker-compose exec app npm run migrate:up

Run migrations down

docker-compose exec app npm run migrate:down

Create migrations

docker-compose exec app npx db-migrate create {name_of_migration}

To see how works

First of all, create the .env file (you have the example of the .env.example file).

After starting the docker services and the application node make sure to run the migration up to have the database structure and two users record.


Endpoints

Get all users

Request

Method: GET

URL: http://localhsot:8080/users

Response

[
    {
        "id": "32547dd7-617a-4985-a59a-91a176e55b83",
        "name": "Iván"
    },
    {
        "id": "43ba0b24-4d0b-40f7-aa7f-1b2a3058f484",
        "name": "Nabby"
    },
]

Get one users

Request

Method: GET

URL: http://localhsot:8080/users/32547dd7-617a-4985-a59a-91a176e55b83

Response

{
    "id": "32547dd7-617a-4985-a59a-91a176e55b83",
    "name": "Iván"
}

Create user

Request

Method: POST

URL: http://localhsot:8080/users/32547dd7-617a-4985-a59a-91a176e55b83

Body:

{
    "name": "Iván"
}

Response

No response

Update user

Request

Method: PUT

URL: http://localhsot:8080/users/32547dd7-617a-4985-a59a-91a176e55b83

Body:

{
    "name": "Other"
}

Response

No response

Delete user

Request

Method: DELETE

URL: http://localhsot:8080/users/32547dd7-617a-4985-a59a-91a176e55b83

Response

No response

About

Node.js example API using Typescript, PostgreSQL, Docker Compose, Hexagonal arquitecture, DDD, TSLint and testing with Jasmine

Resources

Releases

No releases published

Packages

No packages published
You can’t perform that action at this time.