🚀 Production-ready boilerplate with query validation and dynamic typing with Typescript. A highly scalable foundation API, with focus on security, and best practices. Below a live example :
Loading repository data…
Loading repository data…
vincent-queimado / repository
🚀 Fast and Easy Rest API Boilerplate with Express and Typescript 🌟 Prisma ORM, Zod validation, Winston logger, Passport-jwt, Swagger, Jest, Eslint, Prettier, Husky, live reload, among others. A boilerplate for building production-ready RESTful APIs using Node.js. Happy coding! 💻💪

The project is a concise and comprehensive TypeScript boilerplate specifically designed for rapid development of Express REST APIs. This is a boilerplate designed to streamline the creation of new API projects using Express. It provides a minimal set of dependencies that aid in project structuring and acceleration. The boilerplate is production-ready, although customization is recommended to align with specific project requirements.
The boilerplate includes various essential libraries and tools to support the development of your custom project. It leverages the power of Prisma ORM for seamless database operations, facilitates log management with Morgan and Winston to track HTTP request logs in real-time and store rotating log files with web visualization through the EJS engine.
Additionally, the boilerplate ensures robustness by offering comprehensive unit test coverage using Jest, data validation schemas with Zod, JWT middleware authentication, and Swagger documentation generation.
The project follows the MVC architecture and incorporates additional layers for enhanced support and customization. To ensure code quality and consistency, we have integrated ESLint and Prettier tools, enabling automated type-checking during TypeScript code development.
Rest assured, this repository is fully functional and ready for use.
To install the project, follow the steps below.
First, to clone the repository, you'll need Git installed on your computer. From your command line:
$ git clone https://github.com/vincent-queimado/express-prisma-ts-boilerplate.git
To run this application, you'll need Node.js (which comes with npm) installed on your computer. Make sure you install all the necessary dependencies to run the project from your command line:
$ cd express-prisma-ts-boilerplate
$ npm i
In the project folder you will find a .env.example file, duplicate it and rename it to .env only. The command below will copy the template environment variables file needed to initialize your project.
$ cp .env.example .env
After renaming the file, open it and change the desired variables according to your project:
#.env
APP_URL_HOST='localhost'
APP_URL_PORT='3344'
APP_URL_SSL='false'
...
Running locally in development environment:
# development (watch mode)
$ npm run start:dev
When running locally, by default the API will be accessible at url http://localhost:3344 as illustrated below.
Running in a production environment (the code will be transpiled in the build folder and executed):
# production mode
$ npm run start:prod
You will need to configure an SQL database supported by the Prisma ORM in order to perform the data storage. By default the boilerplate uses a demo connection to the PostgreSQL database, but it can be changed to another database supported by the Prisma ORM.
If you want to install another database, remove the Prisma folder, execute a new prisma initialization, follow the instructions and skip this section:
$ rm .\prisma
$ npx prisma init
If you want to continue with the PostgreSQL database but don't already have the software, download pgAdmin now or use a Hosting Cloud Service.
You will need to configure a SQL database supported by Prisma ORM for data storage.
Before running the project, it will be necessary to perform a migration through Prisma. In this way, the first tables of the project will be created. When executing the reset command, the ORM seed will be called, thus populating some tables:
Migration run command:
$ npm run migrate
Obs.: Initially, the project assumes that we will use the PostgreSQL database by default, but feel free to change the connection data to the database of your choice.
| Name | Description |
|---|---|
| APP_URL_HOST | [String] It is the host the API will use. By default it is localhost. |
| APP_URL_PORT | [String] It is the port the API will use. By default it is 3344. |
| SSL_ALLOW | [String] Enable or disable SSL in the API. By default it is false. |
| SSL_PRIVATE_KEY | [String] SSL private key file path. By default it is empty. |
| SSL_CERTIFICATE | [String] SSL certificate file path. By default it is empty. |
| API_PREFIX | [String] Api route prefix. By default it is api. |
| API_JSON_LIMIT | [String] Limits request JSON body size. By default it is 5mb. |
| API_EXT_URLENCODED | [String] The “extended” syntax allows for rich objects and arrays to be encoded into the URL-encoded format, allowing for a JSON-like experience with URL-encoded. By default it is false. |
| CORS_ALLOW_ORIGIN | [String] CORS Allow Origin is a header that specifies which origins are allowed to access server resour |
Selected from shared topics, language and repository description—not editorial ratings.
🚀 Production-ready boilerplate with query validation and dynamic typing with Typescript. A highly scalable foundation API, with focus on security, and best practices. Below a live example :