{"id":28223130,"url":"https://github.com/luizcurti/node-rest-graphql-api","last_synced_at":"2026-04-29T01:02:34.622Z","repository":{"id":294711728,"uuid":"974327513","full_name":"luizcurti/node-rest-graphql-api","owner":"luizcurti","description":"Node.js API with REST and GraphQL Endpoints","archived":false,"fork":false,"pushed_at":"2026-04-01T13:47:56.000Z","size":131,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-04-01T15:30:49.464Z","etag":null,"topics":["docker-compose","eslint","graphql","javascript","jest","mongodb","nodejs","rest-api","testing","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/luizcurti.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-04-28T15:51:29.000Z","updated_at":"2026-04-01T13:48:00.000Z","dependencies_parsed_at":"2025-05-21T18:37:14.385Z","dependency_job_id":null,"html_url":"https://github.com/luizcurti/node-rest-graphql-api","commit_stats":null,"previous_names":["luizcurti/node-rest-graphql-api"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/luizcurti/node-rest-graphql-api","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luizcurti%2Fnode-rest-graphql-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luizcurti%2Fnode-rest-graphql-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luizcurti%2Fnode-rest-graphql-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luizcurti%2Fnode-rest-graphql-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/luizcurti","download_url":"https://codeload.github.com/luizcurti/node-rest-graphql-api/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luizcurti%2Fnode-rest-graphql-api/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32405904,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-28T19:38:08.556Z","status":"ssl_error","status_checked_at":"2026-04-28T19:37:55.688Z","response_time":56,"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":["docker-compose","eslint","graphql","javascript","jest","mongodb","nodejs","rest-api","testing","typescript"],"created_at":"2025-05-18T07:14:50.490Z","updated_at":"2026-04-29T01:02:34.617Z","avatar_url":"https://github.com/luizcurti.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Node.js REST + GraphQL API\n\nA Node.js backend API that exposes both a REST and a GraphQL interface for managing **Users** and **Posts**. Built with Express, Mongoose, and TypeScript, following a modular architecture with one file per use case.\n\n## Tech Stack\n\n- **Node.js** + **Express** + **TypeScript**\n- **MongoDB** + **Mongoose** — data storage\n- **GraphQL** via `express-graphql` + `@graphql-tools/schema`\n- **Jest** + **ts-jest** — unit and E2E testing\n- **Supertest** — HTTP testing\n- **mongodb-memory-server** — in-memory MongoDB for fast tests\n- **Docker Compose** — real MongoDB for E2E tests\n- **ESLint** (airbnb-base) — code linting\n\n## Prerequisites\n\n- Node.js \u003e= 18.0.0\n- Docker (for E2E tests against a real MongoDB instance)\n\n## Installation\n\n1. Clone the repository:\n```bash\ngit clone https://github.com/luizcurti/node-rest-graphql-api.git\ncd node-rest-graphql-api\n```\n\n2. Install dependencies:\n```bash\nnpm install\n```\n\n3. Start the development server:\n```bash\nnpm run dev\n```\n\nThe server starts at **http://localhost:4003**.\n\n## REST API Endpoints\n\n### Users\n\n| Method | Route | Description |\n|--------|-------|-------------|\n| `POST` | `/users` | Create a user |\n| `GET` | `/users` | List all users |\n| `GET` | `/users/:id` | Get user by ID |\n| `PUT` | `/users/:id` | Update a user |\n| `DELETE` | `/users/:id` | Delete a user |\n\n### Posts\n\n| Method | Route | Description |\n|--------|-------|-------------|\n| `POST` | `/posts` | Create a post |\n| `GET` | `/posts` | List all posts |\n| `GET` | `/posts/:id` | Get post by ID |\n| `GET` | `/posts/user/:id` | Get all posts by a user |\n| `PUT` | `/posts/:id` | Update a post |\n| `DELETE` | `/posts/:id` | Delete a post |\n\n## GraphQL API\n\nThe GraphQL endpoint is available at **http://localhost:4003/graphql**.\n\n### Queries\n- `getAllUsers` — list all users\n- `getUserById(id)` — get user by ID\n- `getAllPosts` — list all posts\n- `getPostById(id)` — get post by ID\n- `getPostsByUser(idUser)` — get all posts by a user\n\n### Mutations\n- `createUser(input)` — create a user\n- `updateUser(id, input)` — update a user\n- `deleteUser(id)` — delete a user\n- `createPost(input)` — create a post\n- `updatePost(id, input)` — update a post\n- `deletePost(id)` — delete a post\n\n## Postman Collections\n\nTwo Postman collections are available at the root of the project. Import either into Postman to get pre-configured requests:\n\n- `REST API.postman_collection.json` — all 11 REST endpoints\n- `graphql_api.postman_collection.json` — all GraphQL queries and mutations\n\n## Running Tests\n\n### Unit tests + in-memory E2E tests\n```bash\nnpm test\n```\nRuns 26 test suites, 162 tests.\n\n### E2E tests with real Docker MongoDB\n```bash\nnpm run test:e2e\n```\nSpins up the MongoDB Docker container defined in `docker-compose.yml`, runs 4 test suites (96 tests) against a real database, then tears down the test database.\n\n### Lint\n```bash\nnpm run eslint\n```\n\n## Build\n\n```bash\nnpm run build   # compiles TypeScript to dist/\nnpm start       # runs the compiled output\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluizcurti%2Fnode-rest-graphql-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fluizcurti%2Fnode-rest-graphql-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluizcurti%2Fnode-rest-graphql-api/lists"}