{"id":22477391,"url":"https://github.com/atomic-state/next-rest-controller","last_synced_at":"2025-10-29T16:35:52.067Z","repository":{"id":37883370,"uuid":"503570831","full_name":"atomic-state/next-rest-controller","owner":"atomic-state","description":"A REST helper for Next.js APIs","archived":false,"fork":false,"pushed_at":"2022-06-15T05:20:46.000Z","size":15,"stargazers_count":5,"open_issues_count":0,"forks_count":1,"subscribers_count":0,"default_branch":"main","last_synced_at":"2024-04-16T21:06:06.439Z","etag":null,"topics":["next-api","nextjs","rest-api","restful-next","serverless"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/atomic-state.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-06-15T01:12:08.000Z","updated_at":"2024-04-16T21:06:06.440Z","dependencies_parsed_at":"2022-07-14T02:10:33.044Z","dependency_job_id":null,"html_url":"https://github.com/atomic-state/next-rest-controller","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atomic-state%2Fnext-rest-controller","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atomic-state%2Fnext-rest-controller/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atomic-state%2Fnext-rest-controller/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atomic-state%2Fnext-rest-controller/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/atomic-state","download_url":"https://codeload.github.com/atomic-state/next-rest-controller/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228476045,"owners_count":17926134,"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":["next-api","nextjs","rest-api","restful-next","serverless"],"created_at":"2024-12-06T14:10:41.329Z","updated_at":"2025-10-29T16:35:52.009Z","avatar_url":"https://github.com/atomic-state.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## REST controller for Next.js\r\n\r\n#### How does it work?\r\n\r\nCreate restful controllers in Next.js\r\n\r\n#### Example:\r\n\r\nInside `/pages/api/auth/[...handler]`\r\n\r\n(filename must be a rest operator if you want customized URLs, but you can also use normal api handlers filenames, though they have to share the same URL in your controller)\r\n\r\n```ts\r\n// inside /pages/api/auth/[...handler]\r\n\r\nimport { Controller } from \"next-rest-controller\"\r\n\r\n// The first argument is the 'base' segment that will be used to map the correct url.\r\nconst AuthHandler = Controller(\"/auth\", {\r\n    async \"GET /auth\"(req, res) {\r\n        res.status(401)\r\n        res.send(\"Forbidden\")\r\n    },\r\n    async \"GET /[id]/info\"(req, res) {\r\n        res.send(\"Info for \" + req.query.id)\r\n    },\r\n    // Like Express\r\n    async \"GET /:id/info/:slug\"(req, res) {\r\n        res.send(\"Info for \" + req.query.id)\r\n    }\r\n})\r\n```\r\n\r\n#### Explanation\r\nWhen adding a handler/method, it should start with an HTTP verb, followed by a space, and a url to handle (with or without query params using square brackets, or like Express, by placing `:` before).\r\n\r\nSending, for example, a POST request that would be handled by a GET handler, will send a `405` status code","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fatomic-state%2Fnext-rest-controller","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fatomic-state%2Fnext-rest-controller","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fatomic-state%2Fnext-rest-controller/lists"}