Skip to content

Latest commit

 

History

History
266 lines (204 loc) · 10.8 KB

File metadata and controls

266 lines (204 loc) · 10.8 KB

FOGO API

Table of Contents
  1. About The Project
  2. Getting Started
  3. Contributing
  4. Authors
  5. Acknowledgements

About The Project

A peer-to-peer Dartmouth Dining Service delivery app that lets students order meals using meal swipes or dining dollars, and earn extra cash by delivering orders across campus.

Built With

This project is built using the MERN tech stack

  • MongoDB
  • Express
  • React
  • Node

Getting Started

To get a local copy up and running follow these simple example steps.

Prerequisites

  • You should have node installed
    npm install 

Installation

Follow the instruction below to get started.

  1. Clone the repo
    git clone https://github.com/dartmouth-cs52-25s/project-api-man-to-go.git
  2. Install NPM packages
    npm install
  3. Create .env file (reference .env.example)
    touch .env
  4. Run it locally
    npm start

Environment Variables

Create a .env file at the project root. Refer to .env.example for full keys and formats.

  • MONGODB_URI (required): MongoDB connection string
  • PORT (optional): Port for the API server (defaults to 9090)
  • FIREBASE_SERVICE_ACCOUNT_KEY (required): Stringified JSON for Firebase Admin credentials
  • RESEND_API_KEY (optional): Resend API key for transactional email
  • JWT_SECRET (required): Base64-encoded secret used to sign auth tokens
  • JWT_EXPIRES_IN (required): Token lifetime (e.g. 7d, 24h)

Example .env values are provided in .env.example.

Scripts

Common npm scripts:

  • npm start – Run in development with auto-reload (nodemon + babel-node)
  • npm run build – Transpile to dist/ using Babel
  • npm run prod – Start the transpiled server from dist/
  • npm test – Lint the source using ESLint

Project Structure

project-api-man-to-go/
  src/
    controllers/       // Route handlers and business logic
    firebase/          // Firebase Admin SDK initialization
    middleware/        // Auth and upload middlewares
    models/            // Mongoose models
    routes/            // Express routers
    server.js          // App bootstrap and Socket.IO setup
  uploads/             // Static uploads served at /uploads

Running Locally

  1. Ensure MongoDB is reachable via MONGODB_URI
  2. Ensure FIREBASE_SERVICE_ACCOUNT_KEY is a valid JSON string (see .env.example)
  3. Start the server:
npm start

The API will be available at http://localhost:${PORT || 9090}

(back to top)

API Endpoints

All API routes are located in src/routes/

Auth Apis

Method Endpoint Description
POST /api/auth/signup Sign up a user
POST /api/auth/login Login a user
POST /api/auth/forgot-password Request reset password code
POST /api/auth/reset-password Reset password with the code
GET /api/auth/profile Retrieves user's profile
PUT /api/auth/profile/address Update user's address
PUT /api/auth/profile/payment Update user's payment

Cart Apis

Method Endpoint Description
GET /api/cart/ Gets user's cart
POST /api/cart/add Add an item to the cart
DELETE /api/cart/remove Reduce an item in cart
POST /api/cart/checkout Checkout user's cart

Chat Apis

Method Endpoint Description
GET /api/chat/ Get all chats for user
POST /api/chat/order/:orderId Get or create a chat for an order
GET /api/chat/:chatId/messages Get messages for a specific chat
POST /api/chat/:chatId/messages Send a message to a chat
POST /api/chat/:chatId/read Mark messages as read
GET /api/chat/unread/count Get unread message count
DELETE /api/chat/:chatId Delete a chat

Delivery Apis

Method Endpoint Description
GET /api/deliveries/available Get all available deliveries
GET /api/deliveries/available/:deliveryID Get a single delivery by ID
POST /api/deliveries/claim/:deliveryID Drivers can claim a delivery
GET /api/deliveries/driver Gets drivers deliveries
POST /api/deliveries/pickup/:deliveryID Mark delivery as picked up
POST /api/deliveries/start/:deliveryID Mark delivery as enroute
POST /api/deliveries/complete/:deliveryID Mark delivery as completed
POST /api/deliveries/cancel/:deliveryID Mark delivery as cancelled

Locations Apis

Method Endpoint Description
GET /api/locations Get all locations
GET /api/locations/:locationID Get a single location by ID
POST /api/locations Create a new location
GET /api/locations/:locationID/menu Get a location's menu
DELETE /api/locations/:locationID Delete a location by ID

Menu Apis

Method Endpoint Description
GET /api/menu/ Get all menu items
GET /api/menu/:menuItemID Get a single menu item by ID
POST /api/menu/ Create a new menu item

Notifications Apis

Method Endpoint Description
POST /api/notifications/register Register user's device
GET /api/notifications Gets all user's notifications
PATCH /api/notifications/:id/read Mark notification as read
POST /api/notifications/broadcast Broadcast notifications

Orders Apis

Method Endpoint Description
GET /api/orders Gets all orders
GET /api/orders Gets a single order by ID
PUT /api/orders/update/:orderID Update a single order by ID
POST /api/orders/cancel/:orderID Cancel an order

Contributing

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

Authors

(back to top)

Acknowledgments

List of resources we used in this project

(back to top)