This is a template repository for creating a Node.js web application using the Express framework. It provides a basic structure and configuration to kickstart your project development.
- Express server setup
- Customised folder structure
- Sample routes and controllers
- Zod configured and typesafe
- Middlewares configured (Error,Validate,Logger)
To get started with this template, follow the instructions below:
- Node.js (version 14 or higher)
- npm (Node Package Manager)
- Clone the repository:
git clone https://github.com/nisabmohd/node-express-template.git
- Change to the project directory:
cd node-express-template
- Create .env in root folder
PORT=8000
MONGO_URI=mongodb://localhost:27017/test
LOGGER=true
Note : if there is no env file or misamtch type of env varaibles from src\utils\validationEnv.ts schema doesn't match server will not start
if LOGGER=true
added in .env file then you can log the requestInfo
- Install the dependencies:
npm install
To start the dev server, use the following command:
npm run built
npm run start
The server will start running on http://localhost:8000
. You can access it in your browser or through API clients like Postman,Insomnnia.
During development, you can use the following command to run the server with automatic reloading on file changes:
npm run dev
If you want to contribute to this template, feel free to submit a pull request. Contributions, bug reports, and feature requests are always welcome!
This template was created by nisabmohd and is inspired by various Node.js and Express project structures and best practices.