boiler-express-node v1.0.0
🚀 boiler-express-node - A Ready-to-Use Boilerplate for Express.js
boiler-express-node
is a well-structured boilerplate template designed to streamline the development of MVC-based applications using Express.js. With this template, you can quickly start building APIs and web applications with minimal setup.
⚠️ ATTENTION
- After installing the dependencies with
npm install
, navigate to thenode_modules
folder in your project directory. - Inside
node_modules
, locate theboiler-express-node
folder. - Copy the
boiler-express-node
folder to your root project directory to start using the boilerplate structure easily. - This step ensures that the boilerplate template is accessible and ready for customization in your project.
Follow these steps carefully to set up the boilerplate for your development workflow.
📋 Features:
- 🏗️ Pre-configured MVC structure to easily start building APIs and web applications.
- 📦 Pre-created demoUser API that you can use and run immediately.
- 🔒 Essential development packages for security, validation, authentication, and database management.
- 🗄️ MongoDB support for database interaction.
- 🔑 Environment variable management, CORS, and automatic server restarts during development.
📦 Pre-installed Packages:
1. Nodemon 🔄
- Nodemon monitors file changes and automatically restarts the server during development, saving you from manually restarting after each code change.
2. Express ⚡
- Express is a minimal and flexible web framework for building APIs and web applications. It simplifies routing, middleware handling, and HTTP requests.
3. BcryptJS 🔐
- BcryptJS is used for password hashing and authentication, ensuring that sensitive data is securely stored and verified.
4. CORS 🌐
- CORS (Cross-Origin Resource Sharing) middleware is essential for handling requests from different origins (domains), allowing secure API interactions from various sources.
5. Dotenv 📜
- Dotenv loads environment variables from a
.env
file intoprocess.env
, keeping sensitive information like API keys and database credentials safe and out of your codebase.
6. Joi 📏
- Joi is a powerful schema validation library that helps validate incoming data, ensuring that your application receives data in the correct format.
7. JSON Web Token (JWT) 🛡️
- JWT is used for securely transmitting information between client and server. It's mainly used for user authentication, generating tokens for session management.
8. Mongoose 🐱
- Mongoose is an ODM (Object Data Modeling) library for MongoDB. It simplifies data model definition and interaction with MongoDB collections.
📝 Create a .env
file
Note: Ensure you have filled in all the values in the .env
file, especially for sensitive data like the MongoDB URI, JWT secret, and mail credentials.
PORT = YOUR_SERVER_PORT
MONGODB_URI = YOUR_MONGODB_URI
JWT_SECRET = YOUR_JWT_SECRET
JWT_EXPIRES_IN = YOUR_JWT_EXPIRES_IN
API_KEY = YOUR_API_KEY
DB_USER = YOUR_DB_USER
DB_PASSWORD = YOUR_DB_PASSWORD
DB_NAME = YOUR_DB_NAME
DB_HOST = YOUR_DB_HOST
MAIL_HOST = YOUR_MAIL_HOST
MAIL_PORT = YOUR_MAIL_PORT
MAIL_USER = YOUR_MAIL_USER
MAIL_PASS = YOUR_MAIL_PASS
SESSION_SECRET = YOUR_SESSION_SECRET
CORS_ORIGIN = YOUR_CORS_ORIGIN
📄 Environment Variables:
- PORT: Port your server will run on (e.g., 3000).
- MONGODB_URI: MongoDB connection string (e.g., mongodb://localhost:27017/mydatabase).
- JWT_SECRET: A strong, unique secret key used to sign JWT tokens.
- JWT_EXPIRES_IN: Token expiration time, e.g., 1h, 24h.
- API_KEY: Your third-party API key (e.g., for mail services).
- DB_USER, DB_PASSWORD, DB_NAME, DB_HOST: Credentials for connecting to your database.
- MAIL_HOST, MAIL_PORT, MAIL_USER, MAIL_PASS: Mail service configuration for sending emails.
- SESSION_SECRET: Secret key for managing user sessions.
- CORS_ORIGIN: Allowed origins for Cross-Origin Resource Sharing.
📍 Useful Links:
- 📚 Express Documentation
- 📖 MongoDB Documentation
- 🛠️ JWT Documentation
- 📝 Mongoose Documentation
- 🌍 Dotenv Documentation
- 🔄 Nodemon Documentation
- 🔑 BcryptJS Documentation
- ✅ Joi Documentation
- 🌐 CORS Documentation
📝 Additional Notes:
This boilerplate template is designed to help you get up and running quickly with Express.js. Ensure that you update sensitive values in the .env file before running the app.
If you're using a production environment, make sure to follow proper security practices for handling API keys, secrets, and other sensitive data.
Getting Started
To get started with this template, follow the steps below:
- Start the development server:
npm run dev
Explore the project:
- The server will automatically restart when changes are made. Check the demoUser API for example routes.
7 months ago