Skip to content

MKDdkm/skill-lab-assignmnet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Synergia Event Booking API

A REST API built with Node.js and Express.js to manage event bookings for Synergia technical event.

Features

  • View all event bookings
  • Register for the event
  • View specific booking details
  • Update participant information
  • Cancel bookings
  • In-memory data storage (no database required)

Installation

  1. Install dependencies:
npm install
  1. Start the server:
npm start

The server will run on http://localhost:3000

API Endpoints

Method Endpoint Description
GET /api/bookings Get all event bookings
POST /api/bookings Create a new booking
GET /api/bookings/:id Get booking by ID
PUT /api/bookings/:id Update participant details
DELETE /api/bookings/:id Cancel a booking

API Usage Examples

1. Get All Bookings

GET http://localhost:3000/api/bookings

Response:

{
  "success": true,
  "count": 2,
  "data": [
    {
      "id": 1,
      "participantName": "John Doe",
      "email": "john.doe@example.com",
      "phone": "1234567890",
      "eventName": "Synergia 2025",
      "registrationDate": "2025-10-29T..."
    }
  ]
}

2. Create a New Booking

POST http://localhost:3000/api/bookings
Content-Type: application/json

{
  "participantName": "Alice Johnson",
  "email": "alice@example.com",
  "phone": "5551234567"
}

Response:

{
  "success": true,
  "message": "Booking created successfully",
  "data": {
    "id": 3,
    "participantName": "Alice Johnson",
    "email": "alice@example.com",
    "phone": "5551234567",
    "eventName": "Synergia 2025",
    "registrationDate": "2025-10-29T..."
  }
}

3. Get Booking by ID

GET http://localhost:3000/api/bookings/1

Response:

{
  "success": true,
  "data": {
    "id": 1,
    "participantName": "John Doe",
    "email": "john.doe@example.com",
    "phone": "1234567890",
    "eventName": "Synergia 2025",
    "registrationDate": "2025-10-29T..."
  }
}

4. Update Participant Details

PUT http://localhost:3000/api/bookings/1
Content-Type: application/json

{
  "participantName": "John Updated",
  "email": "john.updated@example.com"
}

Response:

{
  "success": true,
  "message": "Booking updated successfully",
  "data": {
    "id": 1,
    "participantName": "John Updated",
    "email": "john.updated@example.com",
    "phone": "1234567890",
    "eventName": "Synergia 2025",
    "registrationDate": "2025-10-29T..."
  }
}

5. Cancel a Booking

DELETE http://localhost:3000/api/bookings/1

Response:

{
  "success": true,
  "message": "Booking cancelled successfully",
  "data": {
    "id": 1,
    "participantName": "John Updated",
    "email": "john.updated@example.com",
    "phone": "1234567890",
    "eventName": "Synergia 2025",
    "registrationDate": "2025-10-29T..."
  }
}

Testing with cURL (PowerShell)

Get all bookings:

curl http://localhost:3000/api/bookings

Create a new booking:

curl -Method POST -Uri http://localhost:3000/api/bookings -Headers @{"Content-Type"="application/json"} -Body '{"participantName":"Alice Johnson","email":"alice@example.com","phone":"5551234567"}'

Get booking by ID:

curl http://localhost:3000/api/bookings/1

Update booking:

curl -Method PUT -Uri http://localhost:3000/api/bookings/1 -Headers @{"Content-Type"="application/json"} -Body '{"participantName":"John Updated","email":"john.updated@example.com"}'

Delete booking:

curl -Method DELETE -Uri http://localhost:3000/api/bookings/1

Project Structure

skill-lab-5c/
├── server.js          # Main Express server file
├── package.json       # Project dependencies
├── README.md         # This file
└── node_modules/     # Dependencies folder

Technologies Used

  • Node.js: JavaScript runtime
  • Express.js: Web framework for Node.js
  • In-Memory Storage: Array-based data storage

Notes

  • Data is stored in memory and will be lost when the server restarts
  • The server includes two sample bookings by default
  • All responses follow a consistent JSON format with success/error indicators

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published