Skip to content

Latest commit

 

History

History
168 lines (111 loc) · 2.59 KB

readme.md

File metadata and controls

168 lines (111 loc) · 2.59 KB

License: MIT JavaScript Style Guide

devplaces-backend

This is the backend application for DevPlaces, a small project inspired in Rocketseat OmniStack Week 9

Get Started

  1. Clone the project
  git clone https://github.com/rafaelcalhau/devplaces-backend.git
  1. Navigate into the project folder
  cd devplaces-backend
  1. Install all dependencies using the NPM or YARN
  npm install # or yarn
  1. Rename the file .env.example to .env and edit it with your own data.
  cp .env.example .env

Usage

🚨 NOTICE: before running the project, make sure your .env file is already created and have all necessary values. This application uses MongoDB, and if you don't want to run it on your local environment, you can create your database totally free on MongoDB Atlas.


Run for development:

  npm run dev # or yarn dev

Public Routes

  • Sign In:

    POST /api/authenticate

    {
      "email": "string",
      "password": "string"
    }
  • Create User

    POST /api/users

    body:

    {
      "name": "string",
      "email": "string",
      "password": "string"
    }

Private Routes

Required: Add your user id into the request headers

{
  "userid": "string"
}

SPOTS

  • Create a spot

    POST /spots

    body:

    {
      "company": "string",
      "price": 15.0,
      "technologies": "php,javascript,react"
    }

    Accepts an file upload.

  • Update a spot

    PUT /spots/:id

    body:

    {
      "company": "string",
      "price": 15.0,
      "technologies": "php,javascript,react"
    }

    Accepts an file upload.

  • Delete a spot

    DELETE /spots/:id

  • List all spots

    GET /spots

BOOKINGS

  • Book a spot

    POST /spots/:spot_id/bookings

    body:

    {
      "date": "string"
    }
  • Update a booking

    PATCH /spots/:spot_id/bookings/:booking_id

    body:

    {
      "approved": "boolean"
    }
  • Delete a booking

    DELETE /spots/:spot_id/bookings/:booking_id

  • List all bookings from a spot

    GET /spots/:spot_id/bookings


License

MIT