|
1 | 1 | # Typescript-Node-Sequelize-Boilerplate |
2 | 2 |
|
3 | | -- Node (TypeScript) |
| 3 | +A boilerplate/starter project for quickly building RESTful APIs using Node.js,Typescript, Express, and Sequelize. |
| 4 | + |
| 5 | + |
| 6 | +- Node |
| 7 | +- Typescript |
| 8 | +- Express |
4 | 9 | - MySql |
5 | | - |
| 10 | + |
| 11 | +## Table of Contents |
| 12 | + |
| 13 | +- [Typescript-Node-Sequelize-Boilerplate](#typescript-node-sequelize-boilerplate) |
| 14 | + - [Table of Contents](#table-of-contents) |
| 15 | + - [Quick start](#quick-start) |
| 16 | + - [Manual Installation](#manual-installation) |
| 17 | + - [Getting started](#getting-started) |
| 18 | + - [For development](#for-development) |
| 19 | + - [Sample .ENV](#sample-env) |
| 20 | + - [Commands](#commands) |
| 21 | + - [Project Structure](#project-structure) |
| 22 | + - [API Documentation](#api-documentation) |
| 23 | + - [API Endpoints](#api-endpoints) |
| 24 | + - [Linting](#linting) |
| 25 | + - [Inspirations](#inspirations) |
| 26 | + |
| 27 | + |
| 28 | + |
| 29 | +## Quick start |
| 30 | + |
| 31 | +create boillerplate with single command |
| 32 | +``` |
| 33 | + npx @nabadeep25/create-ts-node-app myapp |
| 34 | +
|
| 35 | +``` |
| 36 | + |
| 37 | + |
| 38 | + |
| 39 | +## Manual Installation |
| 40 | + |
| 41 | +steps: |
| 42 | + |
| 43 | +Clone the repo: |
| 44 | + |
| 45 | +``` |
| 46 | +git clone --depth 1 https://github.com/nabadeep25/typescript-node-sequelize-boilerplate.git foldername |
| 47 | +
|
| 48 | +cd folder name |
| 49 | +npx rimraf ./.git |
| 50 | +``` |
| 51 | + |
| 52 | +Install the dependencies: |
| 53 | + |
| 54 | +``` |
| 55 | +npm install |
| 56 | +``` |
| 57 | + |
| 58 | +Set the environment variables: |
| 59 | + |
| 60 | +``` |
| 61 | +cp .env.example .env |
| 62 | +
|
| 63 | +``` |
6 | 64 | ## Getting started |
7 | 65 |
|
8 | 66 | ``` |
@@ -50,3 +108,84 @@ OTP_SECRET=shgdbnbgw |
50 | 108 |
|
51 | 109 |
|
52 | 110 |
|
| 111 | + |
| 112 | +## Commands |
| 113 | + |
| 114 | + |
| 115 | +```bash |
| 116 | +# run in development |
| 117 | +npm run watch |
| 118 | + |
| 119 | +# run in production |
| 120 | +npm run start |
| 121 | + |
| 122 | +# lint files |
| 123 | +npm run lint |
| 124 | + |
| 125 | +# format files |
| 126 | +npm run format |
| 127 | + |
| 128 | +``` |
| 129 | + |
| 130 | + |
| 131 | + |
| 132 | + |
| 133 | +## Project Structure |
| 134 | + |
| 135 | +``` |
| 136 | +src\ |
| 137 | + |--config\ # Environment variables and configuration related things |
| 138 | + |--controllers\ # Route controllers |
| 139 | + |--helpers\ # Helper function files |
| 140 | + |--middlewares\ # Custom express middlewares |
| 141 | + |--model\ # Sequelize models |
| 142 | + |--routes\ # Routes |
| 143 | + |--services\ # Service |
| 144 | + |--utils\ # Utility classes and functions |
| 145 | + |--validations\ # Request data validation schemas |
| 146 | + |--app.ts # Express app |
| 147 | + |--server.ts # App entry point |
| 148 | +``` |
| 149 | + |
| 150 | +## API Documentation |
| 151 | + |
| 152 | +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](https://swagger.io/) definitions written as comments in the route files. |
| 153 | + |
| 154 | +### API Endpoints |
| 155 | + |
| 156 | +List of available routes: |
| 157 | + |
| 158 | +**Auth routes**:\ |
| 159 | +`POST api/v1/auth/register` - register\ |
| 160 | +`POST api/v1/auth/login` - login\ |
| 161 | +`POST api/v1/auth/forgot-password` - send reset password email\ |
| 162 | +`POST api/v1/auth/reset-password` - reset password\ |
| 163 | + |
| 164 | + |
| 165 | +**User routes**:\ |
| 166 | +`GET api/v1/user` - get user info\ |
| 167 | +`PATCH api/v1/user` - update user\ |
| 168 | + |
| 169 | + |
| 170 | +## Linting |
| 171 | + |
| 172 | +Linting is done using [ESLint](https://eslint.org/) and [Prettier](https://prettier.io). |
| 173 | + |
| 174 | +In this app, ESLint is configured to follow the [Airbnb JavaScript style guide](https://github.com/airbnb/javascript/tree/master/packages/eslint-config-airbnb-base) with some modifications. It also extends [eslint-config-prettier](https://github.com/prettier/eslint-config-prettier) to turn off all rules that are unnecessary or might conflict with Prettier. |
| 175 | + |
| 176 | +To modify the ESLint configuration, update the `.eslintrc.json` file. To modify the Prettier configuration, update the `.prettierrc.json` file. |
| 177 | + |
| 178 | +To prevent a certain file or directory from being linted, add it to `.eslintignore` and `.prettierignore`. |
| 179 | + |
| 180 | +To maintain a consistent coding style across different IDEs, the project contains `.editorconfig` |
| 181 | + |
| 182 | + |
| 183 | + |
| 184 | +## Inspirations |
| 185 | +- [hagopj13/node-express-boilerplate](https://github.com/hagopj13/node-express-boilerplate) |
| 186 | +- [microsoft/typescript-node-starter](https://github.com/microsoft/TypeScript-Node-Starter) |
| 187 | + |
| 188 | + |
| 189 | + |
| 190 | + |
| 191 | + |
0 commit comments