This repository contains a JSON-API REST API boilerplate using NFW-CORE.
- Typescript >= 4.9.x (waiting on tsyringe to move to 5.x)
- node >= 18.x
- pnpm 8.x
Any package manager should do the trick but i recommend using Pnpm.
pnpm i
Install the database container.
docker compose up -d
You must create a config/env/<NODE_ENV>.env
file for each env at the root of your project.
The structure of the env file is validated and can be found in the src/api/services/configuration.service.ts
service.
pnpm start:dev
Useful for debugging
pnpm start:test
MIKRO-ORM CLI
pnpm mikro-orm:cli <any command>
You need to transpile (or bundle) the Typescript. And then run node against it. it's up to you.
pnpm tsc
# rollup ...
# docker containers ...
Runs the tests with vitest. The migrations are run and database is cleared before testing.
pnpm test
With beautiful UI in watch mode and coverage
pnpm test -- --ui --watch --coverage
In watch mode
pnpm test -- --watch
- config: config files (some config files that cannot be moved stay in root)
- database: the docker database init files.
- dist: the typescript output folder
- src
- api: transport and configuration related files.
- database: database and ORM related files.
- tests:
- mocks: mocks folder
- src: the test files folder
- acceptance: acceptance tests files
- integration: integration tests files
- unit: unit tests files
- static: static files (png,pdf, ...) for testing
- utils: utils for testing
- App must not depend on tests folder.
- Path aliases are used in typescript to have clearer imports and separation. You cannot import app into app. Import must be relative when the import in the same path.