{"id":24648298,"url":"https://github.com/sabuj-chowdhury/campflow_server","last_synced_at":"2026-05-13T07:36:20.440Z","repository":{"id":272528729,"uuid":"916875577","full_name":"Sabuj-Chowdhury/CampFlow_Server","owner":"Sabuj-Chowdhury","description":" CampFlow server","archived":false,"fork":false,"pushed_at":"2025-02-17T19:52:49.000Z","size":112,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-20T17:35:39.778Z","etag":null,"topics":["cors","express-js","jwt","mongodb","stripe-payments"],"latest_commit_sha":null,"homepage":"https://campflow-ten.vercel.app/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Sabuj-Chowdhury.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-01-14T23:22:02.000Z","updated_at":"2025-02-17T19:52:52.000Z","dependencies_parsed_at":"2025-01-15T02:50:34.798Z","dependency_job_id":"0a47c0c0-f09d-4ff7-9b5f-7e936ebf97af","html_url":"https://github.com/Sabuj-Chowdhury/CampFlow_Server","commit_stats":null,"previous_names":["sabuj-chowdhury/campflow_server"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Sabuj-Chowdhury/CampFlow_Server","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sabuj-Chowdhury%2FCampFlow_Server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sabuj-Chowdhury%2FCampFlow_Server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sabuj-Chowdhury%2FCampFlow_Server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sabuj-Chowdhury%2FCampFlow_Server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Sabuj-Chowdhury","download_url":"https://codeload.github.com/Sabuj-Chowdhury/CampFlow_Server/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sabuj-Chowdhury%2FCampFlow_Server/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32973310,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-13T06:31:55.726Z","status":"ssl_error","status_checked_at":"2026-05-13T06:31:51.336Z","response_time":115,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cors","express-js","jwt","mongodb","stripe-payments"],"created_at":"2025-01-25T16:14:52.021Z","updated_at":"2026-05-13T07:36:20.387Z","avatar_url":"https://github.com/Sabuj-Chowdhury.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CampFlow Server Documentation\n\nWelcome to the CampFlow server documentation. This guide provides detailed information about the setup and functionality of the CampFlow backend server, hosted at [CampFlow Server](https://campflow-ten.vercel.app).\n\n## Overview\n\nThe CampFlow server is a express.js-based backend application that provides APIs for managing users, campaigns, registrations, payments, and reviews. It integrates with MongoDB for data storage, Stripe for payment processing, and Nodemailer for email handling. JWT is used for secure authentication.\n\n---\n\nThe server is hosted at: [CampFlow Server](https://campflow-ten.vercel.app)\n\n## Environment Variables\n\nTo run this server locally, you need to set the following environment variables in a `.env` file. **Do not include actual values in the file for security reasons.**\n\n```env\nDB_USER=your_database_username # Username for the database connection\nDB_PASS=your_database_password # Password for the database connection\nACCESS_TOKEN=your_jwt_access_token_secret # Secret for signing JWT tokens\nSTRIPE_SECRET_KEY=your_stripe_secret_key # Secret key for Stripe payment integration\nUSER_EMAIL=your_email_for_nodemailer # Email address for sending notifications\nUSER_PASS=your_email_password_for_nodemailer # Password for the email account\n```\n\nEnsure these values are set correctly for the server to function properly.\n\n## Dependencies\n\nThe server uses the following dependencies:\n\n```json\n\"dependencies\": {\n  \"cors\": \"^2.8.5\",\n  \"dotenv\": \"^16.4.7\",\n  \"express\": \"^4.21.2\",\n  \"jsonwebtoken\": \"^9.0.2\",\n  \"mongodb\": \"^6.12.0\",\n  \"morgan\": \"^1.10.0\",\n  \"nodemailer\": \"^6.9.16\",\n  \"stripe\": \"^17.5.0\"\n}\n```\n\n---\n\n## Installation and Setup\n\n1. **Clone the repository:**\n\n   ```bash\n   git clone https://github.com/Sabuj-Chowdhury/CampFlow_Server\n   ```\n\n2. **Install dependencies:**\n\n   ```bash\n   npm install\n   ```\n\n3. **Create `.env` file:**\n   Add the required environment variables as mentioned above.\n\n4. **Start the server:**\n   ```bash\n   npm start\n   ```\n   The server will run on `http://localhost:8000` by default.\n\n---\n\n## Database Collections\n\n- **Users:** Stores user data.\n- **Campaigns:** Stores campaign details.\n- **Registrations:** Tracks user registrations.\n- **Payments:** Logs payment details.\n- **Reviews:** Manages user reviews.\n\n---\n\n## Technologies Used\n\n- **Backend Framework:** Node.js, Express.js\n- **Database:** MongoDB\n- **Authentication:** JWT\n- **Payment Gateway:** Stripe\n- **Email Service:** Nodemailer\n- **Hosting:** Vercel\n\n---\n\n## Base URL\n\n```\nhttps://campflow-ten.vercel.app\n```\n\n---\n\n## Middleware\n\n### `verifyToken`\n\nValidates JWT tokens for secure API access. Adds decoded token to `req.decoded`.\n\n### `verifyAdmin`\n\nChecks if the user is an admin. Requires `verifyToken` middleware.\n\n---\n\n## Routes\n\n### **JWT**\n\n#### Generate JWT Token\n\n- **POST** `/jwt`\n- **Description**: Generates a JWT token for a user.\n- **Request Body**:\n  ```json\n  {\n    \"email\": \"user@example.com\",\n    \"role\": \"user\"\n  }\n  ```\n- **Response**:\n  ```json\n  {\n    \"token\": \"\u003cJWT_TOKEN\u003e\"\n  }\n  ```\n\n---\n\n### **Users**\n\n#### Save User\n\n- **POST** `/users`\n- **Description**: Saves a new user in the database.\n- **Request Body**:\n  ```json\n  {\n    \"name\": \"John Doe\",\n    \"email\": \"john@example.com\",\n    \"password\": \"securepassword\"\n  }\n  ```\n- **Response**:\n  ```json\n  {\n    \"insertedId\": \"\u003cUSER_ID\u003e\"\n  }\n  ```\n\n#### Get User Data\n\n- **GET** `/user/:email`\n- **Description**: Fetches user details by email.\n- **Authorization**: Requires `verifyToken`.\n\n#### Check Admin Status\n\n- **GET** `/user/admin/:email`\n- **Description**: Checks if a user is an admin.\n- **Authorization**: Requires `verifyToken`.\n\n#### Update User\n\n- **PATCH** `/user/update/:id`\n- **Description**: Updates user details.\n- **Authorization**: Requires `verifyToken`.\n- **Request Body**:\n  ```json\n  {\n    \"name\": \"Updated Name\",\n    \"image\": \"image_url\",\n    \"address\": \"Updated Address\",\n    \"phone\": \"1234567890\"\n  }\n  ```\n\n---\n\n### **Camps**\n\n#### Add Camp\n\n- **POST** `/add-camp`\n- **Description**: Adds a new camp.\n- **Authorization**: Requires `verifyToken` and `verifyAdmin`.\n\n#### Get All Camps\n\n- **GET** `/camps`\n- **Description**: Retrieves all camps.\n\n#### Get Popular Camps\n\n- **GET** `/camps/popular`\n- **Description**: Retrieves the top 6 popular camps.\n\n#### Get Camp Details\n\n- **GET** `/camp/:id`\n- **Description**: Retrieves details of a specific camp by ID.\n\n#### Search and Sort Camps\n\n- **GET** `/available-camps`\n- **Description**: Searches and sorts camps based on query parameters.\n- **Query Parameters**:\n  - `sort`: `count`, `camp-fees`, or `alphabetical`\n  - `search`: Search term\n\n#### Update Camp\n\n- **PUT** `/camp/:id`\n- **Description**: Updates camp details.\n- **Authorization**: Requires `verifyToken` and `verifyAdmin`.\n\n#### Delete Camp\n\n- **DELETE** `/camp/:id`\n- **Description**: Deletes a camp by ID.\n- **Authorization**: Requires `verifyToken`.\n\n---\n\n### **Registrations**\n\n#### Save Registration\n\n- **POST** `/camp/registration`\n- **Description**: Saves a registration and updates camp count.\n- **Authorization**: Requires `verifyToken`.\n\n#### Get All Registrations\n\n- **GET** `/registrations`\n- **Description**: Retrieves all registrations.\n- **Authorization**: Requires `verifyToken` and `verifyAdmin`.\n\n#### Get Registrations by Email\n\n- **GET** `/registration/:email`\n- **Description**: Retrieves all registrations for a specific user.\n- **Authorization**: Requires `verifyToken`.\n\n#### Get Registration by ID\n\n- **GET** `/registration/pay/:id`\n- **Description**: Retrieves a specific registration by ID.\n- **Authorization**: Requires `verifyToken`.\n\n#### Update Registration Status\n\n- **PATCH** `/registration/:id`\n- **Description**: Updates the status of a registration.\n- **Authorization**: Requires `verifyToken` and `verifyAdmin`.\n\n#### Delete Registration\n\n- **DELETE** `/registration/:id`\n- **Description**: Deletes a registration by ID.\n- **Authorization**: Requires `verifyToken`.\n\n---\n\n### **Payments**\n\n#### Create Payment Intent\n\n- **POST** `/payment-intent`\n- **Description**: Creates a payment intent for Stripe.\n- **Authorization**: Requires `verifyToken`.\n\n#### Save Payment\n\n- **POST** `/payments`\n- **Description**: Saves payment details and updates registration payment status.\n- **Authorization**: Requires `verifyToken`.\n\n#### Get Payment History\n\n- **GET** `/payments/:email`\n- **Description**: Retrieves payment history for a user.\n- **Authorization**: Requires `verifyToken`.\n\n---\n\n### **Reviews**\n\n#### Add Review\n\n- **POST** `/review`\n- **Description**: Adds a review.\n- **Authorization**: Requires `verifyToken`.\n\n#### Get Reviews\n\n- **GET** `/reviews`\n- **Description**: Retrieves all reviews.\n\n---\n\n### **Analytics**\n\n#### User Stats\n\n- **GET** `/user-stats/:email`\n- **Description**: Retrieves statistics for a user (e.g., total camps, total spent).\n\n---\n\n### **Email**\n\n#### Send Email\n\n- **POST** `/email`\n- **Description**: Sends an email using Nodemailer.\n- **Request Body**:\n  ```json\n  {\n    \"name\": \"John Doe\",\n    \"email\": \"john@example.com\",\n    \"message\": \"Hello, I have a question.\"\n  }\n  ```\n\n---\n\n### Root\n\n#### Welcome Message\n\n- **GET** `/`\n- **Description**: Returns a welcome message for the server.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsabuj-chowdhury%2Fcampflow_server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsabuj-chowdhury%2Fcampflow_server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsabuj-chowdhury%2Fcampflow_server/lists"}