Express.js app with MongoDB, Mongoose, EJS layouts, and REST-style routes for authors and books.
- Node.js >= 18
- MongoDB (mongod running locally or a remote instance)
-
Install dependencies:
npm install
-
Configure the database:
Copy
.env.exampleto.envand setDATABASE_URL:cp .env.example .env
Edit
.envand set your MongoDB connection string. For local MongoDB:DATABASE_URL=mongodb://localhost:27017/fullstackReplace
fullstackwith your database name. For MongoDB Atlas or remote hosts, use the full connection string (including credentials if required). -
Run the app:
npm run devStart
Or for production:
npm start
| Variable | Description | Default |
|---|---|---|
DATABASE_URL |
MongoDB connection string | (required) |
PORT |
Server port | 3001 |
NODE_ENV |
production disables dotenv, use system env |
development |