https://github.com/walgaur/yatra
Backend for indian-tourism-project. Currently I am refactoring and migrating the entire codebase to typescript.
https://github.com/walgaur/yatra
express-js firebase mongodb node nodemailer typescript
Last synced: 10 days ago
JSON representation
Backend for indian-tourism-project. Currently I am refactoring and migrating the entire codebase to typescript.
- Host: GitHub
- URL: https://github.com/walgaur/yatra
- Owner: walgaur
- License: mit
- Created: 2023-10-27T05:14:30.000Z (over 2 years ago)
- Default Branch: mainline
- Last Pushed: 2025-07-30T21:42:15.000Z (11 months ago)
- Last Synced: 2025-11-12T21:24:20.838Z (8 months ago)
- Topics: express-js, firebase, mongodb, node, nodemailer, typescript
- Language: TypeScript
- Homepage: https://indian-tourism.vercel.app
- Size: 1.54 MB
- Stars: 3
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
- License: License
Awesome Lists containing this project
README
Indian Tourism API Documentation
All the APIs uses JSON Web Tokens (JWT) for authentication, which are automatically stored as HTTP Cookies. No manual token handling is required.
User Authentication Endpoints
| | API Endpoint | Method | Auth | Description |
| --- | ----------------------------------------- | ------ | ---- | ----------------------- |
| 1. | [/api/auth/login](#login) | POST | NO | Send a login request |
| 2. | [/api/auth/signup](#signup) | POST | NO | Send a singup request |
| 3. | [/api/auth/logout](#logout) | POST | YES | Logout the current user |
| 4. | [/api/auth/forgot-password](#forgot-pass) | POST | NO | Reset the password |
User Operation Endpoints
| | API Endpoint | Method | Auth | Description |
| --- | ------------------------------------------------------- | ------ | ---- | ------------------------ |
| 1. | [/api/update/user](#user-update) | POST | YES | Update User Details |
| 2. | [/api/user/details/{userId}](#user-details) | GET | YES | Get user details |
| 3. | [/api/user/bookings/{userId}](#user-bookings) | GET | YES | Get user's bookings |
| 4. | [/api/book/cancellations/{userId}](#user-cancellations) | GET | YES | Get user's cancellations |
Location Endpoints
| | API Endpoint | Method | Auth | Description |
| --- | -------------------------------------------------------------- | ------ | ---- | ------------------------------- |
| 1. | [/api/location/add-location/](#add-location) | POST | YES | Add new location |
| 2. | [/api/location/update-location/{locationId}](#update-location) | GET | YES | Update location data |
| 3. | [/api/location/](#random-location) | GET | NO | Get random locations |
| 4. | [/api/location/search/kolkata](#search-location) | GET | NO | Search for a locations |
| 5. | [/api/location/get-availability/{locationId}](#location-avail) | GET | NO | Get Location's availablity data |
Booking Endpoints
| | API Endpoint | Method | Auth | Description |
| --- | ------------------------------------------------- | ------ | ---- | ------------------------------ |
| 1. | [/api/book/lock/](#lock-booking) | POST | YES | Temporarily lock a booking |
| 2. | [/api/book/lock/details/{lockId}](#lock-details) | GET | YES | Get booking lock details |
| 3. | [/api/book/final](#finalize-booking) | POST | YES | Finalize the locked booking |
| 4. | [/api/book/cancel](#cancel-booking) | POST | YES | Cancel a booking |
| 5. | [/api/book/cancel/approve](#approve-cancellation) | POST | YES | Approve a cancellation request |
One Time Password (OTP) Endpoints
| | API Endpoint | Method | Auth | Description |
| --- | ----------------------------------- | ------ | ---- | ----------------------------------------------- |
| 1. | [/api/auth/resend-otp](#send-otp) | POST | YES | Send email verification or password reset OTP |
| 2. | [/api/auth/verify-otp](#verify-otp) | POST | \* | Resend email verification or password reset OTP |
---
API Usage Instructions
Creating a login request
Send a `POST` request to the `/api/auth/login` endpoint.
```http
POST http://example.com/api/auth/login
Content-Type: application/json
{
"email": "email@domain.com",
"password": "yourPassword"
}
```
Creating a signup request
Send a `POST` request to the `/api/auth/signup` endpoint.
```http
POST http://example.com/api/auth/signup
Content-Type: application/json
{
"email": "email@domain.com",
"password": "yourPassword"
}
```
The request body should also contain the following information
`middleName`, `email`, `phone`, `addressMain`, `country`, `state`, `city`, `pincode`, `dob` with their values in **string** format.
Making a logout request
Send a `POST` request to the `/api/auth/logout` endpoint.
```http
POST http://example.com/api/auth/logout
Content-Type: application/json
{
"email": "email@domain.com",
}
```
Resetting the password
Send a `POST` request to the `/api/auth/forgot-password` endpoint.
```http
POST http://example.com/api/auth/forgot-password
Content-Type: application/json
{
"email": "email@domain.com",
}
```
Updating user details
Send a `POST` request to the `/api/update/user` endpoint.
```http
POST http://example.com/api/update/user
Content-Type: multipart/form-data
{
"firstName": "modified-first-name",
"lastName" : "modified-last-name",
"email": "email@domain.com",
}
```
The multipart form data can also contain the following fields
`middleName`, `email`, `phone`, `addressMain`, `country`, `state`, `city`, `pincode`, `dob` in **string** format.
Fetching user details
Send a `GET` request to the `/api/user/details/{userId}` endpoint.
```http
GET http://example.com/api/user/details/{userId}
```
Fetching all the locations booked by a user
Send a `GET` request to the `/api/user/bookings/{userId}` endpoint.
```http
GET http://example.com/api/user/bookings/{userId}
```
Fetching all the bookings cancelled by a user
Send a `GET` request to the `/api/user/cancellations/{userId}` endpoint.
```http
GET http://example.com/api/user/cancellations/{userId}
```
Request to add a new location
Send a `POST` request to the `/api/location/add-location` endpoint.
```http
POST http://example.com/api/location/add-location
Content-Type: application/json
{
"name" : "name-of-the-location"
"description" : "description-of-the-location"
"address" : "address-of-the-location"
}
```
The request body JSON should also contain all these fields.
`city`, `state`, `country`, `pincode`, `latitude`, `longitude`, `ticketPrice` containing string data,
`cover-iamge1`, `cover-iamge2`, `cover-iamge3`, `slider-image1`, `slider-image2` and `slider-image3` containing image data.
Updating a location data
Send a `POST` request to the `/api/location/update-location/{locationId}` endpoint.
```http
POST http://example.com/api/location/update-location/{locationId}
Content-Type: application/json
{
"name" : "updated-name"
"description" : "updated-description"
"address" : "updated-address"
}
```
The request body JSON MAY contain all these fields.
`city`, `state`, `country`, `pincode`, `latitude`, `longitude`, `ticketPrice` containing updatedstring data,
`cover-iamge1`, `cover-iamge2`, `cover-iamge3`, `slider-image1`, `slider-image2` and `slider-image3` containing updated image data.
Fetching random location's data
Send a `GET` request to the `/api/location/` endpoint.
```http
GET http://example.com/api/location/
```
Search locations using search string
Send a `GET` request to the `/api/location/search/{seaerchString}` endpoint.
```http
GET http://example.com/api/location/{searchString}
```
Get location's availability data
Send a `GET` request to the `/api/location/get-availability/{locationId}` endpoint.
```http
GET http://example.com/api/location/get-availability/{locationId}
```
Temporarily lock a booking
Send a `POST` request to the `/api/book/lock` endpoint.
```http
POST http://example.com/api/location/get-availability/{locationId}
Content-Type: application/json
{
"locationId" : location-id,
"noOfTickets" : 3,
"bookingDate" : "01-01-0001"
}
```
Fetch the booking lock details
Send a `GET` request to the `/api/book/lock/details/{lockId}` endpoint.
```http
GET http://example.com/api/book/lock/details/{lockId}
```
Finalizing the booking using the lock ID
Send a `POST` request to the `/api/book/final` endpoint.
```http
POST http://example.com/api/book/final
Content-Type: application/json
{
"lockId" : 123,
"paymentId": "random-payment-id"
}
```
Submit a cancellation request to the admin
Send a `POST` request to the `/api/book/cancel` endpoint.
```http
POST http://example.com/api/book/cancel
Content-Type: application/json
{
"bookingId" : 123,
"userId" : 1234
}
```
Approving the ticket cancellation request
Send a `POST` request to the `/api/book/cancel/approve` endpoint.
```http
POST http://example.com/api/book/cancel/approve
Content-Type: application/json
{
"bookingId" : 123,
"adminId" : 1234
}
```
Send OTP for email verification or password reset
Send a `POST` request to the `/api/auth/resend-otp` endpoint.
```http
POST http://example.com/api/auth/resend-otp
Content-Type: application/json
{
"email": "lipapad224@wiroute.com",
"otpType": "passwordReset"
}
```
**otpType** key can accept two values.
Use `passwordReset` when the OTP is to validate user for password reset.
Use `emailVerification` the email of the user needs to be verified (during first signup)
Verify the OTP sent to the user's email id
Send a `POST` request to the `/api/auth/verify-otp` endpoint.
```http
POST http://example.com/api/auth/verify-otp
Content-Type: application/json
{
"email": "email@domain.com",
"otp": "anOtP",
"otpType": "passwordReset"
}
```
**otpType** key can accept two values.
Use `passwordReset` when you want to validate the OTP sent to reset the password.
Use `emailVerification` when you want to validate the OTP sent to verify the user's email id.
---