{"id":13836156,"url":"https://github.com/lependu/fastify-lured","last_synced_at":"2026-04-02T18:53:54.867Z","repository":{"id":57233319,"uuid":"115212549","full_name":"lependu/fastify-lured","owner":"lependu","description":"Preloads lua scripts with fastify-redis and lured.","archived":false,"fork":false,"pushed_at":"2023-06-24T14:03:53.000Z","size":109,"stargazers_count":0,"open_issues_count":3,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-11T16:42:02.473Z","etag":null,"topics":["fastify","fastifyjs-plugin","lua","lured","nodejs","redis"],"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/lependu.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}},"created_at":"2017-12-23T17:55:52.000Z","updated_at":"2020-07-30T12:48:23.000Z","dependencies_parsed_at":"2024-04-12T11:01:54.109Z","dependency_job_id":"7ae3f840-5f2d-48ca-aaa2-2e25b90b5fab","html_url":"https://github.com/lependu/fastify-lured","commit_stats":null,"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lependu%2Ffastify-lured","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lependu%2Ffastify-lured/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lependu%2Ffastify-lured/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lependu%2Ffastify-lured/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lependu","download_url":"https://codeload.github.com/lependu/fastify-lured/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247354711,"owners_count":20925484,"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":["fastify","fastifyjs-plugin","lua","lured","nodejs","redis"],"created_at":"2024-08-04T15:00:36.977Z","updated_at":"2025-12-30T23:07:01.060Z","avatar_url":"https://github.com/lependu.png","language":"JavaScript","readme":"## fastify-lured\n\n\u003e :warning: This package is maintained until 2019-09-01 (end of the `fastify@1.x` lifecycle.) and won't be updated to `fastify@2.x`\n\n[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](http://standardjs.com/)\n[![Build Status](https://travis-ci.org/lependu/fastify-lured.svg?branch=master)](https://travis-ci.org/lependu/fastify-lured)\n[![Greenkeeper badge](https://badges.greenkeeper.io/lependu/fastify-lured.svg)](https://greenkeeper.io/)\n[![Known Vulnerabilities](https://snyk.io/test/github/lependu/fastify-lured/badge.svg)](https://snyk.io/test/github/lependu/fastify-lured)\n[![Coverage Status](https://coveralls.io/repos/github/lependu/fastify-lured/badge.svg?branch=master)](https://coveralls.io/github/lependu/fastify-lured?branch=master)\n![npm](https://img.shields.io/npm/v/fastify-lured.svg)\n![npm](https://img.shields.io/npm/dm/fastify-lured.svg)\n\nSimple plugin to preload lua scripts via [fastify-redis](https://github.com/fastify/fastify-redis). Under the hood it scans the directory provided in `path` option and loads the files with [lured](https://github.com/enobufs/lured).\n\n## Install\n```\n$ npm i --save fastify-lured\n```\n\n## Usage\n\n1. Set up a redis server.\n2. Register `fastify-redis` first, then this plugin.\n\nIt provides `scripts` [decorator](https://www.fastify.io/docs/latest/Decorators/) object:\n```\n{\n  [lowerCamelCaseFileNameWithoutExt]: {\n    script: {String} The string representation of the script.\n    sha: {String} Calculated sha of the script.\n  }\n}\n```\n\n```js\nconst Fastify = require('fastify')\nconst fastifyRedis = require('fastify-redis')\nconst plugin = require('./index')\nconst nodeRedis = require('redis')\nconst { join } = require('path')\n\nconst { createClient } = nodeRedis\nconst instance = Fastify()\nconst client = createClient({ host: 'redis-test' })\n\ninstance\n  .register(fastifyRedis, { client })\n  .register(lured, { path: join(__dirname, 'test-scripts') })\n  .get('/hello/:name', {}, (req, reply) =\u003e {\n    let { redis, scripts } = instance\n\n    redis.evalsha(scripts.hello.sha, 0, req.params.name, (err, result) =\u003e {\n      reply\n        // hello.lua script returns JSON which do not need seraialization.\n        // Therefore we can bypass fastify internal serialization process.\n        // For that we must set the content-type header.\n        // See: https://www.fastify.io/docs/latest/Reply/#-serializer-func-\n        .type('application/json; charset=utf-8')\n        .serializer(function () {\n          return result\n        })\n        .send(err || result)\n    })\n  })\n```\n\n## Options\n\n`path` `{String}` *required* It has to be an absolute path to the script directory.\n\n## Caveats\n\n- No recursive file loading.\n- Only loads files with `.lua` extension.\n- From *`v2.0.0`* you need to pass node-redis client to fastify-redis, because it switched to ioredis as default client. Ioredis `Commander` class provides much better support for lua scripts, so using this plugin makes no sense.\n\n## License\n\nLicensed under [MIT](./LICENSE).\n","funding_links":[],"categories":["\u003ch2 align=\"center\"\u003eAwesome Fastify\u003c/h2\u003e"],"sub_categories":["\u003ch2 align=\"center\"\u003eEcosystem\u003c/h2\u003e"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flependu%2Ffastify-lured","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flependu%2Ffastify-lured","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flependu%2Ffastify-lured/lists"}