{"id":15174030,"url":"https://github.com/erfanium/sweet-fastify","last_synced_at":"2025-10-01T10:31:46.878Z","repository":{"id":57376037,"uuid":"310948343","full_name":"erfanium/sweet-fastify","owner":"erfanium","description":"To create clean and beautiful fastify routes ","archived":true,"fork":false,"pushed_at":"2021-02-15T05:36:46.000Z","size":15,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-10-19T22:15:02.266Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/erfanium.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":"2020-11-07T23:10:28.000Z","updated_at":"2024-04-21T13:13:43.000Z","dependencies_parsed_at":"2022-09-02T19:32:01.976Z","dependency_job_id":null,"html_url":"https://github.com/erfanium/sweet-fastify","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erfanium%2Fsweet-fastify","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erfanium%2Fsweet-fastify/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erfanium%2Fsweet-fastify/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erfanium%2Fsweet-fastify/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/erfanium","download_url":"https://codeload.github.com/erfanium/sweet-fastify/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234858938,"owners_count":18897842,"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-09-27T11:23:03.477Z","updated_at":"2025-10-01T10:31:46.497Z","avatar_url":"https://github.com/erfanium.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# sweet-fastify\n\nBuild HTTP API much faster, cleaner and safer without losing performance\n\n- There's no separated `req.query`, `req.params` or `req.body` objects, all of them merged into single object called  `params`\n- Validator schema checker via typescript for extra safely\n- Clean and safe authentication middleware handler\n\n## Examples\n\nThese examples are used in production by me!\n\n### Basic route\n\n```ts\ninterface Request {\n   phone: string\n}\ninterface Response {\n   digits: number\n   code?: string\n   exp: number\n   next: 'login' | 'register'\n}\n\nconst logger = new Logger('Code')\n\nconst mock = true\n\nexport const code = sweet({\n   method: 'POST',\n   url: '/users/code',\n   params: {\n      phone: 'phone',\n   },\n   async handler(params: Request): Promise\u003cResponse\u003e {\n      const user = await User.findOneByPhone(params.phone)\n      const otp = await OTP.generate(params.phone)\n\n      logger.info(params.phone, otp.code)\n      await sendOTP(params.phone, otp.code)\n      return {\n         digits: OTP.codeDigits,\n         code: mock ? otp.code : undefined,\n         exp: dateToUnixTimestamp(otp.expiredAt),\n         next: user ? 'login' : 'register',\n      }\n   },\n})\n```\n\n### With authentication\n\n```ts\ninterface Request {\n   name: string\n}\n\nexport const createBook = sweet({\n   method: 'POST',\n   url: '/books',\n   auth: users,\n   params: {\n      name: 'string|max:30',\n   },\n   async handler(params: Request, { userID }): Promise\u003cBook\u003e {\n      const book: Book = {\n         id: oidHex(),\n         v: oidHex(),\n         creator: userID,\n         deleted: false,\n         name: params.name,\n      }\n\n      await Book.repo.insert(book)\n\n      return book\n   },\n })\n ```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ferfanium%2Fsweet-fastify","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ferfanium%2Fsweet-fastify","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ferfanium%2Fsweet-fastify/lists"}