This file describes the commands that can be run for this application.
/!\ The commands are run from the project's root directory.
The running commands run an instance of the application or another processus.
There is a command to run the backend
application:
npm run backend:start
The server will be listening on the port
3000
.
Unless the configuration has been changed.
It is possible to launch a Database instance with the given docker-compose.yml.
docker-compose up db
As in the lint section, the application code can be linted with the following command:
npm run backend:lint
And its corrector:
npm run backend:lint:fix
Check also the styleguide.
As in the test section, the library code can be tested with the following command:
npm run backend:test
If developing at the same time, enable the watch mode:
npm run backend:test:watch
See these commands to run the E2E tests.
Compodoc is a tool
that generates documentation from the comments of an Angular
application.
Nest
having a file structure very similar, it works on it too
The documentation can be served with the following command:
npm run backend:compodoc
The server will be listening on the port
3080
.
The documentation can also be generated to be served as static content:
npm run backend:compodoc:build
The comment coverage can also be tested. In fact, it is one of the tests of the CI:
npm run backend:compodoc:coverage
Mikro-orm
is the orm managing connection and all the queries with the database.
The following commands need a running database which the configuration is set in the config file.
/!\ Be aware that all the following commands modify the database.
The migrations update the database schema and eventually its data.
The migrations can be run with the following command:
npx mikro-orm migration:up
It can also be reverse a step with the command:
npx mikro-orm migration:down
More commands at https://mikro-orm.io/docs/migrations#using-via-cli.
It is possible to generate the schema for the database.
The command will drop, then recreate the database schema:
npx mikro-orm schema:fresh -r
To completely remove the schema, use the next command:
npx mikro-orm schema:drop -r --drop-migrations-table
More commands at https://mikro-orm.io/docs/schema-generator.
The seeding consists of inserting some data in the database, instead of adding them manually.
The command is as follows (on a up-to-date database):
npx mikro-orm seeder:run -c <seed>
The possible values for
<seed>
are:
DbBaseSeeder
: Some basic data
It is also possible to recreate all the database schema and seed it with the following command:
npx mikro-orm schema:fresh -r --seed <seed>
More commands at https://mikro-orm.io/docs/seeding#use-with-cli.
These commands generate some chunk of code for the application. They are well integrated in the project and does the necessary changes.
The Nest CLI is a useful tool
that can be used via Nx
.
The latest proposes a lot of commands,
especially the generators.
Also see the structure of the code.
Here's the command to generate an application module:
nx g @nx/nest:module --project=backend app/<module>
Where <module>
is the module to create.
To generate a non-application module (for example, orm
):
nx g @nx/nest:module --project=backend orm
Here's the command to generate an application service:
nx g @nx/nest:service --project=backend app/<service>
Where <service>
is the service to create.
To generate a non-application service (for example, orm
):
nx g @nx/nest:service --project=backend orm
If another service must be created to an existing module,
the --flat
parameter must be provided.
Example with a secondary service for a group
module:
nx g @nx/nest:service --project=backend app/group/groupWithRoles --flat
The final results would look like:
group.module.ts
group-with-roles.servive.ts
group.servive.ts
Here's the command to generate an application controller:
nx g @nx/nest:controller --project=backend app/<controller>
Where <controller>
is the controller to create.
To generate a non-application controller (for example, orm
):
nx g @nx/nest:controller --project=backend orm
If another controller must be created to an existing module,
the --flat
parameter must be provided.
Example with a secondary controller for a group
module:
nx g @nx/nest:controller --project=backend app/group/groupWithRoles --flat
The final results would look like:
group-with-roles.controller.ts
group.controller.ts
group.module.ts
The following sections are commands that generate some chunk of code that can later be run into a database.
It is possible to create migrations files with the CLI.
The following command generates a migration file:
npx mikro-orm migration:create
Mikro-orm
determines the changes from the snapshot to generate the file.
Check here after the creation of a migration.
To have a blank migration file, use the next command:
npx mikro-orm migration:create -b
More commands at https://mikro-orm.io/docs/migrations#using-via-cli.