{"id":22105003,"url":"https://github.com/rahul-0000-code/rest_api","last_synced_at":"2025-03-24T02:44:10.803Z","repository":{"id":230038752,"uuid":"778305201","full_name":"rahul-0000-code/REST_API","owner":"rahul-0000-code","description":null,"archived":false,"fork":false,"pushed_at":"2024-03-27T13:31:30.000Z","size":24,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-29T08:44:31.765Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/rahul-0000-code.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":"2024-03-27T13:27:40.000Z","updated_at":"2024-03-27T13:28:33.000Z","dependencies_parsed_at":null,"dependency_job_id":"4f06fa4c-0896-48a0-a3f3-37f868617464","html_url":"https://github.com/rahul-0000-code/REST_API","commit_stats":null,"previous_names":["rahul-0000-code/rest_api"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rahul-0000-code%2FREST_API","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rahul-0000-code%2FREST_API/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rahul-0000-code%2FREST_API/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rahul-0000-code%2FREST_API/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rahul-0000-code","download_url":"https://codeload.github.com/rahul-0000-code/REST_API/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245200675,"owners_count":20576673,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":[],"created_at":"2024-12-01T06:37:24.784Z","updated_at":"2025-03-24T02:44:10.778Z","avatar_url":"https://github.com/rahul-0000-code.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# Online Restaurant Service REST API\n\nThis is a REST API for a hypothetical online restaurant service. It allows users to perform CRUD operations on products, place orders, and view orders.\n\n## Use Case\n\n1. **Create, Read, Update, Delete Product**: Users can perform CRUD operations on products. Each product has a name, price, and description.\n2. **Place Order for a Product**: Users can place orders for products, specifying the product and quantity.\n3. **List All Orders**: Users can view all orders placed.\n\n## Environment Variables\n\nTo run the server, create a `.env` file in the project directory with the following format:\n\n```\nMONGODB_URL=mongodb://localhost:27017/restaurant_db\nPORT=3000\nJWT_SECRET=your_secret_key\n```\n\n- `MONGODB_URL`: The URL of your MongoDB database.\n- `PORT`: The port number for the server to listen on.\n- `JWT_SECRET`: Secret key used for signing JWT tokens.\n\n## Running the Server\n\n1. Install dependencies:\n\n   ```bash\n   npm install\n   ```\n\n2. Start MongoDB server:\n\n   ```bash\n   mongod\n   ```\n\n3. Start the server:\n\n   ```bash\n   node server.js\n   ```\n\n## API Endpoints\n\n- **POST /register**: Register a new user.\n- **POST /login**: Login with username and password to get JWT token.\n- **POST /products**: Create a new product.\n- **GET /products**: Get all products.\n- **PUT /products/:id**: Update a product by ID.\n- **DELETE /products/:id**: Delete a product by ID.\n- **POST /orders**: Place a new order.\n- **GET /orders**: Get all orders.\n\n## Sample Requests\n\n- **Register User**:\n\n   ```bash\n   curl -X POST -H \"Content-Type: application/json\" -d '{\"username\":\"your_username\", \"password\":\"your_password\"}' http://localhost:3000/register\n   ```\n\n- **Login**:\n\n   ```bash\n   curl -X POST -H \"Content-Type: application/json\" -d '{\"username\":\"your_username\", \"password\":\"your_password\"}' http://localhost:3000/login\n   ```\n\n- **Create Product**:\n\n   ```bash\n   curl -X POST -H \"Authorization: Bearer \u003cyour_token\u003e\" -H \"Content-Type: application/json\" -d '{\"name\":\"Product Name\", \"price\":10, \"description\":\"Product Description\"}' http://localhost:3000/products\n   ```\n\n- **List Products**:\n\n   ```bash\n   curl http://localhost:3000/products\n   ```\n\n- **Place Order**:\n\n   ```bash\n   curl -X POST -H \"Authorization: Bearer \u003cyour_token\u003e\" -H \"Content-Type: application/json\" -d '{\"product\":\"\u003cproduct_id\u003e\", \"quantity\":1}' http://localhost:3000/orders\n   ```\n\n- **List Orders**:\n\n   ```bash\n   curl -H \"Authorization: Bearer \u003cyour_token\u003e\" http://localhost:3000/orders\n   ```\n\nReplace `\u003cyour_username\u003e`, `\u003cyour_password\u003e`, `\u003cyour_token\u003e`, and `\u003cproduct_id\u003e` with appropriate values.\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frahul-0000-code%2Frest_api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frahul-0000-code%2Frest_api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frahul-0000-code%2Frest_api/lists"}