Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CSSE API

A fully functional backend API built with Node.js, Express, and MongoDB.

Features

  • Express.js web framework
  • MongoDB with Mongoose ODM
  • CORS enabled
  • Environment variables support
  • Request logging with Morgan
  • RESTful API structure
  • Error handling middleware

Project Structure

CSSE_API/
├── server.js           # Entry point
├── package.json        # Dependencies and scripts
├── .env               # Environment variables
├── .gitignore         # Git ignore rules
└── src/
    ├── models/        # Database models
    ├── controllers/   # Request handlers
    ├── routes/        # API routes
    └── utils/         # Utility functions

Quick Start

  1. Install dependencies:
npm install
  1. Set up MongoDB (choose one):

    • Local: Install and start MongoDB (see SETUP.md)
    • Cloud: Use MongoDB Atlas and update .env with connection string
  2. Create a .env file:

PORT=3000
MONGODB_URI=mongodb://localhost:27017/csse_api
NODE_ENV=development
  1. Start the server:
npm run dev

For detailed setup instructions, see SETUP.md

Running the Application

Development mode (with auto-reload):

npm run dev

Production mode:

npm start

API Endpoints

Example Resource

  • GET /api/example - Get all examples
  • GET /api/example/:id - Get example by ID
  • POST /api/example - Create new example
  • PUT /api/example/:id - Update example
  • DELETE /api/example/:id - Delete example

Testing the API

You can test the API using tools like:

  • Postman
  • Thunder Client (VS Code extension)
  • cURL
  • Insomnia

Example cURL command:

curl http://localhost:3000/

Development

To add a new feature:

  1. Create a model in src/models/
  2. Create a controller in src/controllers/
  3. Create routes in src/routes/
  4. Import and use the routes in server.js

License

ISC

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages