{"id":19222907,"url":"https://github.com/christianjtr/express-api-mongodb-docker-jest-supertest","last_synced_at":"2026-04-07T07:43:22.286Z","repository":{"id":220549202,"uuid":"751934815","full_name":"christianjtr/express-api-mongodb-docker-jest-supertest","owner":"christianjtr","description":"API RESTFul implementation to put into practice concepts like dockerization, e2e tests, swagger documentation, and others.","archived":false,"fork":false,"pushed_at":"2024-02-02T16:48:42.000Z","size":248,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-01-03T14:35:06.096Z","etag":null,"topics":["api-rest","docker","docker-compose","e2e","e2e-tests","express","expressjs","javascript","jest","jest-tests","mongodb","mongoose","node","nodejs","openapi","rest-api","supertest","swagger","swagger-ui"],"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/christianjtr.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}},"created_at":"2024-02-02T16:42:44.000Z","updated_at":"2024-03-22T22:15:16.000Z","dependencies_parsed_at":"2024-02-02T17:57:49.616Z","dependency_job_id":null,"html_url":"https://github.com/christianjtr/express-api-mongodb-docker-jest-supertest","commit_stats":null,"previous_names":["christianjtr/express-api-mongodb-docker-jest-supertest"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/christianjtr/express-api-mongodb-docker-jest-supertest","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/christianjtr%2Fexpress-api-mongodb-docker-jest-supertest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/christianjtr%2Fexpress-api-mongodb-docker-jest-supertest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/christianjtr%2Fexpress-api-mongodb-docker-jest-supertest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/christianjtr%2Fexpress-api-mongodb-docker-jest-supertest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/christianjtr","download_url":"https://codeload.github.com/christianjtr/express-api-mongodb-docker-jest-supertest/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/christianjtr%2Fexpress-api-mongodb-docker-jest-supertest/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31504897,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-07T03:10:19.677Z","status":"ssl_error","status_checked_at":"2026-04-07T03:10:13.982Z","response_time":105,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: 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":["api-rest","docker","docker-compose","e2e","e2e-tests","express","expressjs","javascript","jest","jest-tests","mongodb","mongoose","node","nodejs","openapi","rest-api","supertest","swagger","swagger-ui"],"created_at":"2024-11-09T15:05:51.119Z","updated_at":"2026-04-07T07:43:22.271Z","avatar_url":"https://github.com/christianjtr.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# JS API RESTFul test\n\nThis is a conceptual test that puts into practice the following core technologies:\n\n- [ExpressJS](https://expressjs.com/)\n- [MongoDB](https://www.mongodb.com/)\n- [Docker](https://www.docker.com/)\n\n\n### 🎯 Goals\n\n- Build an API RESTFul based on the JS ecosystem following the given statements.\n- Document the API.\n- Dockerize the implementation.\n- Add some **integration test** to check if everything is ok.\n\n### 💡 Suggestions you may dig in\n\n- Adopt TypeScript.\n- Add unit tests.\n- Protect routes (Authorization and Authentication).\n- Prepare the implementation to be deployed.\n- Adopt an event-driven approach or caching strategy.\n\n## Assestment\n\nWrite an API that will be queried by two services: **X and Y services**.\n\nThe **X service** will need to keep in sync with the list of Couriers in the platform and their max capacity (in liters).\n\n````javascript\ncurl -X POST http://localhost:3000/couriers --data '\n{\n    \"max_capacity\": 45\n}'\n````\n\nThe **Y service** will need to query this API to determine which couriers have available space.\n\n````javascript\ncurl -X GET http://localhost:3000/couriers/lookup --data '\n{\n    \"capacity_required\": 45\n}'\n````\n\nWrite the API that will allow adding, removing, and updating couriers' capacities, and that will let lookup a list of couriers whose capacity is greater or equal to the one required.\n\n## How to run the project\n\nThe project requires [Node.js](https://nodejs.org/), [MongoDB](https://www.mongodb.com/), and [Docker](https://www.docker.com/) to run.\n\nClone the repository:\n\n```shell\ngit clone https://github.com/christianjtr/express-api-mongodb-docker-jest-supertest.git\n```\n\nEnvironment variables:\n\n| Env. Var. | Value  |\n|-------|--------|\n| `NODE_ENV` | `development` or `test` |\n| `SERVER_PORT` | `3001` |\n| `API_VERSION` | `v1` |\n| `SEED_MOCKED_DATA` | `true` or `false` |\n| `MONGODB_HOST` | `localhost` |\n| `MONGODB_PORT` | `27017` |\n| `MONGODB_DB` | `\u003cYOUR_DATABASE_NAME\u003e` |\n\n\u003e You can modify the variables by your preferences at ***.env*** and ***.env.test*** files\n\n###### Start the application\n\nInitialize `Docker`, pull down the images, create, and build the containers.\n\n```shell\nnpm run app:start\n```\n\n###### Stop the application\n\nShut down the application.\n\n```shell\nnpm run app:stop\n```\n\n###### Start server application (Non-dockerized version)\n\nTo run the application without using `Docker`, you will need to install **MongoDB Community Version: 4.4** in your OS System.\n\n```shell\nnpm run server:start\n```\n\n###### Run test suites\n\nThere are two simple **integration tests** as an example.\n\n```shell\nnpm test\n```\n\u003e [!IMPORTANT]  \n\u003e Technologies:\n\u003e - [Jest](https://jestjs.io/)\n\u003e - [Supertest](https://www.npmjs.com/package/supertest)\n\u003e - [MongoDB Memory Server](https://www.npmjs.com/package/mongodb-memory-server)\n\n\n## API Endpoints\n\nDocumentation was generated using [Swagger](https://swagger.io/) along with a `.yml` file having the API specs.\n\n###### Parameters:\n\n\u003e Noticed that you can change these parameters in **.env** files\n\n| Param | Value  |\n|-------|--------|\n| `host` | `localhost` |\n| `port` | `3001` |\n| `version` | `v1` |\n\n\n###### Base URI:\n\n````javascript\nBaseURI: http://localhost:3001/api/v1/{resource}\n````\n\n#### API Docs\n\nSwagger API Docs\n\n````javascript\nURI: {BaseURI}/docs\n````\n\n![](./assets/swagger_specs_demo.png)\n\n#### Health checks\n###### Example cURL\n\n```javascript\n$ curl --location 'http://localhost:3001/api/v1/health-checks/alive'\n```\n\n#### Couriers\n\nBasic CRUD operations\n\n````javascript\nURI: {BaseURI}/couriers\n````\n\n##### Get all couriers\n###### Example cURL\n```javascript\n$ curl --location 'http://localhost:3001/api/v1/couriers'\n```\n\n##### Get courier by ID\n###### Example cURL\n```javascript\n$ curl --location 'http://localhost:3001/api/v1/couriers/65b93d111efb464a86c6d109'\n```\n\n##### Create courier\n###### Example cURL\n```javascript\n$ curl --location 'http://localhost:3001/api/v1/couriers' \\\n--header 'Content-Type: application/json' \\\n--data '{\n    \"max_capacity\": 100\n}'\n```\n\n##### Update courier by ID\n###### Example cURL\n```javascript\n$ curl --location --request PUT 'http://localhost:3001/api/v1/couriers/65b93d4e1afd3c4aab06a8d5' \\\n--header 'Content-Type: application/json' \\\n--data '{\n    \"max_capacity\": 50\n}'\n```\n\n##### Delete courier by ID\n###### Example cURL\n```javascript\n$ curl --location --request DELETE 'http://localhost:3001/api/v1/couriers/65b93d92d1f6ff4ad25961c6'\n```\n\n#### Courier actions\n\n````javascript\nURI: {BaseURI}/couriers/lookup/:capacity_required\n````\n\n##### Lookup\nRequest data from this API to determine which couriers have available space. (Greater or equals to the requested capacity)\n###### Example cURL\n```javascript\n$ curl --location 'http://localhost:3001/api/v1/couriers/lookup/700'\n```\n\n## Technologies\n\nExpressJS, MongoDB, Docker, Jest, SupertTest.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchristianjtr%2Fexpress-api-mongodb-docker-jest-supertest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchristianjtr%2Fexpress-api-mongodb-docker-jest-supertest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchristianjtr%2Fexpress-api-mongodb-docker-jest-supertest/lists"}