notes taken during the course
https://github.com/arielweinberger/nestjs-course-task-management/tree/s1-task-management-app
yarn global add @nestjs/cli
nest -v
nest new .
yarn start:dev
nest g --help
nest g module tasks
nest g controller tasks --no-spec
nest g service tasks --no-spec
yarn add uuid
https://github.com/typestack/class-validator
yarn add class-validator class-transformer
docker run --name postgres-nest -p 5432:5432 -e POSTGRES_PASSWORD=postgres -d postgres
docker container start postgres-nest
docker container stop postgres-nest
docker container rm postgres-nest
PGAdmin Server > Create
General Name: NestJS Course
Connection Host name/address: postgres Username: postgres Password: postgres Save password
PGAdmin > Server > NestJS Course > Databases > Create Database: task-management
yarn add typeorm @nestjs/typeorm pg
yarn remove uuid
docker-compose run --rm nest_yarn nest g module auth
docker-compose run --rm nest_yarn nest g service auth --no-spec
docker-compose run --rm nest_yarn nest g controller auth --no-spec
- Passwords will contain at least 1 upper case letter
- Passwords will contain at least 1 lower case letter
- Passwords will contain at least 1 number or special character
- There is no length validation (min, max) in this regex!
Regular expression for JavaScript:
/((?=.*\d)|(?=.*\W+))(?![.\n])(?=.*[A-Z])(?=.*[a-z]).*$/
One minor recommendation is to use
/(?:(?=.*\d)|(?=.*\W+))(?![.\n])(?=.*[A-Z])(?=.*[a-z]).*$/
The ?: at the start of the first group tells the regexp engine not to capture the matches which will make it ever so slightly more performant.
- sha256
- Risk: Rainbow table
- Salt to avoid Rainbow table: salt_userpass
docker-compose run --rm nest_yarn yarn add bcrypt
docker-compose run --rm nest_yarn yarn add @types/bcrypt -D
docker-compose run --rm nest_yarn yarn add @nestjs/jwt @nestjs/passport passport passport-jwt
JWT = base64
Signature = verify if the data is changed!
https://jwt.io/
docker-compose run --rm nest_yarn yarn add @types/passport-jwt -D
Envs with windows:
yarn global add cross-env
docker-compose run --rm nest_yarn yarn add @nestjs/config
Schema validation
docker-compose run --rm nest_yarn yarn add @hapi/joi
docker-compose run --rm nest_yarn yarn add @types/hapi__joi -D
https://passwordsgenerator.net/
https://github.com/arielweinberger/task-management-frontend
docker-compose run --rm nest_yarn yarn global add heroku
heroku -v
heroku login
heroku addons:create heroku-postgresql:hbby-dev -a HEROKU_APP_NAME
heroku git:remote -a HEROKU_APP_NAME
heroku config:set NPM_CONFIG_PRODUCTION=false
heroku config:set NODE_ENV=production
heroku config:set STAGE=prod
heroku config:set DB_HOST=...
heroku config:set DB_PORT=...
heroku config:set DB_USERNAME=...
heroku config:set DB_PASSWORD=...
heroku config:set DB_DATABASE=...
heroku config:set JWT_SECRET=...
git add .
git commit -m "Going Live"
git push -f heroku HEAD:master
heroku logs --tail
yarn test --watch