https://github.com/mohosin2126/fitness-and-sports-partner-server-v1
This Node.js Express server connects to MongoDB, handles fitness service operations, bookings, and manages additional services. It uses MongoDB for data storage and provides RESTful APIs
https://github.com/mohosin2126/fitness-and-sports-partner-server-v1
Last synced: 3 months ago
JSON representation
This Node.js Express server connects to MongoDB, handles fitness service operations, bookings, and manages additional services. It uses MongoDB for data storage and provides RESTful APIs
- Host: GitHub
- URL: https://github.com/mohosin2126/fitness-and-sports-partner-server-v1
- Owner: mohosin2126
- Created: 2023-11-08T08:34:06.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-12-10T06:23:12.000Z (over 1 year ago)
- Last Synced: 2025-01-14T22:41:20.046Z (5 months ago)
- Language: JavaScript
- Homepage:
- Size: 14.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# fitness-and-sports-partner-server
- Dependencies and Configuration:
Dependencies like express, cors, and mongodb are imported.
The Express application is created, and the server's port is set.
- Middleware Setup:CORS middleware is used to handle cross-origin resource sharing.
Express is configured to parse incoming JSON requests.
- MongoDB Connection:Connection to MongoDB is established using a connection string, username, and password.
The MongoDB client is configured with specific API version settings.
- Async Function for Server Setup:An asynchronous function named run is defined to set up endpoints and handle database operations.
The function connects to MongoDB and defines collections for services and bookings.
- Service and Booking Collections:Collections for services, bookings, and a new service are created from the connected MongoDB database.
- Service Endpoints:Endpoints are created for retrieving all services, fetching a specific service by ID, and searching services by text.
- Booking Endpoints:APIs are implemented for retrieving bookings and adding new bookings.
- New Service Endpoints:Endpoints for adding, retrieving, updating, and deleting new services are defined.
- Ping Command:A ping command is included to check the connection to the MongoDB deployment and log a success message.
- Server Initialization:A simple "fitness is running" response is set for the root endpoint.
The server is configured to listen on the specified port.