DEV Community

Richard Essuman
Richard Essuman

Posted on

A Backend NodeJS API for a Learning Application Management System

Day 1: Setting Up the Project
Today, I started building an authentication API using Node.js and Express.js. Here's what I did:

Why Node.js? It’s fast, scalable, and perfect for building APIs.

Express.js: I chose Express because it’s lightweight and makes routing and middleware management easy.

Packages Installed:

  1. express:
    For handling HTTP requests and routing.

  2. dotenv:
    To manage environment variables (like API keys and secrets).

  3. cors:
    To enable Cross-Origin Resource Sharing for my frontend (running on http://localhost:5173).

  4. helmet:
    To secure HTTP headers and protect against common vulnerabilities.

  5. morgan:
    For logging HTTP requests during development.

I also set up a basic server structure and connected it to a MongoDB database using mongoose. The database connection is handled in a separate file (connectDB.js) for modularity.

Top comments (0)