/admin-node

Primary LanguageTypeScript

Run

  • npm install
  • start mysql server
  • npm start ... to start nodemon
  • http://localhost:8000/
  • Seeing Database: npm run roles:seed

In case of errors

  • npm install -g nodemon
  • npm install -g ts-node
  • Set-ExecutionPolicy RemoteSigned -Scope CurrentUserke

Debug

  • NO npm start, just F5 OR
  • ctrl + shift + p -> Debug: Toggle Auto Attach Always + npm start

Setup

First steps

  • npm init -y
  • npm i -D typescript ts-node nodemon and TS global npm i -g typescript
  • tsc --init

Configure nodemon

  • create nodemon.json and add stuff

SQL stuff

SQLite

  • Delete all rows and ignore Foreign Keys

    PRAGMA foreign_keys = OFF; DELETE FROM table_name; PRAGMA foreign_keys = ON;

MySql

  • Delete all rows and ignore Foreign Keys

    SET FOREIGN_KEY_CHECKS = 0; truncate table table_name; SET FOREIGN_KEY_CHECKS = 1;


Packages

Express

  • REST API framework
  • npm i express cors
  • Install respective types npm i -D @types/express @types/cors

Further resources

Bcryptjs

  • Encryption package
  • npm i bcryptjs
  • npm i -D @types/bcrypt

TypeORM

SQLite Database

Express-Validation

  • validation library

JWT

  • json web token packages
  • npm i jsonwebtoken
  • npm i -D @types/jsonwebtoken
  • Steps:
    • define payload & create token respectively
    • store token in http-only-cookie
  • npm i cookie-parser ... to receive cookie from api-response
  • npm i -D @types/cookie-parser

environment variables

File Upload - Multer

  • npm i multer
  • npm i -D @types/multer

Export CSV

  • npm i json2csv
  • npm i -D @types/json2csv

TODO

Logging