- Postgres for the database
- Node/Express for the application logic
- dotenv from npm for managing environment variables
- db-migrate from npm for migrations
- jsonwebtoken from npm for working with JWTs
- jasmine from npm for testing
$ npm init -y
$ npm i --save-dev @types/express @types/jasmine @types/jsonwebtoken @types/node @types/pg @types/supertest @typescript-eslint/eslint-plugin @typescript-eslint/parser eslint eslint-config-prettier eslint-plugin-prettier nodemon prettier ts-node
$ npm i express jasmine jasmine-spec-reporter bcrypt db-migrate db-migrate-pg dotenv jsonwebtoken pg supertest typescript
- Cross check the environment variables correctly when creating Pool object.
- Note down the db and credential details and add them in the .env
CREATE USER admin WITH PASSWORD 'Akhil123';
CREATE DATABASE storefront;
CREATE DATABASE storefront_test;
\c storefront
GRANT ALL PRIVILEGES ON DATABASE storefront TO admin;
\c storefront_test
GRANT ALL PRIVILEGES ON DATABASE storefront_test TO admin;
Install the db-migrate library globally on your system to run the command.
npm would otherwise include the binaries and packages in the node_modules directory
Dev
db-migrate up --config database.json -e dev
Test
db-migrate up --config database.json -e test
Dev
db-migrate down --config database.json -e dev
Test
db-migrate down --config database.json -e test
I have not ignored .env file for now. will include that .gitignore later.
POSTGRES_HOST= 127.0.0.1
POSTGRES_DB = storefront
POSTGRES_USER = admin
POSTGRES_PASSWORD = Akhil123
POSTGRES_DB_TEST = storefront_test
NODE_ENV = dev
PORT = 5432
TOKEN_SECRET = I_AM_THE_LAST_JEDI
SALT_ROUNDS = 10
BCRYPT_PASSWORD = UNBREAKABLE
TEST_TOKEN = eyJhbGciOiJIUzI1NiJ9.MQ.SMntCq5FXdlRgXKQZztNsTeecF7EdLXPeUpop53SUlY
$ npm run start
$ npm run build
$ npm run test
$ npm run prettier
$ npm run lint