Code Monkey home page Code Monkey logo

housereserve-backend-nodejs's Introduction

House Reserve | Back-end | NodeJS

A NodeJS API to register houses for rent using email and make reservations.

How to configure the project:

If you use npm, just replace the yarn > npm.

  • Clone the repository to your computer, navigate to the folder and use the command yarn install to install the dependencies.

  • Turn on your database and create a database with the name of housereserve (or whatever you prefer). > This project was created using MongoDB.

  • Open the project folder in your text editor to include your database information:

The information of what to fill is commented in the scripts.

  • Navigate to src > app.js and add your MongoDB connection URL.
  • Navigate to src > server.js and include the port the server will listen to.
  • Navigate to src > models > House.js and include your host and port to save the image upload.

Now start the project with the command yarn dev (accessing the project's root folder from the terminal).

If you have followed the steps here, everything is ready for use! Now just use the API on your front-end or test the routes using Insomnia.

Access routes to the API:

Replace base_url with your server's url. Example: localhost:3333

User routes

  • Route to create and login user: base_url/sessions

Example: { "email": "YOUR_EMAIL", }

Registration routes

  • Route to register house: base_url/houses (necessary to send the headers with user_id and use in body multipart/form-data)

Example: > thumbnail YOUR_IMAGE_FILE description HOUSE_DESCRIPTION price HOUSE_PRICE location HOUSE_LOCATION status TRUE_OR_FALSE >

  • Route to update register house: base_url/houses/:house_id (where house_id is the house id. Necessary to send the headers with user_id and use in body multipart/form-data)

Example: > thumbnail YOUR_IMAGE_FILE description HOUSE_DESCRIPTION price HOUSE_PRICE location HOUSE_LOCATION status TRUE_OR_FALSE >

  • Route to list all houses: base_url/houses (necessary to send the query params with status TRUE or status FALSE to list available or unavailable houses)

  • Route to delete house: base_url/houses (necessary to send the headers with user_id and a JSON body with house_id)

Example: { "house_id": "YOUR_HOUSE_ID" }

Routes to create reservation

  • Route to create reserve: base_url/houses/:house_id/reserve (where :house_id is the house id. Necessary to send the headers with user_id and a JSON body with reserve date)

Example: { "date": "YOUR_RESERVE_DATE" }

  • Route to cancel reserve: base_url/reserves/cancel (just send a JSON body with reserve id)

Example: { "reserve_id": "YOUR_RESERVE_ID" }

  • Route to list all reserves: base_url/reserves (just send the headers with user_id)

Routes to the dashboard with your registered houses

  • Route to list all registers: base_url/dashboard (just send the headers with user_id)

Doubts? Send me a message on my social networks. Good luck! ;)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.