{"id":13576919,"url":"https://github.com/matthewp/astro-fastify","last_synced_at":"2025-04-13T21:12:10.945Z","repository":{"id":59145065,"uuid":"532026417","full_name":"matthewp/astro-fastify","owner":"matthewp","description":"A Fastify adapter for Astro","archived":false,"fork":false,"pushed_at":"2024-03-02T17:41:12.000Z","size":287,"stargazers_count":58,"open_issues_count":6,"forks_count":15,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-05-18T14:42:42.237Z","etag":null,"topics":["astro","fastify"],"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/matthewp.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}},"created_at":"2022-09-02T17:49:58.000Z","updated_at":"2024-05-30T05:09:58.154Z","dependencies_parsed_at":"2024-01-03T13:47:30.351Z","dependency_job_id":"cdc6e5e1-af62-47c7-b959-d4b651146dc6","html_url":"https://github.com/matthewp/astro-fastify","commit_stats":{"total_commits":51,"total_committers":3,"mean_commits":17.0,"dds":"0.21568627450980393","last_synced_commit":"b470dbb920c135af3df4c4ca522eae49fb24c2e0"},"previous_names":[],"tags_count":24,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matthewp%2Fastro-fastify","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matthewp%2Fastro-fastify/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matthewp%2Fastro-fastify/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matthewp%2Fastro-fastify/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/matthewp","download_url":"https://codeload.github.com/matthewp/astro-fastify/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248782260,"owners_count":21160717,"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":["astro","fastify"],"created_at":"2024-08-01T15:01:15.856Z","updated_at":"2025-04-13T21:12:10.911Z","avatar_url":"https://github.com/matthewp.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"![npm version number](https://img.shields.io/npm/v/@matthewp/astro-fastify)\n\n# @matthewp/astro-fastify\n\nAn [fastify](https://www.fastify.io/) adapter to use in [Astro](https://astro.build/) projects. __@matthewp/astro-fastify__ allows you to use fastify and Astro side-by-side, and deploy your apps to Node.js powered by a battle-tested HTTP server.\n\nUnlike most adapters, __@matthewp/astro-fastify__ also works in *dev mode*.\n\n## install\n\n__@matthewp/astro-fastify__ is needed in production so use `--save`.\n\n```shell\nnpm install @matthewp/astro-fastify --save\n```\n\n## Usage\n\n__@matthewp/astro-fastify__ is used like any other adapter for Astro. Import and use it in your __astro.config.mjs__ file:\n\n```js\nimport fastify from '@matthewp/astro-fastify';\n\n/** @type {import('astro').AstroUserConfig} */\nexport default {\n  output: 'server',\n  adapter: fastify({\n    entry: new URL('./api/index.ts', import.meta.url)\n  })\n};\n```\n\n### Options\n\n#### entry\n\nSpecifies the entry point to define fastify routes and plugins. This module must export a default function that takes in the Fastify instance, where you can define routes and registry plugins.\n\n__api/index.ts__\n\n```js\nimport type { DefineFastifyRoutes } from '@matthewp/astro-fastify';\n\nconst defineRoutes: DefineFastifyRoutes = (fastify) =\u003e {\n  fastify.get('/api/todos', function(request, reply) {\n    reply.send({\n      todos: [\n        { label: 'eat lunch' },\n        { label: 'exercise' },\n        { label: 'walk the dog' }\n      ]\n    });\n  })\n};\n\nexport default defineRoutes;\n```\n\n#### port\n\nSpecifies the port to use in production. Most hosts will set `process.env.PORT` and that will be used, so setting this option is unnecessary. If you do set *port* it will override host-specific config.\n\nIn development mode this option has no effect, as fastify runs on the same server as Astro.\n\n#### logger\n\nSpecifies the Fastify logging options. See the [Fastify docs](https://www.fastify.io/docs/latest/Reference/Logging/) to see the options. Note that these options are built into the production bundle, so options such as `logger.stream` do not work.\n\n### Note on route priority\n\nFastify runs in front of Astro's own routing, which means that any routes you define in fastify take priority over routes defined in Astro. So if, for example, you have conflicting routes the Astro route will never be hit.\n\n### Production usage\n\n__@matthewp/astro-fastify__ automatically configures Astro to build your fastify routes into your production build. Run your build as normal:\n\n```shell\nastro build\n```\n\nOr if you have an npm script:\n\n```shell\nnpm run build\n```\n\nWhich will create an entrypoint for your server, by default `dist/server/entry.mjs`. Running this file in Node.js automatically starts the fastify server:\n\n```shell\nnode dist/server/entry.mjs\n```\n\nConfigure your host to run this script. Assets and JavaScript are output to `dist/client/assets/`. You can configure your CDN to serve these files more efficiently and with long-lived cache headers.\n\n## License\n\nBSD-2-Clause\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatthewp%2Fastro-fastify","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmatthewp%2Fastro-fastify","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatthewp%2Fastro-fastify/lists"}