- Creating a contract between services that is followed by teams.
- It also often involves additional planning and collaboration with the stakeholders providing feedback on the design of an API before any code is written.
- Teams can mock APIs and test API dependencies based on the established API definition.
- There are a lot of good API design tools like Swagger.
- Describes the structure of the API and serves as interactive API documentation.
The route prefix is /api
.
Route | Description |
---|---|
/api | Shows us the name, description and the version of the package.json |
/swagger | This is the Swagger UI with our API documentation |
/api/accounts | Account entity endpoint |
/api/transactions | Transaction entity endpoint |
Name | Description |
---|---|
src/ | Source files |
src/api | REST API implementation |
src/api/middlewares/ | Express Middlewares like helmet security features |
src/api/controllers/ | REST API Controllers |
src/api/services/ | Service layer contains the business logic, which uses the repository and other services. |
src/api/models/ | TypeORM Models |
src/api/repositories/ | Repository / DB layer |
src/loaders/ | Loader is a place where you can configure your app |
src/public/ | Static assets (fonts, css, js, img). |
test | Tests |
test/e2e/ *.test.ts | End-2-End tests (like e2e) |
test/integration/ *.test.ts | Integration test |
test/unit/ *.test.ts | Unit tests |
You need to set up your development environment before you can do anything.
Install Node.js and NPM
- on OSX use homebrew
brew install node
- on Windows use chocolatey
choco install nodejs
Install yarn globally
yarn global add yarn
Go to the project dir and start your app with this yarn script.
yarn start serve
This starts a local server using
nodemon
, which will watch for any file changes and will restart the server according to these changes. The server address will be displayed to you ashttp://0.0.0.0:3000
.
All script are defined in the package-scripts.js
file, but the most important ones are listed here.
- Install all dependencies with
yarn install
- Run code quality analysis using
yarn start lint
. This runs tslint. - There is also a vscode task for this called
lint
.
- In-progress