Skip to content

heinvv/expressjs-project

Repository files navigation

expressjs-project

Express.js app with MongoDB, Mongoose, EJS layouts, and REST-style routes for authors and books.

Prerequisites

  • Node.js >= 18
  • MongoDB (mongod running locally or a remote instance)

Setup

  1. Install dependencies:

    npm install
  2. Configure the database:

    Copy .env.example to .env and set DATABASE_URL:

    cp .env.example .env

    Edit .env and set your MongoDB connection string. For local MongoDB:

    DATABASE_URL=mongodb://localhost:27017/fullstack
    

    Replace fullstack with your database name. For MongoDB Atlas or remote hosts, use the full connection string (including credentials if required).

  3. Run the app:

    npm run devStart

    Or for production:

    npm start

Environment Variables

Variable Description Default
DATABASE_URL MongoDB connection string (required)
PORT Server port 3001
NODE_ENV production disables dotenv, use system env development

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors