You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

@blued-core/http-server

Package Overview
Dependencies
Maintainers
6
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@blued-core/http-server

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

0.7.6
latest
npm
Version published
Maintainers
6
Created
Source

基于 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

额外提供的参数

optiontypedefaultdesc
logPathstring-设置 log 输出的路径
exceptionReportUrlstring-设置异常监控上报的路径
performanceConfigObject-设置性能监控上报的配置

performanceConfig 具体配置

optiontypedesc
hoststring配置的 IP
portnumber端口号
groupstring上报数据所属分组
projectstring上报数据所属项目

FAQs

Package last updated on 27 Apr 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts