Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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: about 2 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 (over 5 years ago)
- Default Branch: master
- Last Pushed: 2019-12-05T01:25:13.000Z (about 5 years ago)
- Last Synced: 2024-11-18T22:01:51.415Z (3 months ago)
- Topics: fastify, fastify-call, fastify-plugin
- Language: JavaScript
- Homepage:
- Size: 31.3 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# fastify-call
Fastify plugin to call self method.
[![Build Status](https://travis-ci.org/huangang/fastify-call.svg?branch=master)](https://travis-ci.org/huangang/fastify-call)
[![NPM version](https://img.shields.io/npm/v/fastify-call.svg?style=flat)](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}`)
})
```