{"id":29603571,"url":"https://github.com/inyourtime/fastify-line","last_synced_at":"2026-01-20T17:28:28.294Z","repository":{"id":302473952,"uuid":"1011858124","full_name":"inyourtime/fastify-line","owner":"inyourtime","description":"A Fastify plugin for the LINE Messaging API","archived":false,"fork":false,"pushed_at":"2025-07-13T05:54:20.000Z","size":17,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-13T05:59:30.151Z","etag":null,"topics":["bot","fastify","fastify-plugin","line","line-bot","sdk"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/fastify-line","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/inyourtime.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-07-01T12:47:21.000Z","updated_at":"2025-07-13T05:54:22.000Z","dependencies_parsed_at":"2025-07-02T15:56:21.082Z","dependency_job_id":null,"html_url":"https://github.com/inyourtime/fastify-line","commit_stats":null,"previous_names":["inyourtime/fastify-line"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/inyourtime/fastify-line","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inyourtime%2Ffastify-line","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inyourtime%2Ffastify-line/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inyourtime%2Ffastify-line/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inyourtime%2Ffastify-line/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/inyourtime","download_url":"https://codeload.github.com/inyourtime/fastify-line/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inyourtime%2Ffastify-line/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266142165,"owners_count":23883038,"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":["bot","fastify","fastify-plugin","line","line-bot","sdk"],"created_at":"2025-07-20T14:37:58.303Z","updated_at":"2026-01-20T17:28:28.286Z","avatar_url":"https://github.com/inyourtime.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# fastify-line\n\n[![CI](https://github.com/inyourtime/fastify-line/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/inyourtime/fastify-line/actions/workflows/ci.yml)\n[![NPM version](https://img.shields.io/npm/v/fastify-line.svg?style=flat)](https://www.npmjs.com/package/fastify-line)\n[![Checked with Biome](https://img.shields.io/badge/Checked_with-Biome-60a5fa?style=flat\u0026logo=biome)](https://biomejs.dev)\n[![MIT License](https://img.shields.io/badge/license-MIT-blue.svg?style=flat)](./LICENSE)\n\nA Fastify plugin for seamless integration with the [LINE Messaging API](https://developers.line.biz/en/docs/messaging-api/overview/). It provides signature verification, raw body parsing, and exposes the official LINE Messaging API client on your Fastify instance.\n\n---\n\n## Features\n\n- Signature verification for LINE webhooks\n- Raw body parsing for webhook requests\n- Exposes the official `@line/bot-sdk` Messaging API client as `fastify.line`\n- Easy route integration with Fastify\n\n## Installation\n\n```bash\nnpm install fastify-line @line/bot-sdk\n```\n\n\u003e **Note:** `@line/bot-sdk` is a peer dependency and must be installed separately.\n\n## Compatibility\n\n| Plugin Version | Fastify Version |\n|:--------------:|:---------------:|\n| `\u003e=0.x`        | `^5.x`          |\n\n## Usage\n\nRegister the plugin with your LINE channel credentials:\n\n```ts\nimport Fastify from 'fastify'\nimport fastifyLine, { type WebhookRequestBody } from 'fastify-line'\n\nconst fastify = Fastify()\n\nawait fastify.register(fastifyLine, {\n  channelSecret: process.env.LINE_CHANNEL_SECRET!,\n  channelAccessToken: process.env.LINE_CHANNEL_ACCESS_TOKEN!,\n})\n\nfastify.post\u003c{ Body: WebhookRequestBody }\u003e(\n  '/webhook',\n  {\n    config: { lineWebhook: true }, // Enable LINE webhook handling for this route\n  },\n  async (request, reply) =\u003e {\n    const { events } = request.body\n\n    for (const event of events) {\n      if (event.type === 'message' \u0026\u0026 event.message.type === 'text') {\n        await fastify.line.client.replyMessage({\n          replyToken: event.replyToken,\n          messages: [\n            {\n              type: 'text',\n              text: `You said: ${event.message.text}`,\n            },\n          ],\n        })\n\n        // or use blobClient\n        // fastify.line.blobClient\n      }\n    }\n\n    reply.send({ ok: true })\n  },\n)\n\nawait fastify.listen({ port: 3000 })\n```\n\n### Skip Signature Verification\n\n```ts\nawait fastify.register(fastifyLine, {\n  channelSecret: process.env.LINE_CHANNEL_SECRET!,\n  channelAccessToken: process.env.LINE_CHANNEL_ACCESS_TOKEN!,\n  skipVerify: true, // Skip signature verification\n})\n```\n\n\u003e **Warning:** Only use `skipVerify: true` in development/testing environments. Always verify signatures in production to ensure webhook security. If you skip automatic verification, you can manually verify signatures in your webhook handler using `validateSignature` from `@line/bot-sdk`.\n\n## Options\n\n| Option               | Type     | Required | Default | Description                                                      |\n|----------------------|----------|----------|---------|------------------------------------------------------------------|\n| `channelSecret`      | string   | Yes      | -       | Your LINE channel secret (for signature verification)            |\n| `channelAccessToken` | string   | Yes      | -       | Your LINE channel access token (for Messaging API client)        |\n| `skipVerify`         | boolean  | No       | `false` | Skip signature verification                                      |\n\n## How It Works\n\n- Adds a `line` property to your Fastify instance: `fastify.line` (an instance of `MessagingApiClient` from `@line/bot-sdk`).\n- For routes with `config: { lineWebhook: true }`:\n  - Parses the raw request body.\n  - Verifies the `X-Line-Signature` header using your channel secret.\n  - Throws `MissingSignatureError` or `InvalidSignatureError` if verification fails.\n\n## Error Handling\n\nThe plugin throws custom errors for signature issues:\n\n- `MissingSignatureError`: Thrown if the `X-Line-Signature` header is missing.\n- `InvalidSignatureError`: Thrown if the signature is invalid.\n\nYou can handle these errors using Fastify's error handler:\n\n```ts\nfastify.setErrorHandler((err, _request, reply) =\u003e {\n  if (err instanceof MissingSignatureError) {\n    reply.status(401).send({\n      error: err.message,\n      message: 'The X-Line-Signature header is missing.',\n    })\n  }\n\n  if (err instanceof InvalidSignatureError) {\n    reply.status(401).send({\n      error: err.message,\n      message: 'The X-Line-Signature header is invalid.',\n      signature: err.signature,\n    })\n  }\n\n  // Default error handling\n  reply.send(err)\n})\n```\n\n## Types\n\nThis plugin augments Fastify's types:\n\n- `fastify.line`: The LINE Messaging API client\n- `config.lineWebhook`: Set to `true` on a route to enable LINE webhook handling\n\n## Contributing\n\nContributions are welcome!\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finyourtime%2Ffastify-line","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Finyourtime%2Ffastify-line","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finyourtime%2Ffastify-line/lists"}