/modern-restful-API

Simple and efficient way to handle HTTP requests and interact with a MongoDB database

Primary LanguageTypeScript

REST API - Brush up



Simple and efficient way to handle HTTP requests and interact with a MongoDB database


MAIN OBJECTIVES:


  • Create a robust and scalable API with Express and modern technologies, following best practices (see: node best practices)

  • Improved code maintainability and type safety with TypeScript.

  • Integrating and interacting with a MongoDB database, using Mongoose (ODM)

  • Organizing the codebase using controllers, middlewares, and routes for better maintainability.

  • Implementing authentication mechanisms for user management.


TOOLS USED


Node.js & Express.js:
Node for the runtime environment for executing JavaScript on the server-side and Express framework for building robust and scalable APIs.

MongoDB & Mongoose:
A NoSQL database using Mongoose ODM (Object Document Mapper) for MongoDB, straightforward way to interact with the database.

TypeScript:
A superset of JavaScript that adds static typing and other features for better code quality.

Lodash:
A utility library providing useful functions for working with arrays, objects, and more.

Nodemon:
A utility that monitors for changes in files and automatically restarts the server.

Body-parser:
Middleware for parsing incoming request bodies.

Compression:
Middleware for compressing responses to reduce response times.

Cookie-parser:
Middleware for parsing cookies attached to the client's request.

Cors:
Middleware for handling Cross-Origin Resource Sharing.



Running Locally 🏃‍♂️


Prerequisites :

Node version 18.15.x

1. Cloning the repository
git clone 
2. Install packages
npm i
3. Setup MongoDB URL
src/index.ts

const MONGO_URL = ''; // INSERT YOUR DB URI

Finally, run app w/ available commands

Running commands with npm npm run [command]

command description
start Starts a development instance of the app