Skip to content

DevoAlex/OrizonAPI

Repository files navigation

✈️ MeditAPI

REST API for a sustainable travel agency application.

❓ Why

This project is the final practice for start2impact Node.js course.

💡 How it works

This API has three data Schemas:

  • Users: data of the subscripted users
  • products: the trips available in the agency
  • Orders: the orders already booked by the users

Using the correct endpoints you can Create, Read, Update ore Delete (CRUD) users,products and orders. You can search for the orders using the id, the date they were created and the products they contain. For this project I used Node.js (with Express) and MongoDB database.

📚 Libraries

  • Express
  • dotenv
  • Helmet
  • Morgan
  • Mongoose
  • Date-fns

💾 Installation

First of all, you need Node.js installed.
If you don't have it, you can download it here: Node.js
After the installation, you're ready to go.

1 - Clone the repository

git clone https://github.com/DevoAlex/OrizonAPI.git

2 - Install the dependencies

npm install

3 - Start it

npm start

4 - Connect your MongoDB database

Create, if doesn't exist, a .env file and then insert an enviroment variable named DB_URIwith your MongoDB connection string.
Example: DB_URI="mongodb+srv://...

5 - Test it with a client

Using something like Postman, Thunderclient or Insomnia, you can start using this API on the port 3000.

📂 Endpoints

Users

You can get the entire users list with a GET request:

/users

or GET data for a specific user:

/users/:userId

:userID must be a valid MongoDB id.
You can PATCH or DELETE user data with the same endpoint.

Finally, you can add a new user with a POST request:

/users

{
    "firstName": "insert an alphanumeric string",
    "lastName": "insert an alphanumeric string",
    "email": "insert an email"
}

Products

You can get the entire products list with a GET request:

/products

or GET data for a specific target:

/products/:productId

:productId must be a valid MongoDB id.
You can PATCH or DELETE a product with the same endpoint.

Finally, you can add a new product with a POST request:

/products

{
    "name": "insert an alphanumeric string",
    "price": "insert a number"
}

Orders

You can get all the orders with a GET request

/orders

or GET data for a specific order:

/orders/:orderId

You can PATCH or DELETE an order with the same endpoint.

For a new order, use a POST request:

/orders

{
  "product": "insert a valid mongoID that represents the products ordered",
  "user": "insert the userId of the owner of the order",
  "createdOn": "defaults to the date when the order has been made"
}

You can search for orders with a certain date or product:

/orders/createdOn/:date for getting orders made in a certain date, /orders/containsProduct/:productId" for getting orders that contain a certain product,

📃 License

MIT

📧 Contact Me

Any questions? Send me an e-mail here: alexpeluso.dev@gmail.com
You can find my Linkedin profile here: https://www.linkedin.com/in/alex-peluso-a42347227/

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published