Skip to content

PlaceEYE/2024Server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

API Documentation

Base URL

http://localhost:3000

Endpoints

1. Register a New Client

  • Endpoint: /register
  • Method: POST
  • Description: Registers a new client with a unique name. Returns an error if the name already exists.

Request Body:

{
  "name": "someName"
}

Response:

  • 201 Created:
{
  "id": 1,
  "name": "someName",
  "enter": false,
  "qrPresent": false,
  "exhibitionSection": null
}
  • 400 Bad Request:
{
  "error": "Name already exists"
}
  • 500 Internal Server Error:
{
  "error": "Error message"
}

2. QR Scan

  • Endpoint: /qr-scan
  • Method: POST
  • Description: Updates the enter status of a client. If enter is false, sets it to true and returns entered: false. If enter is true, returns entered: true.

Request Body:

{
  "id": 1
}

Response:

  • 200 OK (if enter was previously false):
{
  "entered": false
}
  • 200 OK (if enter was previously true):
{
  "entered": true
}
  • 404 Not Found:
{
  "error": "Client not found"
}
  • 500 Internal Server Error:
{
  "error": "Error message"
}

3. Move Client to Section

  • Endpoint: /move
  • Method: POST
  • Description: Moves a client to a specified exhibition section (A, B, C, or D).

Request Body:

{
  "id": 1,
  "section": "A"
}

Response:

  • 200 OK:
{
  "section": "A"
}
  • 400 Bad Request:
{
  "error": "Invalid section"
}
  • 404 Not Found:
{
  "error": "Client not found"
}
  • 500 Internal Server Error:
{
  "error": "Error message"
}

4. Login

  • Endpoint: /login
  • Method: POST
  • Description: Returns the ID of the client with the specified name.

Request Body:

{
  "name": "someName"
}

Response:

  • 200 OK:
{
  "id": 1
}
  • 404 Not Found:
{
  "error": "Name not found"
}
  • 500 Internal Server Error:
{
  "error": "Error message"
}

Example Usage

Register a New Client

curl -X POST http://localhost:3000/register -H "Content-Type: application/json" -d '{"name": "John Doe"}'

QR Scan

curl -X POST http://localhost:3000/qr-scan -H "Content-Type: application/json" -d '{"id": 1}'

Move Client to Section

curl -X POST http://localhost:3000/move -H "Content-Type: application/json" -d '{"id": 1, "section": "B"}'

Login

curl -X POST http://localhost:3000/login -H "Content-Type: application/json" -d '{"name": "John Doe"}'

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published