Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/keverjs/response
standard response output format.
https://github.com/keverjs/response
Last synced: about 2 months ago
JSON representation
standard response output format.
- Host: GitHub
- URL: https://github.com/keverjs/response
- Owner: keverjs
- License: mit
- Created: 2021-03-23T06:35:24.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2023-08-09T09:40:07.000Z (over 1 year ago)
- Last Synced: 2024-10-31T17:46:47.441Z (about 2 months ago)
- Language: TypeScript
- Size: 456 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# @kever/response
a kever property plugin, standard response output format.
## Install
> npm install @kever/response --save
## Start
```ts
//index.ts
import { createApp } from '@kever/core'createApp({
port: 9000,
plugins: [
'@kever/response'
]
})
``````ts
// controller.ts
import { BaseController, Context, Controller } from '@kever/core'
import { PluginType, UsePlugin } from '@kever/ioc'
import { Get } from '@kever/router'
import { Response } from '@kever/response'@Controller('/')
export class Controller extends BaseController {@UsePlugin(PluginType.property, 'response')
private response: Response@Get('/index')
async index(ctx: Context) {ctx.body = this.response(ctx, 10000, {
name: 'kever',
message: 'Hello world'
})
}
}```