{"id":19092763,"url":"https://github.com/basedhound/crud-test-1_api","last_synced_at":"2026-04-09T21:02:11.232Z","repository":{"id":53880681,"uuid":"521782980","full_name":"basedhound/crud-test-1_api","owner":"basedhound","description":"Build a REST API with Node, Express, and MongoDB. This API should handle CRUD operations for managing products and be connected to a database. Successfully implementing it will reveal a secret word.","archived":false,"fork":false,"pushed_at":"2024-08-06T10:09:13.000Z","size":358,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-22T07:44:29.623Z","etag":null,"topics":["api","cors","crud","dotenv","express","mongodb","mongoose","node","nodejs"],"latest_commit_sha":null,"homepage":"","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/basedhound.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":"2022-08-05T21:43:02.000Z","updated_at":"2024-08-06T10:09:19.000Z","dependencies_parsed_at":"2024-07-22T11:56:44.994Z","dependency_job_id":"71022b0e-104b-4ace-93f9-a2dc46f6f9b3","html_url":"https://github.com/basedhound/crud-test-1_api","commit_stats":null,"previous_names":["basedhound/api_crud-test","basedhound/crud-test-1_api"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/basedhound/crud-test-1_api","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/basedhound%2Fcrud-test-1_api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/basedhound%2Fcrud-test-1_api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/basedhound%2Fcrud-test-1_api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/basedhound%2Fcrud-test-1_api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/basedhound","download_url":"https://codeload.github.com/basedhound/crud-test-1_api/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/basedhound%2Fcrud-test-1_api/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":283937314,"owners_count":26919456,"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","status":"online","status_checked_at":"2025-11-11T02:00:06.610Z","response_time":65,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["api","cors","crud","dotenv","express","mongodb","mongoose","node","nodejs"],"created_at":"2024-11-09T03:21:48.314Z","updated_at":"2025-11-11T21:33:12.652Z","avatar_url":"https://github.com/basedhound.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n    \u003c!-- \u003ca href=\"\" target=\"_blank\"\u003e\n      \u003cimg src=\"\" alt=\"Project Banner\"\u003e\n    \u003c/a\u003e --\u003e\n  \u003ch3 align=\"center\"\u003eCRUD Operations #1\u003c/h3\u003e\n  \u003ch4 align=\"center\"\u003eSchool Exercise\u003c/h4\u003e\n\u003c/div\u003e\n\n## \u003cbr /\u003e 📋 \u003ca name=\"table\"\u003eTable of Contents\u003c/a\u003e\n\n- ✨ [Introduction](#introduction)\n- ⚙️ [Tech Stack](#tech-stack)\n- 📝 [Features](#features)\n- 🚀 [Quick Start](#quick-start)\n\n## \u003cbr /\u003e \u003ca name=\"introduction\"\u003e✨ Introduction\u003c/a\u003e\n\n**[FR]** Ce projet est un quiz conçu pour tester vos compétences en créant une API REST avec Node, Express et MongoDB. Lorsque tout fonctionnera correctement, l'application de test affichera un mot secret. Quel est ce mot secret ? Pour répondre correctement, vous devez créer une API fonctionnelle comme démontré pendant le cours. Votre API doit être connectée à une base de données, car diverses opérations CRUD seront testées et vérifiées. Vous allez créer une API basique pour une boutique en ligne qui permet de créer, lire, modifier et supprimer des produits.\n\n**[EN]** This project is a quiz designed to test your skills by creating a REST API with Node, Express, and MongoDB. When everything is working correctly, the test application will display a secret word. What is this secret word? To answer correctly, you need to create a functional API as demonstrated in the course. Your API must be connected to a database, as various CRUD operations will be tested and verified. You will create a basic API for an online store that allows you to create, read, update, and delete products. The products will have four required fields:\n\n- `name` : The name of the product, of type String.\n- `description` : The description of the product, of type String.\n- `price` : The price of the product, of type Number.\n- `inStock` : Whether the product is in stock, of type Boolean.\n\n### Required endpoints\n\nThe frontend app requires the following endpoints with the correct behavior for all tests to pass:\n\n- **GET** : `/api/products`\u003cbr\u003e\n  Returns all products as `{ products: Product[] }`\u003cbr\u003e \u003cbr\u003e\n\n- **GET** : `/api/products/:id`\u003cbr\u003e\n  Returns product for given ID as `{ product: Product }`\u003cbr\u003e \u003cbr\u003e\n\n* **POST** : `/api/products`\n  Request body contains:\n\n```js\n{\n  name: string,\n  description: string,\n  price: number,\n  inStock: boolean\n}\n```\n\nCreates product in database.\u003cbr\u003e\nReturns product created in database (including `_id` field) as `{ product: Product }`\u003cbr\u003e\u003cbr\u003e\n\n- **PUT** : `/api/products/:id`\n\nRequest body contains:\n\n```js\n{\n  name: string,\n  description: string,\n  price: number,\n  inStock: boolean\n}\n```\n\nModifies product with given ID as per object provided in request body.\n\nReturns `{ message: 'Modified!' }`\u003cbr\u003e\u003cbr\u003e\n\n- **DELETE** : `/api/products/:id`\n\nDeletes product with given ID.\n\nReturns `{ message: 'Deleted!' }` \u003cbr\u003e\u003cbr\u003e\n\n### Schema\n\n```js\nmongoose.Schema({\n  name: { type: String, required: true },\n  description: { type: String, required: true },\n  price: { type: Number, required: true },\n  inStock: { type: Boolean, required: true }\n})\n```\n\n\n\n## \u003cbr /\u003e \u003ca name=\"tech-stack\"\u003e⚙️ Tech Stack\u003c/a\u003e\n\n- [**REST API**](https://blog.postman.com/rest-api-examples/) (Representational State Transfer Application Programming Interface) is a specific type of API that adheres to the principles of REST, an architectural style for designing networked applications. REST APIs use standard HTTP methods (GET, POST, PUT, DELETE) to interact with resources, which are typically represented in JSON or XML format. REST APIs are stateless, meaning each request from a client to the server must contain all the information needed to understand and process the request. This approach simplifies the interactions between client and server and ensures scalability and performance.\n\n- [**Node.js**](https://nodejs.org/en/learn/getting-started/introduction-to-nodejs)  is a JavaScript runtime built on Chrome's V8 JavaScript engine. It allows developers to execute JavaScript on the server side, enabling the creation of scalable and high-performance applications. Node.js's non-blocking, event-driven architecture makes it particularly suitable for building real-time, data-intensive applications. \n\n- [**NPM**](https://nodejs.org/en/learn/getting-started/an-introduction-to-the-npm-package-manager)  (Node Package Manager) is the default package manager for Node.js. It allows developers to install, share, and manage dependencies in their projects. NPM provides access to a vast repository of open-source packages, facilitating the rapid development and integration of new features. \n\n- [**Express**](https://expressjs.com/en/starter/installing.html)  is a minimal and flexible Node.js web application framework that provides a robust set of features for building web and mobile applications. It simplifies the process of creating RESTful APIs by providing a thin layer of fundamental web application features, including routing, middleware support, and HTTP utilities.\n\n- [**MongoDB**](https://www.mongodb.com/docs/atlas/)  is a NoSQL database system known for its flexibility and scalability, ideal for handling large volumes of unstructured or semi-structured data. It stores data in JSON-like documents, making it easy to integrate with modern applications. MongoDB's features include powerful querying capabilities, automatic sharding for horizontal scaling, flexible data models, and support for distributed transactions in recent versions. \n\n- [**Mongoose**](https://mongoosejs.com/docs/)  is an Object Data Modeling (ODM) library for MongoDB and Node.js. It provides a schema-based solution to model application data, ensuring data consistency and providing powerful tools for querying and validation. Mongoose simplifies the process of interacting with MongoDB by providing a higher abstraction layer. \n\n- [**Dotenv**](https://www.npmjs.com/package/dotenv)  is a module that loads environment variables from a .env file into process.env. This practice helps manage configuration and secrets in Node.js applications, keeping them out of the source code and making it easier to change settings without modifying the application code. \n\n## \u003cbr/\u003e \u003ca name=\"features\"\u003e📝 Features\u003c/a\u003e\n\n👉 **CRUD Operations**: Implement full Create, Read, Update, and Delete functionality for managing products.\n\n👉 **Product Listing**: Retrieve all products with a single request.\n\n👉 **Product Details**: Fetch detailed information for a specific product using its _id.\n\n👉 **Product Creation**: Add new products to the database with required fields.\n\n👉 **Product Update**: Modify existing product details by _id.\n\n👉 **Product Deletion**: Remove products from the database by _id.\n\n👉 **Error Handling**: Proper handling of errors during database operations with meaningful responses.\n\n👉 **JSON Data Handling**: Use JSON format for request and response bodies to ensure consistency.\n\n\n\n## \u003cbr /\u003e \u003ca name=\"quick-start\"\u003e🚀 Quick Start\u003c/a\u003e\n\nFollow these steps to set up the project locally on your machine.\n\n\u003cbr/\u003e**Prerequisites**\n\nMake sure you have the following installed on your machine:\n\n- [Git](https://git-scm.com/)\n- [Node.js](https://nodejs.org/en)\n- [npm](https://www.npmjs.com/) (Node Package Manager)\n\nInstall nodemon globally on your machine, open your terminal and run the following command:\n```bash\nnpm install -g nodemon\n```\n\n- **Nodemon** is a tool that helps develop Node.js based applications by automatically restarting the node application when file changes in the directory are detected.\n\n\u003cbr/\u003e**Cloning the Repository**\n\n```bash\ngit clone {git remote URL}\n```\n\n\u003cbr/\u003e**Installation**\n\nLet's install the project dependencies for both the client and server, from your terminal, run:\n\n```bash\n# Navigate to the client directory\ncd client\n\n# Install the necessary dependencies for the client-side application\nnpm install\n# or\nyarn install\n\n# Navigate back to the root directory\ncd ..\n\n# Navigate to the server directory\ncd server\n\n# Install the necessary dependencies for the server-side application\nnpm install\n# or\nyarn install\n```\n\n\u003cbr/\u003e**Set Up Environment Variables**\n\nCreate a new file named .env inside the **server folder** and add the following content:\n\n```env\nDB_USERNAME=\nDB_PASSWORD=\nDB_CLUSTER=\nDATABASE=\n```\n\nReplace the placeholder values with your actual respective account credentials:\n- [MongoDB](https://cloud.mongodb.com)\n\n\n\u003cbr/\u003e**Running the Project**\n\nInstallation will take a minute or two, but once that's done, you should be able to run the following command:\n\n```bash\n# Navigate to the client directory\ncd client\n\n# Start client\n# If `npm start` doesn't work, try updating the dependencies in `package.json`.\nnpm start\n# or\nyarn start\n\n# Navigate back to the root directory\ncd ..\n\n# Navigate to the server directory\ncd server\n\n# Start server\nnpm start\n# or\nyarn start\n```\n\n- Client running on [`http://localhost:4200`](http://localhost:4200)\n- Server running on [`http://localhost:3000`](http://localhost:3000)\n\nChoose the port your API is running on, and click `TEST-ROUTES` to test your API. \u003cbr\u003e \u003cbr\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbasedhound%2Fcrud-test-1_api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbasedhound%2Fcrud-test-1_api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbasedhound%2Fcrud-test-1_api/lists"}