zerothebahdman / pipedpiper

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Nestjs Prisma Starter Nest Logo

All Contributors

This project contains boilerplate for creating APIs using Nest, a progressive Node.js framework for building efficient and scalable server-side applications.

It is mostly built to be used as a starting point and implements common operations such as sign up, JWT authentication, mail validation, model validation and database access.

Features

  1. PostgreSQL with Prisma

  2. JWT Authentication

  3. Mail Verification

  4. Mail Change

  5. Password Reset

  6. Request Validation

  7. Customizable Mail Templates

  8. Swagger API Documentation

  9. Security Techniques

  10. Logger

Getting Started

Installation

  1. Make sure that you have Node.js(>= 10.13.0, except for v13) installed.
  2. Clone this repository by running git clone https://github.com/zerothebahdman/nestjs-prisma-starter.git or directly create your own GitHub repository using this template.
  3. Move to the appropriate directory: cd <YOUR_PROJECT_NAME>.
  4. Run yarn to install dependencies.

Configuration Files

Prisma Configurations

This template uses Postgres by default. If you want to use another database, follow instructions in the official Nest recipe on Prisma.

If you wish to use another database you will also have to edit the connection string on .env file accordingly.

Your database url in the `.env` file should as follows

DATABASE_URL="postgresql://johndoe:randompassword@localhost:5432/mydb?schema=public"

mydb : The name of the databse you created on your machine
johndoe : The username of the database
randompassword : The password of the database

A delivery provider is required for sending mails with Nodemailer. I mostly use MailTrap to send mails, however, Nodemailer can work with any service with SMTP transport.

To get a MailTrap API key:

  • Create a free account from https://mailtrap.io/
  • Confirm your account via the activation email and login.
  • Create an API Key with mail sending capability.

Enter your API key and sender credentials to .env file. Sender credentials are the sender name and sender mail that will be seen by your users.

MAIL_FROM=
MAIL_HOST=
MAIL_PORT=
MAIL_USER=
MAIL_PASSWORD=

Migrations

Please refer to the official Prisma Migrate Guide to get more info about Prisma migrations.

# generate migration for local environment
$ yarn migrate:dev:create
# run migrations in local environment
$ yarn migrate:dev

# deploy migration to prod environment
$ yarn migrate:deploy:prod

Running the app

# development mode
$ yarn start:dev

# production
$ yarn build
$ yarn start:prod

Running the tests

# unit tests
$ yarn test

# e2e tests
$ yarn test:e2e

# test coverage
$ yarn test:cov

Support Nest

Nest is an MIT-licensed open source project. If you'd like to join support Nest, please read more here.

License

Licenced under MIT License. Nest is also MIT licensed.

About

License:MIT License


Languages

Language:TypeScript 98.6%Language:JavaScript 0.7%Language:Dockerfile 0.6%Language:Procfile 0.0%