{"id":18519512,"url":"https://github.com/typeofweb-org/server","last_synced_at":"2025-04-09T08:32:18.226Z","repository":{"id":48640520,"uuid":"375415297","full_name":"typeofweb-org/server","owner":"typeofweb-org","description":"100% typesafe wrapper around Express.js","archived":false,"fork":false,"pushed_at":"2021-10-07T13:06:18.000Z","size":844,"stargazers_count":13,"open_issues_count":3,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-10-16T08:08:02.939Z","etag":null,"topics":["express","hacktoberfest","nodejs","typescript"],"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/typeofweb-org.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":["typeofweb"],"patreon":null,"open_collective":"typeofweb","ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2021-06-09T16:07:20.000Z","updated_at":"2022-08-26T15:36:03.000Z","dependencies_parsed_at":"2022-09-26T20:11:08.707Z","dependency_job_id":null,"html_url":"https://github.com/typeofweb-org/server","commit_stats":null,"previous_names":["typeofweb-org/server","typeofweb/server"],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/typeofweb-org%2Fserver","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/typeofweb-org%2Fserver/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/typeofweb-org%2Fserver/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/typeofweb-org%2Fserver/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/typeofweb-org","download_url":"https://codeload.github.com/typeofweb-org/server/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247500455,"owners_count":20948878,"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":["express","hacktoberfest","nodejs","typescript"],"created_at":"2024-11-06T17:16:36.302Z","updated_at":"2025-04-09T08:32:17.732Z","avatar_url":"https://github.com/typeofweb-org.png","language":"TypeScript","funding_links":["https://github.com/sponsors/typeofweb","https://opencollective.com/typeofweb","https://github.com/sponsors/typeofweb)!"],"categories":[],"sub_categories":[],"readme":"# @typeofweb/server\n\n\u003c!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section --\u003e\n[![All Contributors](https://img.shields.io/badge/all_contributors-1-orange.svg?style=flat-square)](#contributors-)\n\u003c!-- ALL-CONTRIBUTORS-BADGE:END --\u003e\n\n[![codecov](https://codecov.io/gh/typeofweb/server/branch/main/graph/badge.svg?token=X1Z8BQ0TFG)](https://codecov.io/gh/typeofweb/server)\n[![npm](https://img.shields.io/npm/v/@typeofweb/server.svg)](https://www.npmjs.com/package/@typeofweb/server)\n\n## Docs\n\n## Sponsors\n\n\u0026lt;your name here\u003e\n\nSee [opencollective.com/typeofweb](https://opencollective.com/typeofweb) or [github.com/sponsors/typeofweb](https://github.com/sponsors/typeofweb)! ❤️\n\n\u003csvg class=\"octicon octicon-heart text-pink\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath fill-rule=\"evenodd\" d=\"M4.25 2.5c-1.336 0-2.75 1.164-2.75 3 0 2.15 1.58 4.144 3.365 5.682A20.565 20.565 0 008 13.393a20.561 20.561 0 003.135-2.211C12.92 9.644 14.5 7.65 14.5 5.5c0-1.836-1.414-3-2.75-3-1.373 0-2.609.986-3.029 2.456a.75.75 0 01-1.442 0C6.859 3.486 5.623 2.5 4.25 2.5zM8 14.25l-.345.666-.002-.001-.006-.003-.018-.01a7.643 7.643 0 01-.31-.17 22.075 22.075 0 01-3.434-2.414C2.045 10.731 0 8.35 0 5.5 0 2.836 2.086 1 4.25 1 5.797 1 7.153 1.802 8 3.02 8.847 1.802 10.203 1 11.75 1 13.914 1 16 2.836 16 5.5c0 2.85-2.045 5.231-3.885 6.818a22.08 22.08 0 01-3.744 2.584l-.018.01-.006.003h-.002L8 14.25zm0 0l.345.666a.752.752 0 01-.69 0L8 14.25z\"\u003e\u003c/path\u003e\u003c/svg\u003e\n\n## Contributors ✨\n\nThanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):\n\n\u003c!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section --\u003e\n\u003c!-- prettier-ignore-start --\u003e\n\u003c!-- markdownlint-disable --\u003e\n\u003ctable\u003e\n  \u003ctr\u003e\n    \u003ctd align=\"center\"\u003e\u003ca href=\"https://github.com/wisnie\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/47081011?v=4?s=100\" width=\"100px;\" alt=\"\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eBartłomiej Wiśniewski\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/typeofweb/server/commits?author=wisnie\" title=\"Code\"\u003e💻\u003c/a\u003e\u003c/td\u003e\n  \u003c/tr\u003e\n\u003c/table\u003e\n\n\u003c!-- markdownlint-restore --\u003e\n\u003c!-- prettier-ignore-end --\u003e\n\n\u003c!-- ALL-CONTRIBUTORS-LIST:END --\u003e\n\nThis project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!\n\n## Example\n\n```ts\nimport { createApp } from '@typeofweb/server';\n\nimport { dbPlugin } from './dbPlugin';\nimport { authPlugin } from './authPlugin';\n\nconst app = await createApp({\n  host: 'localhost',\n  port: 3000,\n});\n\napp.plugin(dbPlugin);\napp.plugin(authPlugin);\n\napp.route({\n  path: '/health-check/:count',\n  method: 'GET',\n  validation: {\n    query: {},\n    params: {\n      count: number(),\n    },\n    payload: {},\n    response: {},\n  },\n  async handler(request) {\n    if (!request.plugins.auth.session) {\n      throw new HttpError(HttpStatusCode.Unauthorized);\n    }\n\n    const { params } = request;\n    const result = await request.server.plugins.db.user.findOne(params.count);\n\n    request.events.emit('found', result);\n\n    return result;\n  },\n});\n\nconst server = await app.listen();\n```\n\n```ts\n// dbPlugin.ts\n\nimport { createPlugin } from '@typeofweb/server';\n\ndeclare module '@typeofweb/server' {\n  interface TypeOfWebServerMeta {\n    readonly db: PrismaClient;\n  }\n\n  interface TypeOfWebRequestMeta {\n    readonly auth: { readonly session: Session };\n  }\n\n  interface TypeOfWebServerEvents {\n    readonly found: User;\n  }\n}\n\nexport const dbPlugin = createPlugin('db', async (app) =\u003e {\n  return {\n    server: new Prisma(),\n  };\n});\n```\n\n```ts\n// authPlugin.ts\n\nimport { createPlugin } from '@typeofweb/server';\n\nexport const authPlugin = createPlugin('auth', async (app) =\u003e {\n  return {\n    request(request) {\n      const session = await request.plugins.db.session.findOne({ id: request.cookies.session });\n      return { session };\n    },\n  };\n});\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftypeofweb-org%2Fserver","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftypeofweb-org%2Fserver","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftypeofweb-org%2Fserver/lists"}