This project is a ride service API developed with Express.js and Node.js. The API allows for creating, canceling, and listing rides, as well as user registration and authentication.
- Installation
- Usage
- API Routes
- Swagger Documentation
-
Clone the repository:
git clone https://github.com/your-username/ride-service-api.git
-
Navigate to the project directory:
cd ride-service-api
-
Install the dependencies:
npm install
-
Create a .env file in the root of the project and add the following environment variables:
API_BASE_URL=http://localhost:3000
NODE_ENV=development
JWT_SECRET=your_jwt_secret
To start the server, run:
npm start
The server will be running at http://localhost:3000.
Endpoint: POST /rides/register
Request Body:
{
"email": "[email protected]",
"password": "yourpassword"
}
Response:
- 201 Created
{
"id": 1,
"email": "[email protected]"
}
Endpoint: POST /rides/login
Request Body:
{
"email": "[email protected]",
"password": "yourpassword"
}
Endpoint: POST /rides/create
Request Body:
{
"user_id": "user123"
}
Response:
- 201 Created
{
"id": 1,
"user_id": "user123",
"status": "active",
"created_at": "2024-06-17T00:00:00.000Z"
}
Endpoint: POST /rides/cancel/:id
Parameters:
- id (Number): ID of the ride to be canceled.
Response:
- 200 OK
{
"id": 1,
"status": "canceled"
}
Endpoint: GET /rides
Response:
- 200 OK
[
{
"id": 1,
"user_id": "user123",
"status": "active",
"created_at": "2024-06-17T00:00:00.000Z"
},
{
"id": 2,
"user_id": "user456",
"status": "completed",
"created_at": "2024-06-17T00:00:00.000Z"
}
]
Response:
- 200 OK
[]
The API documentation is available via Swagger. To view the documentation, navigate to /api-docs in your browser.