@blued-core/http-server
TypeScript icon, indicating that this package has built-in type declarations

0.7.5 • Public • Published

基于 routing-controller 的简易封装,抽出了一些复用的逻辑。

npx install-peerdeps @blued-core/http-server

使用方式

import { createServer } from '@blued-core/http-server'

createServer({
  logPath: './log',
  exceptionReportUrl: 'sentry.xxx.com',
  performanceConfig: {
    host: '0.0.0.1',
    port: 12345,
    group: 'test',
    project: 'test-project'
  },
  port: 1234
})

// 具体的 router 实现

import { JsonController, Get } from '@blued-core/http-server'

@JsonController('/test')
export default class {
  @Get('/patha')
  get () {
    return 'Hello World'
  }
}

// curl http://127.0.0.1:1234/test/patha

如果请求 Header 携带 Content-Type: application/json 则会主动拼接参数,类似
{ code: 200, data: 'Hello World' }

主要文档基于:http-server-base

额外提供的参数

option type default desc
logPath string - 设置 log 输出的路径
exceptionReportUrl string - 设置异常监控上报的路径
performanceConfig Object - 设置性能监控上报的配置

performanceConfig 具体配置

option type desc
host string 配置的 IP
port number 端口号
group string 上报数据所属分组
project string 上报数据所属项目

Dependents (0)

Package Sidebar

Install

npm i @blued-core/http-server

Weekly Downloads

3

Version

0.7.5

License

ISC

Unpacked Size

8.16 kB

Total Files

6

Last publish

Collaborators

  • chisecc
  • jarvan8888
  • jiasm
  • ryli
  • nieweidong
  • fengcang2020