https://github.com/huangang/fastify-call
Fastify plugin to call self method.
https://github.com/huangang/fastify-call
fastify fastify-call fastify-plugin
Last synced: 3 months ago
JSON representation
Fastify plugin to call self method.
- Host: GitHub
- URL: https://github.com/huangang/fastify-call
- Owner: huangang
- Created: 2019-06-14T08:37:47.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2019-12-05T01:25:13.000Z (over 5 years ago)
- Last Synced: 2025-03-17T09:07:10.619Z (4 months ago)
- Topics: fastify, fastify-call, fastify-plugin
- Language: JavaScript
- Homepage:
- Size: 31.3 KB
- Stars: 3
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# fastify-call
Fastify plugin to call self method.
[](https://travis-ci.org/huangang/fastify-call)
[](https://www.npmjs.com/package/fastify-call)
## Install
```
npm i fastify-call --save
```
## Usage```js
'use strict'const fastify = require('fastify')()
fastify.register(require('fastify-call'))
fastify.get('/t1', function (request, reply) {
reply.send({ 'hello': 't1' })
})fastify.get('/t2', function (request, reply) {
return fastify.call('t1').then((data) => {
data.world = 't2'
return reply.send(data)
})
})fastify.get('/t3', function (request, reply) {
return fastify.call.post('t1', { a: 1 }).then((data) => {
data.world = 't3'
return reply.send(data)
})
})fastify.listen(3000, err => {
if (err) throw err
console.log(`server listening on ${fastify.server.address().port}`)
})
```