guilhiz / Node-Boilerplate

A pre-configured Node.js boilerplate with TypeScript, Express and PostgreSQL, plus settings for popular tools like ESLint, Prettier, and Husky. Comes with a pre-defined file structure and ready-to-use libraries like Zod, JWT, Bcrypt and Helmet. Highly customizable to meet your needs.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

My Node Boilerplate with TypeScript

โš™๏ธ Configs

  • ๐Ÿ”„ Dependabot โ€” Automated dependency updates for GitHub repositories.
  • ๐Ÿ’  Express โ€” Fast, flexible web framework for Node.js
  • ๐Ÿ—ƒ๏ธ Prisma โ€” A modern database ORM
  • โœจ TSX โ€” Node.js library with esbuild to run TypeScript & ESM files
  • โšก TSUP โ€” A fast and flexible TypeScript building tool
  • ๐Ÿ“ Dotenv-cli โ€” To load multiple environment variables files
  • ๐Ÿ”ง ESLint โ€” Pluggable JavaScript linter
  • ๐ŸŽจ Prettier โ€” Opinionated Code Formatter
  • ๐Ÿ“ Commitzen โ€” Git commit message helper
  • ๐Ÿถ Husky โ€” Use git hooks with ease
  • ๐Ÿšซ Lint-staged โ€” Run linters against staged git files

Libs

  • ๐Ÿ”’ Zod โ€” TypeScript-first schema validation.
  • ๐Ÿ”‘ JWT โ€” JSON Web Token implementation.
  • ๐Ÿ”ฌ Jest โ€” A popular JavaScript testing framework
  • ๐Ÿ” Bcrypt โ€” Library for hashing passwords.
  • ๐Ÿ›ก๏ธ Helmet โ€” Express middleware for securing HTTP headers.
  • โœ‚๏ธ Saniteze-html โ€” Remove HTML tags from a string.

๐Ÿš€ Getting Started

To use this boilerplate as a template for your own project, follow these steps:

  • Click on the Use this template button on this repository page to create a new repository from this template.
  • Choose a name and configure the new repository as desired.
  • Clone the newly created repository to your local machine with the following command in your terminal:
git clone https://github.com/<YOUR_USERNAME>/<YOUR_PROJECT_NAME>.git

After cloning the repository, run the following commands inside the project folder:

  • Install the dependencies with npm install
  • Create an env.development file in the envs folder
  • Configure the environment variables based on the envs/.env.development.example
  • Run the project with npm run dev

๐Ÿ“ Main File Structure

โ”œโ”€โ”€ ๐Ÿ“.github // GitHub workflows
โ”œโ”€โ”€ ๐Ÿ“.husky // Git hooks
โ”œโ”€โ”€ ๐Ÿ“.envs // Environment variables
โ”œโ”€โ”€ ๐Ÿ“.prisma // Prisma ORM configuration
|
โ”œโ”€โ”€ ๐Ÿ“src
|   โ”œโ”€โ”€ ๐Ÿ“configs // Application configurations
|   โ”œโ”€โ”€ ๐Ÿ“controllers // Request controllers
|   โ”œโ”€โ”€ ๐Ÿ“errors // Custom error classes
|   โ”œโ”€โ”€ ๐Ÿ“middlewares // Middleware functions
|   โ”œโ”€โ”€ ๐Ÿ“repositories // Data access layer
|   โ”œโ”€โ”€ ๐Ÿ“routes  // Application routes
|   โ”œโ”€โ”€ ๐Ÿ“schemas // Request schemas
|   โ”œโ”€โ”€ ๐Ÿ“services // Business logic layer
|   โ”œโ”€โ”€ ๐Ÿ“utils // General utilities
|   |   โ”œโ”€โ”€๐Ÿ“constants // Global constants
|   |   โ””โ”€โ”€๐Ÿ“functions // Utility functions
|   |
|   โ”œโ”€โ”€ ๐Ÿ“„app.ts // Express app configuration
|   โ””โ”€โ”€ ๐Ÿ“„server.ts // Server entry point
|
โ”œโ”€โ”€ ๐Ÿ“tests
|   โ”œโ”€โ”€ ๐Ÿ“factories // Test data factories
|   โ”œโ”€โ”€ ๐Ÿ“integration // Integration tests
|   โ””โ”€โ”€ ๐Ÿ“unit // Unit tests
|
โ”œโ”€โ”€ ๐Ÿ“„.eslintrc.json // ESLint configuration file
โ”œโ”€โ”€ ๐Ÿ“„.prettierrc // Prettier configuration file
โ”œโ”€โ”€ ๐Ÿ“„jest.config.ts // Jest configuration file
โ”œโ”€โ”€ ๐Ÿ“„README.md // Project documentation
โ”œโ”€โ”€ ๐Ÿ“„package.json // NPM package configuration file
โ””โ”€โ”€ ๐Ÿ“„tsconfig.json // TypeScript configuration file

:octocat: How to use commitzen

  1. Run git add to stage changes
  2. Run git commit without providing a message to use Commitzen
  3. Use the Commitzen interface to write and confirm the commit message
ezgif.com-gif-maker.mp4

๐Ÿค Contributing

If you want to contribute to this template, follow these steps:

  • Fork this repository
  • Create a new branch with their feature using git checkout -b my-feature.
  • Commit their changes using git commit -m 'Adding new feature'.
  • Push the changes to their branch using git push origin my-feature.
  • Open a pull request on your repository.

About

A pre-configured Node.js boilerplate with TypeScript, Express and PostgreSQL, plus settings for popular tools like ESLint, Prettier, and Husky. Comes with a pre-defined file structure and ready-to-use libraries like Zod, JWT, Bcrypt and Helmet. Highly customizable to meet your needs.

License:Mozilla Public License 2.0


Languages

Language:TypeScript 93.9%Language:Shell 6.1%