yarn dev
: Start server in dev. mode;
-
yarn test
: Run all Jest tests;- Note: in
jest.config.ts
you need specify where you have tests files, in my case:
testMatch: [ '**/tests/*.tests.ts', '**/tests/*.spec.ts', ],
- Note: in
- Use
/api
in base url for all routes (classe 1 - 22/02/21);
- Use
.env
file to set server port (classe 1 - 22/02/21);- Note:
.env.example
contains an example of.env
file.
- Note:
- Create
environment.ts
file (in/src/configs
) to access data from.env
file (classe 1 - 22/02/21);
- Add Husky Hooks to run Prettier and format code in pre-commit (classe 2 - 23/02/21);
- Custom structure in
src/routes
(classe 1 - 22/02/21);- Note: I use on file per controller, example:
UserController
I haveusers.routes
, whereusers.routes
contains all routes related with users.
- Note: I use on file per controller, example:
- Use
.spec.ts
for tests files (classe 3 - 24/02/21);
- Validate if already exists migrations on Jest Tests (classe 3 - 24/02/21);
- Code:
try { await connection.runMigrations(); } catch (error) { console.log('Already have migrations!'); }