# @blued-core/http-server

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

Latest version **0.7.6** (published 2025-04-27) · ISC license · 0 weekly downloads

## Install

```sh
npm install @blued-core/http-server
pnpm add @blued-core/http-server
yarn add @blued-core/http-server
bun add @blued-core/http-server
```

## Health

**Score 25/100 (F)** — status: maintenance-mode.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.7.6 |
| Published | 2025-04-27 |
| First published | 2019-04-24 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 6 |
| Unpacked size | 8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | jiasm, ryli, nieweidong, fengcang2020, jarvan8888, chisecc |

## Links

- npm: https://www.npmjs.com/package/@blued-core/http-server
- npm.io page: https://npm.io/package/@blued-core/http-server

## Dependencies (6)

- [@blued-core/cache](https://npm.io/package/@blued-core/cache.md) ^1.0.6
- [@blued-core/normal-conf](https://npm.io/package/@blued-core/normal-conf.md) ^0.1.1
- [@blued-core/winston-logger](https://npm.io/package/@blued-core/winston-logger.md) ^0.1.3
- [@blued-core/http-server-base](https://npm.io/package/@blued-core/http-server-base.md) ^0.6.5
- [@blued-core/performance-client](https://npm.io/package/@blued-core/performance-client.md) 0.0.5
- [@blued-core/exception-report-client](https://npm.io/package/@blued-core/exception-report-client.md) ^0.1.1

## Recent versions

- 0.7.6 (latest) — 2025-04-27
- 0.7.5 — 2024-02-27
- 0.7.4 — 2024-02-20
- 0.7.3 — 2024-02-06
- 0.7.2 — 2024-02-06
- 0.7.1 — 2024-02-05
- 0.7.0 — 2023-03-21
- 0.6.0 — 2021-08-12
- 0.5.2 — 2021-05-26
- 0.5.1 — 2020-09-29
- 0.5.0 — 2020-09-29
- 0.4.4 — 2020-03-10
- 0.4.3 — 2020-03-09
- 0.4.2 — 2019-12-08
- 0.4.1 — 2019-12-06
- … 13 more at https://npm.io/package/@blued-core/http-server/versions

## README

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

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

### 使用方式

```typescript
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](https://www.npmjs.com/package/@blued-core/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|上报数据所属项目

---
_Source: https://npm.io/package/@blued-core/http-server · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
