starlight-server 1.7.13 → 1.7.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -56,7 +56,6 @@ export function parseFormData(body, boundary) {
56
56
  let rest = body;
57
57
  let state = State.Init;
58
58
  let partialInput; // 在 ReadingHeaders 状态里会为其赋值 Will be assigned when in the ReadingHeaders state
59
- // eslint-disable-next-line no-constant-condition
60
59
  while (true) {
61
60
  if (!rest.byteLength)
62
61
  throw new HTTPError(400, 'form-data: not complete');
@@ -1,5 +1,5 @@
1
1
  import type http from 'node:http';
2
- import { type Logger } from '../logging.js';
2
+ import { type Logger } from '@anjianshi/utils';
3
3
  import { RequestBody, type BodyOptions } from './body/index.js';
4
4
  import { type NodeRequest } from './types.js';
5
5
  /**
@@ -1,4 +1,4 @@
1
- import { type Logger } from '../logging.js';
1
+ import { type Logger } from '@anjianshi/utils';
2
2
  import { type NodeResponse } from './types.js';
3
3
  /**
4
4
  * 封装响应内容输出函数
@@ -59,7 +59,7 @@ export class ResponseUtils {
59
59
  */
60
60
  error(error) {
61
61
  if (error instanceof HTTPError) {
62
- this.nodeResponse.statusCode = error.status; // eslint-disable-line require-atomic-updates
62
+ this.nodeResponse.statusCode = error.status;
63
63
  this.nodeResponse.end(error.message);
64
64
  }
65
65
  else if (typeof error === 'number') {
@@ -1,4 +1,4 @@
1
- import { type Logger } from '../logging.js';
1
+ import { type Logger } from '@anjianshi/utils';
2
2
  import { type BodyOptions } from './body/index.js';
3
3
  import { Request } from './request.js';
4
4
  import { ResponseUtils } from './response.js';
@@ -1,5 +1,5 @@
1
1
  import http from 'node:http';
2
- import { LogLevel } from '../logging.js';
2
+ import { LogLevel } from '@anjianshi/utils';
3
3
  import { Request } from './request.js';
4
4
  import { ResponseUtils } from './response.js';
5
5
  /**
@@ -2,7 +2,7 @@ import { type ResponseUtils } from '../http/index.js';
2
2
  import * as factories from './factories.js';
3
3
  import { type DocumentOptions, type OperationOptions } from './factories.js';
4
4
  import type { OpenAPI, Schema, Response, Parameter, RequestBody, Method, Operation } from './specification.js';
5
- export * from './specification.js';
5
+ export type * from './specification.js';
6
6
  /**
7
7
  * 把 OpenAPI 文档输出成 Swagger 页面
8
8
  */
@@ -5,7 +5,6 @@ import { isFileExists } from '@anjianshi/utils/env-node/index.js';
5
5
  import defaultsDeep from 'lodash/defaultsDeep.js';
6
6
  import { getAbsoluteFSPath } from 'swagger-ui-dist';
7
7
  import * as factories from './factories.js';
8
- export * from './specification.js';
9
8
  /**
10
9
  * 把 OpenAPI 文档输出成 Swagger 页面
11
10
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "starlight-server",
3
- "version": "1.7.13",
3
+ "version": "1.7.16",
4
4
  "description": "Simple But Powerful Node.js HTTP Server",
5
5
  "type": "module",
6
6
  "keywords": [
@@ -26,7 +26,7 @@
26
26
  },
27
27
  "main": "dist/index.js",
28
28
  "dependencies": {
29
- "@anjianshi/utils": "^2.3.5",
29
+ "@anjianshi/utils": "^2.3.11",
30
30
  "chalk": "^5.3.0",
31
31
  "dayjs": "^1.11.13",
32
32
  "debug": "^4.3.7",
@@ -38,14 +38,14 @@
38
38
  "@anjianshi/presets-prettier": "^3.0.1",
39
39
  "@anjianshi/presets-typescript": "^3.2.2",
40
40
  "@types/debug": "^4.1.12",
41
- "@types/lodash": "^4.17.9",
42
- "@types/node": "^22.7.3",
41
+ "@types/lodash": "^4.17.10",
42
+ "@types/node": "^22.7.5",
43
43
  "@types/swagger-ui-dist": "^3.30.5",
44
44
  "concurrently": "^8.2.2",
45
45
  "nodemon": "^3.1.7",
46
46
  "rimraf": "^5.0.10",
47
47
  "tsc-alias": "^1.8.10",
48
- "typescript": "^5.6.2"
48
+ "typescript": "^5.6.3"
49
49
  },
50
50
  "eslintIgnore": [],
51
51
  "prettier": "@anjianshi/presets-prettier/prettierrc",
@@ -76,7 +76,7 @@ export function parseFormData(body: Buffer, boundary: string): FormData {
76
76
  let rest = body
77
77
  let state: State = State.Init
78
78
  let partialInput: Input | undefined // 在 ReadingHeaders 状态里会为其赋值 Will be assigned when in the ReadingHeaders state
79
- // eslint-disable-next-line no-constant-condition
79
+
80
80
  while (true) {
81
81
  if (!rest.byteLength) throw new HTTPError(400, 'form-data: not complete')
82
82
 
@@ -110,7 +110,7 @@ export function parseFormData(body: Buffer, boundary: string): FormData {
110
110
  const name = /(?:;| )name="(.*?)"(?:;|$)/.exec(disposition)?.[1] ?? ''
111
111
  const filename = /(?:;| )filename="(.*?)"(?:;|$)/.exec(disposition)?.[1]
112
112
  const contentType = headers.find(
113
- v => v.name.toLowerCase() === 'Content-Type'.toLowerCase()
113
+ v => v.name.toLowerCase() === 'Content-Type'.toLowerCase(),
114
114
  )?.value
115
115
  partialInput =
116
116
  filename === undefined
@@ -1,6 +1,5 @@
1
1
  import type http from 'node:http'
2
- import { parseQuery } from '@anjianshi/utils'
3
- import { type Logger } from '@/logging.js'
2
+ import { parseQuery, type Logger } from '@anjianshi/utils'
4
3
  import { RequestBody, type BodyOptions } from './body/index.js'
5
4
  import { HTTPError, type NodeRequest } from './types.js'
6
5
 
@@ -1,4 +1,4 @@
1
- import { type Logger } from '@/logging.js'
1
+ import { type Logger } from '@anjianshi/utils'
2
2
  import { path2MIMEType } from './mime-types.js'
3
3
  import { HTTPError, type NodeResponse } from './types.js'
4
4
 
@@ -63,7 +63,7 @@ export class ResponseUtils {
63
63
  */
64
64
  error(error: unknown) {
65
65
  if (error instanceof HTTPError) {
66
- this.nodeResponse.statusCode = error.status // eslint-disable-line require-atomic-updates
66
+ this.nodeResponse.statusCode = error.status
67
67
  this.nodeResponse.end(error.message)
68
68
  } else if (typeof error === 'number') {
69
69
  this.error(new HTTPError(error))
@@ -1,5 +1,5 @@
1
1
  import http from 'node:http'
2
- import { type Logger, LogLevel } from '@/logging.js'
2
+ import { type Logger, LogLevel } from '@anjianshi/utils'
3
3
  import { type BodyOptions } from './body/index.js'
4
4
  import { Request } from './request.js'
5
5
  import { ResponseUtils } from './response.js'
@@ -18,7 +18,7 @@ import type {
18
18
  Operation,
19
19
  } from './specification.js'
20
20
 
21
- export * from './specification.js'
21
+ export type * from './specification.js'
22
22
 
23
23
  /**
24
24
  * 把 OpenAPI 文档输出成 Swagger 页面
@@ -97,7 +97,7 @@ export class Swagger {
97
97
  * Swagger 内容包含 HTML、各类资源文件和接口数据 JSON,都通过此方法输出,此方法通过 filepath 判断要输出什么。
98
98
  */
99
99
  private readonly fileCache = new Map<string, string>()
100
- async output(response: ResponseUtils, filepath: string = '') {
100
+ async output(response: ResponseUtils, filepath = '') {
101
101
  filepath = clearSlash(filepath)
102
102
 
103
103
  // 输出接口 JSON 数据
@@ -113,12 +113,12 @@ export class Swagger {
113
113
  if (filepath.endsWith('swagger-initializer.js')) {
114
114
  content = content.replace(
115
115
  'https://petstore.swagger.io/v2/swagger.json',
116
- './api-swagger.json'
116
+ './api-swagger.json',
117
117
  )
118
118
  if (this.uiConfig) {
119
119
  content = content.replace(
120
120
  'SwaggerUIBundle({',
121
- 'SwaggerUIBundle({\n ' + JSON.stringify(this.uiConfig).slice(1, -1) + ',\n'
121
+ 'SwaggerUIBundle({\n ' + JSON.stringify(this.uiConfig).slice(1, -1) + ',\n',
122
122
  )
123
123
  }
124
124
  }