starlight-server 1.5.0 → 1.6.1

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.
@@ -22,7 +22,10 @@ export function makeOperation(options = {}) {
22
22
  ? query
23
23
  : query
24
24
  ? Object.entries(query).reduce((result, [name, options]) => {
25
- const query = makeQuery({ name, ...('schema' in options ? options : { schema: options }) });
25
+ const query = makeQuery({
26
+ name,
27
+ ...('schema' in options ? options : { schema: options }),
28
+ });
26
29
  return [...result, query];
27
30
  }, [])
28
31
  : undefined;
package/package.json CHANGED
@@ -1,13 +1,8 @@
1
1
  {
2
2
  "name": "starlight-server",
3
- "version": "1.5.0",
3
+ "version": "1.6.1",
4
4
  "description": "Simple But Powerful Node.js HTTP Server",
5
5
  "type": "module",
6
- "scripts": {
7
- "dev": "rimraf dist && (concurrently --raw \"tsc -w\" \"sleep 5 && tsc-alias -w\" \"sleep 6 && nodemon dist/demo/index.js\")",
8
- "build": "rimraf dist && tsc && tsc-alias",
9
- "prepublishOnly": "npm run build"
10
- },
11
6
  "keywords": [
12
7
  "web",
13
8
  "app",
@@ -29,26 +24,35 @@
29
24
  "publishConfig": {
30
25
  "registry": "https://registry.npmjs.org/"
31
26
  },
27
+ "main": "dist/index.js",
32
28
  "dependencies": {
33
- "@anjianshi/utils": "^1.3.1",
29
+ "@anjianshi/utils": "^2.0.7",
34
30
  "chalk": "^5.3.0",
31
+ "dayjs": "^1.11.10",
35
32
  "debug": "^4.3.4",
36
- "swagger-ui-dist": "^5.11.10"
33
+ "lodash": "^4.17.21",
34
+ "swagger-ui-dist": "^5.15.1"
37
35
  },
38
36
  "devDependencies": {
39
- "@anjianshi/presets-eslint-node": "^1.0.3",
40
- "@anjianshi/presets-eslint-typescript": "^1.0.3",
41
- "@anjianshi/presets-prettier": "^1.0.0",
42
- "@anjianshi/presets-typescript": "^1.0.1",
37
+ "@anjianshi/presets-eslint-node": "^4.0.3",
38
+ "@anjianshi/presets-eslint-typescript": "^4.0.3",
39
+ "@anjianshi/presets-prettier": "^3.0.0",
40
+ "@anjianshi/presets-typescript": "^3.1.3",
43
41
  "@types/debug": "^4.1.9",
44
42
  "@types/lodash": "^4.14.199",
45
43
  "@types/node": "^20.8.6",
46
44
  "@types/swagger-ui-dist": "^3.30.4",
47
45
  "concurrently": "^8.2.1",
48
46
  "nodemon": "^3.0.2",
49
- "rimraf": "^4.3.0",
50
- "tsc-alias": "^1.8.8"
47
+ "rimraf": "^5.0.5",
48
+ "tsc-alias": "^1.8.8",
49
+ "typescript": "^5.4.5"
51
50
  },
52
51
  "eslintIgnore": [],
53
- "prettier": "@anjianshi/presets-prettier/prettierrc"
54
- }
52
+ "prettier": "@anjianshi/presets-prettier/prettierrc",
53
+ "scripts": {
54
+ "dev": "rimraf dist && (concurrently --raw \"tsc-with-alias --watch\" \"nodemon dist/demo/index.js\")",
55
+ "build": "rimraf dist && tsc-with-alias",
56
+ "lint": "tsc --noEmit && eslint './src/**/*'"
57
+ }
58
+ }
@@ -13,7 +13,6 @@ import type {
13
13
  Reference,
14
14
  Parameter,
15
15
  RequestBody,
16
- Components,
17
16
  } from './specification.js'
18
17
 
19
18
  type SchemaOrRef = Schema | Reference
@@ -45,11 +44,14 @@ export function makeOperation(options: OperationOptions = {}): Operation {
45
44
  const parameters = Array.isArray(query)
46
45
  ? query
47
46
  : query
48
- ? Object.entries(query).reduce<Parameter[]>((result, [name, options]) => {
49
- const query = makeQuery({ name, ...('schema' in options ? options : { schema: options }) })
50
- return [...result, query]
51
- }, [])
52
- : undefined
47
+ ? Object.entries(query).reduce<Parameter[]>((result, [name, options]) => {
48
+ const query = makeQuery({
49
+ name,
50
+ ...('schema' in options ? options : { schema: options }),
51
+ })
52
+ return [...result, query]
53
+ }, [])
54
+ : undefined
53
55
  const requestBody = body ? ('$ref' in body ? (body as Reference) : makeBody(body)) : undefined
54
56
  const responses = response
55
57
  ? '$ref' in response
@@ -79,7 +81,7 @@ export function isOperationOptions(value: unknown): value is OperationOptions {
79
81
  if (typeof value !== 'object' || value === null) return false
80
82
  return (
81
83
  ['category', 'query', 'body', 'response'].find(key =>
82
- truthy((value as Record<string, unknown>)[key])
84
+ truthy((value as Record<string, unknown>)[key]),
83
85
  ) !== undefined
84
86
  )
85
87
  }
@@ -116,7 +118,7 @@ export function makeHeader(options: ParameterOptions): Parameter {
116
118
  */
117
119
  export function makeBody(
118
120
  input: Record<string, SchemaOrRef> | ObjectOptions | Schema,
119
- description?: string
121
+ description?: string,
120
122
  ): RequestBody {
121
123
  return {
122
124
  description,
@@ -152,7 +154,7 @@ export function makeResponsesBy(response: Response | Reference): Responses {
152
154
  /** 生成 Response 定义 */
153
155
  export function makeResponse(
154
156
  schema: Schema | Record<string, SchemaOrRef>,
155
- description?: string
157
+ description?: string,
156
158
  ): Response {
157
159
  return {
158
160
  description,
@@ -175,7 +177,7 @@ export function isSchema(value: unknown): value is Schema {
175
177
  if (typeof value !== 'object' || value === null) return false
176
178
  return (
177
179
  ['type', 'allOf', 'anyOf', 'oneOf', 'not'].find(key =>
178
- truthy((value as Record<string, unknown>)[key])
180
+ truthy((value as Record<string, unknown>)[key]),
179
181
  ) !== undefined
180
182
  )
181
183
  }