Start a new application in seconds!
A highly scalable, configurable, performant with best practices
- Quick-start
- Features
- Configuration
- Scripts
- Git Commitization
- Project Structure
- Important Packages
- Authors
- Make sure that you have Node.js v12.x.x and npm v5 or above installed.
- Clone this repo using
git clone https://github.com/kaushal-aubie/node-boilerplate.git <YOUR_PROJECT_NAME> - Move to the appropriate directory:
cd <YOUR_PROJECT_NAME>. - Run
npm run installin order to install dependencies.
At this point you can runnpm run devto see the app running athttp://localhost:5000. - Got to
http://localhost:5000/pingto receive a pong from the server.
Now you're ready to rumble!
- TypeScript
- The best way to write modern applications. Code is easier to understand. It is now way more difficult to write invalid code as was the case in dynamically typed languages
- Static code analysis
- Focus on writing code, not formatting! Code formatter and linter keeps the code clean which makes work and communication with other developers more effective.
- Next generation JavaScript
- Use template strings, object destructuring, arrow functions,ES2017 latest features like Async/Await and more
- Ready for any Environment
- It is ready to work with any environment such as Development, Production and staging and all can have their different `.env` files
- Path alias
- Create a path alias in `tsconfig.json` and it will allow to find a file or resource located in a different directory or folder from the place where the shortcut is located.
- Docker Support
- Comes with a Dockerfile and docker compose file
- Compression
- Gzip compression with compression
- Git Hooks
- Awesome Command line Git Commitization integrated with husky
- Logging
- Jet Logger For great logging and morgan added for api request logging
- Validation
- Request data validation using JOI
- Security
- set security HTTP headers using helmet
- CORS
- Included CORS
- Email helper
- Email helper ready just to import and use
- File Upload helper
- File Upload helper ready to just import and use
- Response Structure
- Pre-defined response structures with proper status codes.
- Docker Compose File
docker/docker-compose.yml - DockerFile
docker/Dockerfile - Prettier config
/.prettierc. - Typescript config
/tsconfig.json. - ESLint config
/.eslintrc.js. - Commitlint config
/commitlint.config.js. - Husky config
/.husky. - VScode config
/.vscode.
npm run docker:up- Starts the Docker app.npm run docker:stop- Stops the Docker app.npm run docker:down- Stop the Docker Compose Process.npm run docker:remove-dangling- Remove/Delete Dangling Images.npm run docker:compose- Start the App.npm run docker:compose:d- Start the App in detached mode.npm run docker:logs- Start Logs in Docker for app.npm run docker:restart- Restart the Docker app.npm run docker:exec- Open path to the repo inside Docker as bashnpm run docker:logs:follow- Start Logs in Docker for app.npm run docker:seed- To add dummy data in Database in development mode inside docker app.npm run start- To run app in production mode.npm run dev- To run app in development mode.npm run kill-process- To kill process at running port.npm run build- To build the code.npm run format- To prettify code.npm run check-lint- To check lint errors.npm run check-types- To check typescript errors.npm run check-all- To check lint,typescript and build errors.npm run commit- To commit your changes.npm run seed- To add dummy data in Database in development mode.npm run seed:prod- To add dummy data in Database in production mode.
Configuring the gitmoji only once
> npx gitmoji -g
> ? Enable automatic "git add ." (y/N) N
> ? Select how emojis should be used in commits (Use arrow keys)
:smile:
❯ 😄
> ? Enable signed commits (y/N) N
> ? Enable scope prompt (Y/n) YCommit workflow
npm run commit
Step 1: Choose a gitmoji from the list
? Choose a gitmoji: (Use arrow keys or type to search)
> 🎨 - Improve structure / format of the code.
⚡️ - Improve performance.
🔥 - Remove code or files.
🐛 - Fix a bug.
🚑️ - Critical hotfix.
✨ - Introduce new features.
📝 - Add or update documentation.
(Move up and down to reveal more choices)
Step 2: Add a scope, title and message
? Choose a gitmoji: 🎨 - Improve structure / format of the code.
? Enter the scope of current changes: hello
? Enter the commit title [5/48]: title
? Enter the commit message: message
Now it will run lint, types and build scripts if everything is ok, changes will be committed
Git commit message format will be :- git commit -m ":gitmoji: title" -m "message"├───.husky # Husky hooks
│───.vscode # VS Code Settings
│─── docker # Docker configs
│─── dist # Production Build
│─── env # Environment files
│─── src\
│ |--config\ # Environment variables and configuration related things
│ |--controllers\ # Route controllers (controller layer)
│ |--db\ # Database Configuration
│ |--middlewares\ # Custom express middlewares
│ |--interfaces\ # All Shared Global Interfaces
│ |--libs\ # External Libs Config
│ |--models\ # Sequelize models (data layer)
│ |--routes\ # Routes
│ |--services\ # Business logic (service layer)
│ |--utils\ # Utility classes and functions
│ |--validations\ # Request data validation schemas
│ |--response_builder\ # Generic Response Builder logic
│ |--seeds\ # Dummy Data Generation Files
│ |--types\ # Global Typescript Types Definitions
│ |--app.ts # Express app
│ |--server.ts # App entry point
│
├── .gitignore # git ignore
├── .dockerignore # docker ignore
├── .prettierrc # Prettier Config
├── .commitlint.config.js # Commitlint Configuration
├── nodemon.json # nodemon config
├── package.json # blue print of app
├── package-lock.json # package lock file for bindings of packages
├── private.pem # pem file for JWT
├── README.md # Readme File
└── tsconfig.json # Type Script Configuration File
express- Fast, unopinionated, minimalist web framework
compression- Node.js compression middlewarecookie-parser- Parse HTTP request cookiescors- Node.js CORS middlewaremorgan- HTTP request logger middleware for node.jshelmet- Help secure Express/Connect apps with various HTTP headers
pg- PostgreSQL client - pure javascript & libpq with the same APIpg-hstore- A module for serializing and deserializing JSON data into hstore formatsequelize- Sequelize is a promise-based Node.js ORM tool for Postgres, MySQL, MariaDB, SQLite, Microsoft SQL Server, Amazon Redshift and Snowflake’s Data Cloud. It features solid transaction support, relations, eager and lazy loading, read replication and more.
eslint-config-prettier- Turns off all rules that are unnecessary or might conflict with Prettier.eslint-import-resolver-typescript-TypeScript .ts .tsx module resolver foreslint-plugin-import.eslint-config-airbnb-base- an eslint rule plugin companion to babel-eslint.eslint-plugin-import- This plugin intends to support linting of ES2015+ (ES6+) import/export syntax, and prevent issues with misspelling of file paths and import names.eslint-config-airbnb-base- Airbnb's base JS ESLint config, following our styleguideeslint-plugin-prettier- Runs prettier as an eslint rule.@typescript-eslint/eslint-plugin- TypeScript plugin for ESLint.@typescript-eslint/parser- An ESLint custom parser which leverages TypeScript ESTree.
command-line-args- A mature, feature-complete library to parse command-line options.bcrypt- A bcrypt(encryption) library for NodeJS.dotenv- Loads environment variables from .env filejet-logger- A super quick, easy to setup logging tool for NodeJS/TypeScript.joi- Object schema validationjsonwebtoken- JSON Web Token implementation (symmetric and asymmetric)
|
Kaushal Shah |