GithubHelp home page GithubHelp logo

hubject-sample-charging-station-backend's Introduction

Hubject sample charging station backend for hubject internal usage.

The Sample Electric Car Charging Station backend API provides endpoints to retrieve charging station data and manage review.

This is a test project

Follow the instructions below to install and run the backend API:

Installation

Clone the repository:

git clone https://github.com/hubject/hubject-sample-charging-station-backend

Navigate to the project directory:

cd hubject-sample-charging-station-backend

Install the dependencies:

npm install

Running the API

Start the API server:

npm start

The API server will start running on the configured port (default is 3000).

Open http://localhost:3000/api/charging-stations to test that the server has started

API Endpoints

Get all charging stations

  • Endpoint: GET /api/charging-stations

  • Description: Retrieve all charging stations.

  • Response format: JSON

  • Response body example:

[
    {
        "id": 1,
        "name": "Charging Station 1",
        "address": "Address 1",
        "connectors": ["Type 1", "Type 2"],
        "price": 5.0
    },
    {
        "id": 2,
        "name": "Charging Station 2",
        "address": "Address 2",
        "connectors": ["Type 2", "Type 3"],
        "price": 7.5
    }
]

Search charging stations

  • Endpoint: POST /api/charging-stations/search

  • Description: Search for charging stations based on location or criteria.

  • Request body format: JSON

  • Request body example:

{
    "location": "New York",
    "criteria": "fast"
}
  • Response format: JSON

  • Response body example:

[
    {
    "id": 1,
    "name": "Fast Charging Station",
    "address": "123 Main Street, New York",
    "connectors": ["Type 2", "CHAdeMO"],
    "price": 7.0
    }
]

Get a specific charging station

  • Endpoint: GET /api/charging-stations/:id

  • Description: Retrieve a specific charging station by ID.

  • Parameters:

    • id: The ID of the charging station.
  • Response format: JSON

Response body example:

{
    "id": 1,
    "name": "Charging Station 1",
    "address": "Address 1",
    "connectors": ["Type 1", "Type 2"],
    "price": 5.0
}

Get reviews for a charging station

  • Endpoint: GET /api/charging-stations/:id/reviews

  • Description: Retrieve reviews for a specific charging station.

  • Parameters:

    • id: The ID of the charging station.
  • Response format: JSON

  • Response body example:

[
    {
        "id": 1,
        "chargingStationId": 1,
        "rating": 4,
        "comment": "Good charging station"
    },
    {
        "id": 2,
        "chargingStationId": 1,
        "rating": 5,
        "comment": "Excellent service"
    }
]

Add a review for a charging station

  • Endpoint: POST /api/charging-stations/:id/reviews

  • Description: Add a new review for a charging station.

  • Parameters:

    • id: The ID of the charging station.
  • Request body format: JSON

  • Request body example:

{
    "rating": 4,
    "comment": "Good charging experience"
}
  • Response format: JSON

  • Response body example:

{
    "id": 3,
    "chargingStationId": 1,
    "rating": 4,
    "comment": "Good chargingexperience"
}

hubject-sample-charging-station-backend's People

Contributors

hosseinbarzegari avatar moghaffari avatar tonimarinova avatar

Watchers

 avatar  avatar

Forkers

antonovatanas

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.