{"id":15882523,"url":"https://github.com/ph1p/hemera-fastify","last_synced_at":"2025-07-05T13:36:45.819Z","repository":{"id":57262743,"uuid":"126404439","full_name":"ph1p/hemera-fastify","owner":"ph1p","description":"hemera http plugin with hemera-fastify","archived":false,"fork":false,"pushed_at":"2018-03-22T23:04:43.000Z","size":4,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-30T06:34:19.671Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/ph1p.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":"2018-03-22T22:56:13.000Z","updated_at":"2018-03-22T23:04:44.000Z","dependencies_parsed_at":"2022-09-01T04:27:05.275Z","dependency_job_id":null,"html_url":"https://github.com/ph1p/hemera-fastify","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ph1p%2Fhemera-fastify","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ph1p%2Fhemera-fastify/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ph1p%2Fhemera-fastify/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ph1p%2Fhemera-fastify/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ph1p","download_url":"https://codeload.github.com/ph1p/hemera-fastify/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246763861,"owners_count":20829798,"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-10-06T04:04:23.898Z","updated_at":"2025-04-02T05:43:59.851Z","avatar_url":"https://github.com/ph1p.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Hemera-fastify\n\n[![npm](https://img.shields.io/npm/v/hemera-fastify.svg?maxAge=3600)](https://www.npmjs.com/package/hemera-fastify)\n\nCopied from [hemera-web](https://github.com/hemerajs/hemera/tree/master/packages/hemera-web) and switched from express 4 to fastify.\nAlso I've kicked out some dependencies.\n\n\u003e Under development\n\n\n## Example\n\n```javascript\nconst Hemera = require('nats-hemera');\nconst HemeraJoi = require('hemera-joi');\nconst hemeraWeb = require('../hemera-fastify/index');\nconst nats = require('nats').connect({\n  url: 'nats://0.0.0.0:4222'\n});\nconst hemera = new Hemera(nats, {\n  logLevel: 'info'\n});\nconst CustomError = hemera.createError('CustomError');\n\nhemera.use(hemeraWeb, {\n  // set fastify config\n  fastify: {},\n  beforeStart(fastify) {\n    // Add own content parser\n    fastify.addContentTypeParser('text/html', (req, done) =\u003e {\n      var body = '';\n      req.on('data', data =\u003e {\n        body += data;\n      });\n      req.on('end', () =\u003e {\n        try {\n          done(null, body);\n        } catch (e) {\n          done(e);\n        }\n      });\n      req.on('error', done);\n    });\n  },\n  port: 3000,\n  host: '127.0.0.1',\n  pattern: {\n    topic: 'math',\n    cmd: 'add'\n  }\n});\n\nconst start = async () =\u003e {\n  try {\n    // establish connection and bootstrap hemera\n    await hemera.ready();\n\n    hemera.add(\n      {\n        topic: 'math',\n        cmd: 'add'\n      },\n      (req, cb) =\u003e {\n        cb(null, `\u003ch1\u003e${parseInt(req.a) + parseInt(req.b)}\u003c/h1\u003e`);\n\n        // cb(null, {\n        //     result: parseInt(req.a) + parseInt(req.b)\n        // });\n\n        // const error = new CustomError()\n        // error.statusCode = 404\n        // cb(error)\n      }\n    );\n    hemera.log.info('service listening');\n  } catch (err) {\n    hemera.log.error(err);\n    process.exit(1);\n  }\n};\nstart();\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fph1p%2Fhemera-fastify","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fph1p%2Fhemera-fastify","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fph1p%2Fhemera-fastify/lists"}