Original based off the NodeTS Bootstrap repository.
This is a base NodeJS REST Auth TypeScript App built with express and all configurations files included.
This repository is meant to be a base to build on top of for building an API.
git clone https://github.com/codingwithmanny/nodets-rest-auth-bootstrap myproject;
cd myproject;
rm -rf .git;
git init;
git remote add origin https://github.com/your/newrepo;
- NodeJS 12.18.1 or NVM
- Docker or Postgres Database
- MailGun account for emails
While in project directory:
0 - (Optional) NVM Installation
nvm install;
1 - Install Depencies
yarn install; # npm install;
2 - Start Database
Using Docker
docker run -it -d -p 5432:5432 -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=secret -e POSTGRES_DB=postgres --name nodetsdb postgres;
3 - Setup ENV VARS
NOTE: Make sure to fill them with the correct ENV Variables
cp .env.example .env;
and configure the correct DATABASE_URL
File: ./.env
DATABASE_URL="postgresql://postgres:secret@localhost:5432/postgres?schema=public"
4 - Export Environment Variables
yarn env; # npm run env;
5 - Run Migrations
yarn db:migrate; # npm run db:migrate;
6 - Server Start
Development:
yarn dev; # npm dev;
Production:
yarn start; # npm start;
7 - (Optional) Seeding
yarn db:seed:all; # npm run db:seed:all
Build
yarn build; # npm run build
Build & Serve
yarn start; # npm start
All Tests
yarn test; # npm run test;
Jest Watch
yarn test:jest; # npm run test:jest;
Jest Coverage
yarn test:coverage; # npm run test:coverage;
Eslint
yarn test:lint; # npm run test:lint
Guidelines for development
There is a checklist for creating a new migration:
- - Create new model in
./prisma/schema.prisma
- - Double check that it adheres to the criteria
- -
yarn db:save;
- -
yarn db:gen;
- - Create new sed
yarn db:seed:gen
and modifyNEW.ts
with nameModelNameSeed.ts
- - Run migrations
yarn db:migrate
- - Write tests
Create new models in the ./prisma/schema.prisma
file.
Criteria:
- Singular:
User
NOTUsers
- Camelcase capitalized
MyModel
NOTmyModel
Example:
model ModelName {
id String @default(uuid()) @id
updated_at DateTime @default(now())
}