This is basic Nodejs project starter. Its goal is to offer a simple way to start new api applications. It offers:
- Models
- Controllers
- Services
- Migrations
- Environment specific configurations
- Docker development environment
- Tests
- Install Docker and Docker Compose
- clone this project
- run
cd <project_name>
- run
npm run config
- run
npm run docker:start:dev
- run
npm install
- run
npm run db:create:all
- run
npm start
visit http://localhost:9090/users
The project contains unit & integrations tests to cover the full solution.
All: npm test
Unit: npm test:unit
Integration: npm test:integration
For more information about our tests:
- General - Test general guidelines
- Unit - Unit testing guidelines
- Integration - Integration testing guidelines
The full folder structure of this app is explained below:
Name | Description |
---|---|
.vscode | Contains VS Code specific settings |
dist | Contains the distributable (or output) from the TypeScript build. This is the code we ship |
src | Contains the source code |
src/config | Contains the project general configuration |
src/controllers | Controllers define functions that respond to various http requests |
src/models | Models define Sequelize schemas that will be used in storing and retrieving data |
src/server | Server methods to run the server |
src/services | Services that group logic to process information |
src/types | Holds .d.ts files not found on DefinitelyTyped. |
src/index.ts | Entry point to the express app |
tests | Contains the tests |
The name of the branch should follow:
- fix/fix-name
- feature/feature-name
We are using Codelitt's commit styleguide
- Create a branch from the default branch
- Create one commit per fix/feature
- Create a pull request
- Request someone to review it
- Once approved, rebase and merge
The project comes with multiple Package.json
scripts created to run usefull commands.
The following are the current command list:
build
: runs all the builds necessary for the projectbuild:tsc
: runs the typescript build of the projectconfig
: creates a basic env file to run your server, no sensible keys are availabledocker:build
: builds the docker-compose containersdocker:db
: starts the database containerdocker:start:dev
: runs docker-compose containers, and starts bash. (Database will be not populated you will need to run extra commands)docker:start
: same asstart:dev
but it will run the serverdocker:stop
: stops the docker service (docker-compose down)db:setup / db:setup:test
: creates the database if it not exists for dev / test environmentdb:create / db:create:test
: creates & execute migrations of the database if it not exists for dev / test environmentdb:migrate:schema / db:migrate:schema:test
: runs the database migration client of the schema for dev / test environmentdb:migrate:data
: runs the database migration client of the data for dev environmentdb:seed
: runs the seeds of the project for dev environmentstart
: compiles and starts the applicationstart:dev
: watch the TS files, on a change it builds the hole application and starts.start:prod
: starts the application using node for built js.test:unit
: runs the unit teststest:integration
: runs the integration tests on the test environmenttest:all
: runs all test types
Execute a command via:
npm run <command>