Git Product home page Git Product logo

typescript-node-sequelize-boilerplate's Introduction

Typescript-Node-Sequelize-Boilerplate

A boilerplate/starter project for quickly building RESTful APIs using Node.js,Typescript, Express, and Sequelize.

  • Node
  • Typescript
  • Express
  • Sequelize (Oracle, Postgres, MySQL, MariaDB, SQLite and SQL Server etc.)

Table of Contents

Quick start

create boillerplate with single command

 npx  @nabadeep25/create-ts-node-app myapp

Manual Installation

steps:

Clone the repo:

git clone --depth 1 https://github.com/nabadeep25/typescript-node-sequelize-boilerplate.git  foldername

cd folder name
npx rimraf ./.git

Install the dependencies:

npm install

Set the environment variables:

cp .env.example .env

Getting started

npm install

npm run build-ts

npm start

For development

npm install

npm run dev

Sample .ENV

DB_HOST=localhost
DB_NAME=name
DB_PASSWORD=password
DB_PORT=3306
DB_TYPE=postgres
DB_USER=username
PORT=5000



TOKEN_EXPIRY_HOUR=168
SECRET=askjfghhwifuhgw

EMAIL_SERVICE=gmail
[email protected]
EMAIL_PASS=fzobeitqjcxklenm
[email protected]

OTP_EXPIRY_MIN=10
OTP_SECRET=shgdbnbgw

Commands

# run in development
npm run dev

# run in production
npm run start

#  lint files
npm run lint

#  format files
npm run format

Project Structure

dist\               # js files
src\
 |--config\         # Environment variables and configuration related things
 |--controllers\    # Route controllers 
 |--helpers\        # Helper function files
 |--middlewares\    # Custom express middlewares
 |--model\          # Sequelize models 
 |--routes\         # Routes
 |--services\       # Service 
 |--utils\          # Utility classes and functions
 |--validations\    # Request data validation schemas
 |--app.ts\         # Express app
 |--server.ts\      # App entry point

Changing Database

step 1

# Change the value of  DB_TYPE  in .env file to one of the follwing
DB_TYPE=postgres 
DB_TYPE=mysql 
DB_TYPE=sqlite 
DB_TYPE=mariadb 
DB_TYPE=mssql 
DB_TYPE=db2 
DB_TYPE=oracle 

step 2

# Install one of the related packge:
 npm install --save pg pg-hstore # for Postgres
 npm install --save mysql2 # for Mysql
 npm install --save mariadb # for Mariadb
 npm install --save sqlite3 # for Sqlite
 npm install --save tedious # for Microsoft SQL Server (mssql)
 npm install --save oracledb # for Oracle 

for more details please refer Sequelize

API Documentation

To view the list of available APIs and their specifications, run the server and go to http://localhost:5000/api/v1/docs in your browser. This documentation page is automatically generated using the swagger definitions written as comments in the route files.

API Endpoints

List of available routes:

General routes:
GET api/ - get server status
PATCH api/sync - Sync model with database

Auth routes:
POST api/v1/auth/register - register
POST api/v1/auth/login - login
POST api/v1/auth/forgot-password - send reset password email
POST api/v1/auth/reset-password - reset password

User routes:
GET api/v1/user - get user info
PATCH api/v1/user - update user

Inspirations

typescript-node-sequelize-boilerplate's People

Contributors

nabadeep25 avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Forkers

jay74jung

typescript-node-sequelize-boilerplate's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.