Skip to content

Bootstrap NodeJS TypeScript REST Auth API with Prisma and Postgres implementation. Copy this for your next project.

Notifications You must be signed in to change notification settings

codingwithmanny/nodets-rest-auth-bootstrap

Repository files navigation

Version Build Coverage

NodeTS REST Auth Bootstrap

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.

Copy This App

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;

Requirements

  • NodeJS 12.18.1 or NVM
  • Docker or Postgres Database
  • MailGun account for emails

Local Setup

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

Production Commands

Build

yarn build; # npm run build

Build & Serve

yarn start; # npm start

Tests

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

Development

Guidelines for development

New Migration

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 modify NEW.ts with name ModelNameSeed.ts
  • - Run migrations yarn db:migrate
  • - Write tests

Create new models in the ./prisma/schema.prisma file.

Criteria:

  • Singular: User NOT Users
  • Camelcase capitalized MyModel NOT myModel

Example:

model ModelName {
  id                 String    @default(uuid()) @id
  updated_at         DateTime  @default(now())
}

About

Bootstrap NodeJS TypeScript REST Auth API with Prisma and Postgres implementation. Copy this for your next project.

Topics

Resources

Stars

Watchers

Forks

Languages