Skip to content

tutods/nlw06-node

Repository files navigation

NLW#06 NodeJS

This project is created from the NLW#06 of NodeJS



📋 How to execute:

To run this project follow commands below:

  1. yarn install;
  2. yarn typeorm migration:run;
  3. yarn dev: this run the development server;


💬 Changes:

  • I use Nodemon with TS-Node instead TS-Node-Dev;
  • Add ESLint configuration (.eslintrc) and add hook to run on git push;
  • Custom folder structure;
  • Use one controller for all CRUD services (getAll, getOne, create, update and delete);
  • Use JOI to validate parameters and body of requests;
    • I create 3 middlewares to validade the body, query parameters or url parameters;
  • Set Babel to build;
  • Use classToClass (form class-transformer package) to hide password on result of requests;


How to fix Husky to run hooks:

In package.json add on scripts:

"postinstall": "husky install",

After that run on your terminal:

  • With Yarn:
    • yarn husky add .husky/pre-push "yarn lint"
    • yarn husky add .husky/pre-commit "yarn lint-staged"
  • With NPM:
    • npx husky add .husky/pre-push "npm run lint
    • npx husky add .husky/pre-commit "npm lint-staged