https://github.com/shubhamch95/activity-booking-backend
This is a backend API for an activity booking application built with Node.js, Express, and MongoDB. It allows users to register, log in, view available activities, book activities, and view their bookings. The API uses JWT for authentication and bcrypt for password hashing.
https://github.com/shubhamch95/activity-booking-backend
bcryptjs express-validator expressjs javascript mongodb nodejs
Last synced: about 1 month ago
JSON representation
This is a backend API for an activity booking application built with Node.js, Express, and MongoDB. It allows users to register, log in, view available activities, book activities, and view their bookings. The API uses JWT for authentication and bcrypt for password hashing.
- Host: GitHub
- URL: https://github.com/shubhamch95/activity-booking-backend
- Owner: shubhamch95
- Created: 2025-05-07T09:35:37.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-05-07T11:08:42.000Z (about 1 year ago)
- Last Synced: 2025-05-08T02:52:09.593Z (about 1 year ago)
- Topics: bcryptjs, express-validator, expressjs, javascript, mongodb, nodejs
- Language: JavaScript
- Homepage:
- Size: 4.61 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ๐โโ๏ธ Activity Booking API
A simple backend API for user registration, login, listing activities, and booking them โ built with **Node.js**, **Express**, and **MongoDB**.
---
## ๐ฆ Tech Stack
- **Node.js**
- **Express.js**
- **MongoDB** with Mongoose
- **JWT Authentication**
- **bcrypt** for password hashing
- **express-validator** for input validation
---
## โ๏ธ Setup Instructions
### 1. Clone the Repository
```bash
git clone https://github.com/your-username/activity-booking-api.git
cd activity-booking-api
```
### 2. Install Dependencies
```bash
npm install
```
### 3. Configure Environment Variables
Create a `.env` file in the root directory with the following content:
```env
PORT=5000
MONGO_URI=your_mongodb_connection_string
JWT_SECRET=your_super_secret_key
```
### 4. Start the Server
```bash
npm run dev
```
Server will be running at:
๐ `http://localhost:5000`
---
## ๐งช API Endpoints
### โ
Auth
#### `POST /api/auth/register`
Register a user
**Body:**
```json
{
"name": "John Doe",
"email": "john@example.com",
"phone": "1234567890",
"password": "your_password"
}
```
#### `POST /api/auth/login`
Login and get a token
**Body:**
```json
{
"email": "john@example.com",
"password": "your_password"
}
```
---
### ๐
Activities
#### `GET /api/activity/getActivities`
Get a list of all public activities
#### `POST /api/activity/createActivity`
Create a new activity (authorized users only)
**Headers:**
`Authorization: Bearer `
**Body:**
```json
{
"title": "Yoga Session",
"description": "A relaxing yoga class",
"location": "Community Center",
"date": "2025-06-01",
"time": "10:00 AM"
}
```
---
### ๐ Bookings
#### `POST /api/booking/book/:activityId`
Book an activity
**Headers:**
`Authorization: Bearer `
#### `GET /api/booking/myBookings`
List the user's booked activities
**Headers:**
`Authorization: Bearer `
---
## โ
Bonus Features
- ๐ Passwords securely hashed with **bcrypt**
- ๐ก JWT token-based authentication
- ๐ฅ Input validation via **express-validator**
- ๐งน Clean, modular code structure
---
## ๐ Folder Structure
```
๐ฆ project-root
โโโ controllers/
โโโ models/
โโโ routes/
โโโ middleware/
โโโ validators/
โโโ config/
โโโ server.js
โโโ .env
โโโ README.md
```
## Contributing
๐ Contributions are welcome! Follow these steps:
1. **Fork the repository.**
2. **Create a new feature branch.**
3. **Commit your changes.**
4. **Push to your branch and submit a Pull Request (PR).**
## License
๐ **MIT License** - Free to use and modify!
---
Made with โค๏ธ