@logux/server 0.12.2 → 0.12.4
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.
- package/README.md +4 -6
- package/add-sync-map/index.d.ts +32 -32
- package/add-sync-map/index.js +4 -4
- package/base-server/hello.html +1 -1
- package/base-server/index.d.ts +401 -401
- package/base-server/index.js +332 -321
- package/bind-backend-proxy/index.js +77 -77
- package/bind-control-server/index.js +1 -1
- package/context/index.d.ts +36 -36
- package/context/index.js +1 -1
- package/create-http-server/index.js +4 -4
- package/create-reporter/index.js +107 -107
- package/filter-meta/index.d.ts +1 -1
- package/human-formatter/index.js +13 -13
- package/index.d.ts +24 -24
- package/index.js +16 -16
- package/options-loader/index.js +2 -2
- package/options-loader/index.test.js +25 -24
- package/package.json +13 -13
- package/request/index.d.ts +2 -1
- package/request/test.test.js +60 -34
- package/server/index.d.ts +27 -23
- package/server/index.js +56 -56
- package/server-client/index.d.ts +41 -41
- package/server-client/index.js +61 -61
- package/test-client/index.d.ts +50 -50
- package/test-client/index.js +28 -28
- package/test-server/index.d.ts +44 -43
- package/test-server/index.js +20 -20
- package/vite.config.ts +13 -0
package/filter-meta/index.d.ts
CHANGED
package/human-formatter/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import
|
|
2
|
-
import yyyymmdd from 'yyyy-mm-dd'
|
|
3
|
-
import pico from 'picocolors'
|
|
1
|
+
import { once } from 'events'
|
|
4
2
|
import os from 'os'
|
|
3
|
+
import pico from 'picocolors'
|
|
4
|
+
import pino from 'pino'
|
|
5
5
|
import abstractTransport from 'pino-abstract-transport'
|
|
6
6
|
import { Transform } from 'stream'
|
|
7
|
-
import
|
|
8
|
-
import
|
|
7
|
+
import stripAnsi from 'strip-ansi'
|
|
8
|
+
import yyyymmdd from 'yyyy-mm-dd'
|
|
9
9
|
|
|
10
10
|
import { mulberry32, onceXmur3 } from './utils.js'
|
|
11
11
|
|
|
@@ -15,19 +15,19 @@ const SEPARATOR = os.EOL + os.EOL
|
|
|
15
15
|
const NEXT_LINE = os.EOL === '\n' ? '\r\v' : os.EOL
|
|
16
16
|
|
|
17
17
|
const PARAMS_BLACKLIST = {
|
|
18
|
-
|
|
19
|
-
msg: true,
|
|
18
|
+
component: true,
|
|
20
19
|
err: true,
|
|
21
|
-
pid: true,
|
|
22
20
|
hint: true,
|
|
23
|
-
|
|
24
|
-
name: true,
|
|
25
|
-
time: true,
|
|
21
|
+
hostname: true,
|
|
26
22
|
level: true,
|
|
27
23
|
listen: true,
|
|
24
|
+
msg: true,
|
|
25
|
+
name: true,
|
|
26
|
+
note: true,
|
|
27
|
+
pid: true,
|
|
28
28
|
server: true,
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
time: true,
|
|
30
|
+
v: true
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
const LABELS = {
|
package/index.d.ts
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
export { Action } from '@logux/core'
|
|
2
|
-
|
|
3
1
|
export {
|
|
2
|
+
addSyncMap,
|
|
3
|
+
addSyncMapFilter,
|
|
4
|
+
ChangedAt,
|
|
5
|
+
NoConflictResolution,
|
|
6
|
+
SyncMapData,
|
|
7
|
+
WithoutTime,
|
|
8
|
+
WithTime
|
|
9
|
+
} from './add-sync-map/index.js'
|
|
10
|
+
export { ALLOWED_META } from './allowed-meta/index.js'
|
|
11
|
+
export {
|
|
12
|
+
BaseServer,
|
|
4
13
|
BaseServerOptions,
|
|
14
|
+
Logger,
|
|
5
15
|
SendBackActions,
|
|
6
|
-
BaseServer,
|
|
7
16
|
ServerMeta,
|
|
8
|
-
wasNot403
|
|
9
|
-
Logger
|
|
17
|
+
wasNot403
|
|
10
18
|
} from './base-server/index.js'
|
|
19
|
+
export { ChannelContext, Context } from './context/index.js'
|
|
20
|
+
export { filterMeta } from './filter-meta/index.js'
|
|
11
21
|
export {
|
|
12
|
-
|
|
13
|
-
|
|
22
|
+
del,
|
|
23
|
+
get,
|
|
14
24
|
patch,
|
|
15
25
|
post,
|
|
16
|
-
get,
|
|
17
26
|
put,
|
|
18
|
-
|
|
27
|
+
request,
|
|
28
|
+
ResponseError
|
|
19
29
|
} from './request/index.js'
|
|
20
|
-
export {
|
|
21
|
-
NoConflictResolution,
|
|
22
|
-
addSyncMapFilter,
|
|
23
|
-
WithoutTime,
|
|
24
|
-
SyncMapData,
|
|
25
|
-
addSyncMap,
|
|
26
|
-
ChangedAt,
|
|
27
|
-
WithTime
|
|
28
|
-
} from './add-sync-map/index.js'
|
|
29
|
-
export { TestServer, TestServerOptions } from './test-server/index.js'
|
|
30
|
-
export { TestClient, LoguxActionError } from './test-client/index.js'
|
|
31
|
-
export { Context, ChannelContext } from './context/index.js'
|
|
32
|
-
export { Server, ServerOptions } from './server/index.js'
|
|
33
30
|
export { ServerClient } from './server-client/index.js'
|
|
34
|
-
export {
|
|
35
|
-
export {
|
|
31
|
+
export { Server, ServerOptions } from './server/index.js'
|
|
32
|
+
export { LoguxActionError, TestClient } from './test-client/index.js'
|
|
33
|
+
export { TestServer, TestServerOptions } from './test-server/index.js'
|
|
34
|
+
|
|
35
|
+
export { Action } from '@logux/core'
|
package/index.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
export {
|
|
2
|
-
ResponseError,
|
|
3
|
-
request,
|
|
4
|
-
patch,
|
|
5
|
-
post,
|
|
6
|
-
get,
|
|
7
|
-
put,
|
|
8
|
-
del
|
|
9
|
-
} from './request/index.js'
|
|
10
|
-
export {
|
|
11
|
-
NoConflictResolution,
|
|
12
|
-
addSyncMapFilter,
|
|
13
2
|
addSyncMap,
|
|
14
|
-
|
|
3
|
+
addSyncMapFilter,
|
|
4
|
+
ChangedAt,
|
|
5
|
+
NoConflictResolution
|
|
15
6
|
} from './add-sync-map/index.js'
|
|
16
|
-
export { BaseServer, wasNot403 } from './base-server/index.js'
|
|
17
7
|
export { ALLOWED_META } from './allowed-meta/index.js'
|
|
18
|
-
export {
|
|
19
|
-
export { TestClient } from './test-client/index.js'
|
|
20
|
-
export { filterMeta } from './filter-meta/index.js'
|
|
8
|
+
export { BaseServer, wasNot403 } from './base-server/index.js'
|
|
21
9
|
export { Context } from './context/index.js'
|
|
10
|
+
export { filterMeta } from './filter-meta/index.js'
|
|
11
|
+
export {
|
|
12
|
+
del,
|
|
13
|
+
get,
|
|
14
|
+
patch,
|
|
15
|
+
post,
|
|
16
|
+
put,
|
|
17
|
+
request,
|
|
18
|
+
ResponseError
|
|
19
|
+
} from './request/index.js'
|
|
22
20
|
export { Server } from './server/index.js'
|
|
21
|
+
export { TestClient } from './test-client/index.js'
|
|
22
|
+
export { TestServer } from './test-server/index.js'
|
package/options-loader/index.js
CHANGED
|
@@ -99,9 +99,9 @@ function mapArgs(parsedCliArgs, argsSpec) {
|
|
|
99
99
|
function composeHelp(spec, argv) {
|
|
100
100
|
let options = Object.entries(spec.options).map(([name, option]) => ({
|
|
101
101
|
alias: option.alias ? composeCliAliasName(option.alias) : '',
|
|
102
|
-
|
|
102
|
+
description: option.description,
|
|
103
103
|
env: spec.envPrefix ? composeEnvName(spec.envPrefix, name) : '',
|
|
104
|
-
|
|
104
|
+
full: composeCliFullName(name)
|
|
105
105
|
}))
|
|
106
106
|
let nameColumnLength = Math.max(...options.map(it => it.full.length))
|
|
107
107
|
let envColumnLength = Math.max(...options.map(it => it.env.length))
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { resolve } from 'path'
|
|
2
|
+
import { describe, expect, it } from 'vitest'
|
|
2
3
|
|
|
3
|
-
import { loadOptions,
|
|
4
|
+
import { loadOptions, number, oneOf } from './index.js'
|
|
4
5
|
|
|
5
6
|
function fakeProcess(argv, env = {}) {
|
|
6
7
|
return { argv, env }
|
|
@@ -10,13 +11,13 @@ describe('loadOptions', () => {
|
|
|
10
11
|
it('returns help', () => {
|
|
11
12
|
let [help, options] = loadOptions(
|
|
12
13
|
{
|
|
14
|
+
examples: ['$0'],
|
|
13
15
|
options: {
|
|
14
16
|
port: {
|
|
15
17
|
description: 'port',
|
|
16
18
|
parse: number
|
|
17
19
|
}
|
|
18
|
-
}
|
|
19
|
-
examples: ['$0']
|
|
20
|
+
}
|
|
20
21
|
},
|
|
21
22
|
fakeProcess(['node', 'test/test.js', '--help'])
|
|
22
23
|
)
|
|
@@ -43,13 +44,13 @@ describe('loadOptions', () => {
|
|
|
43
44
|
it('uses env for options', () => {
|
|
44
45
|
let [, options] = loadOptions(
|
|
45
46
|
{
|
|
47
|
+
envPrefix: 'LOGUX',
|
|
46
48
|
options: {
|
|
47
49
|
port: {
|
|
48
50
|
description: 'port',
|
|
49
51
|
parse: number
|
|
50
52
|
}
|
|
51
|
-
}
|
|
52
|
-
envPrefix: 'LOGUX'
|
|
53
|
+
}
|
|
53
54
|
},
|
|
54
55
|
fakeProcess([], {
|
|
55
56
|
LOGUX_PORT: '31337'
|
|
@@ -63,13 +64,13 @@ describe('loadOptions', () => {
|
|
|
63
64
|
it('uses dotenv file for options', () => {
|
|
64
65
|
let [, options] = loadOptions(
|
|
65
66
|
{
|
|
67
|
+
envPrefix: 'LOGUX',
|
|
66
68
|
options: {
|
|
67
69
|
port: {
|
|
68
70
|
description: 'port',
|
|
69
71
|
parse: number
|
|
70
72
|
}
|
|
71
|
-
}
|
|
72
|
-
envPrefix: 'LOGUX'
|
|
73
|
+
}
|
|
73
74
|
},
|
|
74
75
|
fakeProcess([], {}),
|
|
75
76
|
{
|
|
@@ -83,13 +84,13 @@ describe('loadOptions', () => {
|
|
|
83
84
|
it('composes correct env and CLI names for argument with complex name', () => {
|
|
84
85
|
let [, options] = loadOptions(
|
|
85
86
|
{
|
|
87
|
+
envPrefix: 'LOGUX',
|
|
86
88
|
options: {
|
|
87
89
|
somePort: {
|
|
88
90
|
description: 'port',
|
|
89
91
|
parse: number
|
|
90
92
|
}
|
|
91
|
-
}
|
|
92
|
-
envPrefix: 'LOGUX'
|
|
93
|
+
}
|
|
93
94
|
},
|
|
94
95
|
fakeProcess(['--some-port', '1'], {
|
|
95
96
|
LOGUX_SOME_PORT: '1'
|
|
@@ -103,15 +104,15 @@ describe('loadOptions', () => {
|
|
|
103
104
|
it('uses combined options', () => {
|
|
104
105
|
let [, options] = loadOptions(
|
|
105
106
|
{
|
|
107
|
+
envPrefix: 'LOGUX',
|
|
106
108
|
options: {
|
|
107
|
-
key: {
|
|
108
|
-
description: 'port'
|
|
109
|
-
},
|
|
110
109
|
cert: {
|
|
111
110
|
description: 'cert'
|
|
111
|
+
},
|
|
112
|
+
key: {
|
|
113
|
+
description: 'port'
|
|
112
114
|
}
|
|
113
|
-
}
|
|
114
|
-
envPrefix: 'LOGUX'
|
|
115
|
+
}
|
|
115
116
|
},
|
|
116
117
|
fakeProcess(['', '--key', './key.pem'], { LOGUX_CERT: './cert.pem' })
|
|
117
118
|
)
|
|
@@ -122,19 +123,19 @@ describe('loadOptions', () => {
|
|
|
122
123
|
|
|
123
124
|
it('uses arg and env in given priority', () => {
|
|
124
125
|
let optionsSpec = {
|
|
126
|
+
envPrefix: 'LOGUX',
|
|
125
127
|
options: {
|
|
126
|
-
|
|
127
|
-
description: '
|
|
128
|
-
parse: number
|
|
128
|
+
cert: {
|
|
129
|
+
description: 'cert'
|
|
129
130
|
},
|
|
130
131
|
key: {
|
|
131
132
|
description: 'key'
|
|
132
133
|
},
|
|
133
|
-
|
|
134
|
-
description: '
|
|
134
|
+
port: {
|
|
135
|
+
description: 'port',
|
|
136
|
+
parse: number
|
|
135
137
|
}
|
|
136
|
-
}
|
|
137
|
-
envPrefix: 'LOGUX'
|
|
138
|
+
}
|
|
138
139
|
}
|
|
139
140
|
|
|
140
141
|
let [, options1] = loadOptions(
|
|
@@ -171,12 +172,12 @@ describe('loadOptions', () => {
|
|
|
171
172
|
let [, options] = loadOptions(
|
|
172
173
|
{
|
|
173
174
|
options: {
|
|
175
|
+
key: {
|
|
176
|
+
description: 'key'
|
|
177
|
+
},
|
|
174
178
|
port: {
|
|
175
179
|
alias: 'p',
|
|
176
180
|
description: 'port'
|
|
177
|
-
},
|
|
178
|
-
key: {
|
|
179
|
-
description: 'key'
|
|
180
181
|
}
|
|
181
182
|
}
|
|
182
183
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@logux/server",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.4",
|
|
4
4
|
"description": "Build own Logux server or make proxy between WebSocket and HTTP backend on any language",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"logux",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
],
|
|
16
16
|
"author": "Andrey Sitnik <andrey@sitnik.ru>",
|
|
17
17
|
"license": "MIT",
|
|
18
|
-
"homepage": "https://logux.
|
|
18
|
+
"homepage": "https://logux.org/",
|
|
19
19
|
"repository": "logux/server",
|
|
20
20
|
"engines": {
|
|
21
21
|
"node": "^14.0.0 || ^16.0.0 || >=18.0.0"
|
|
@@ -27,24 +27,24 @@
|
|
|
27
27
|
"./package.json": "./package.json"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@logux/actions": "^0.3.
|
|
31
|
-
"@logux/core": "^0.8.
|
|
30
|
+
"@logux/actions": "^0.3.1",
|
|
31
|
+
"@logux/core": "^0.8.4",
|
|
32
32
|
"JSONStream": "^1.3.5",
|
|
33
33
|
"cookie": "^0.5.0",
|
|
34
|
-
"dotenv": "^16.
|
|
35
|
-
"fast-glob": "^3.
|
|
34
|
+
"dotenv": "^16.3.1",
|
|
35
|
+
"fast-glob": "^3.3.1",
|
|
36
36
|
"ip": "^1.1.8",
|
|
37
37
|
"nanodelay": "^2.0.2",
|
|
38
|
-
"nanoevents": "^
|
|
39
|
-
"nanoid": "^4.0.
|
|
40
|
-
"node-fetch": "^
|
|
38
|
+
"nanoevents": "^8.0.0",
|
|
39
|
+
"nanoid": "^4.0.2",
|
|
40
|
+
"node-fetch": "^3.3.2",
|
|
41
41
|
"picocolors": "^1.0.0",
|
|
42
|
-
"pino": "8.
|
|
42
|
+
"pino": "8.15.0",
|
|
43
43
|
"pino-abstract-transport": "^1.0.0",
|
|
44
|
-
"semver": "^7.
|
|
45
|
-
"strip-ansi": "^7.0
|
|
44
|
+
"semver": "^7.5.4",
|
|
45
|
+
"strip-ansi": "^7.1.0",
|
|
46
46
|
"url-pattern": "^1.0.3",
|
|
47
|
-
"ws": "^8.
|
|
47
|
+
"ws": "^8.13.0",
|
|
48
48
|
"yyyy-mm-dd": "^1.0.2"
|
|
49
49
|
}
|
|
50
50
|
}
|
package/request/index.d.ts
CHANGED
package/request/test.test.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { spy } from 'nanospy'
|
|
2
|
+
import { expect, it } from 'vitest'
|
|
2
3
|
|
|
3
|
-
import {
|
|
4
|
+
import { del, get, patch, post, put, request, ResponseError } from '../index.js'
|
|
4
5
|
|
|
5
6
|
it('has error', () => {
|
|
6
7
|
let error = new ResponseError(
|
|
7
8
|
403,
|
|
8
9
|
'/a',
|
|
9
|
-
{
|
|
10
|
+
{ body: 'body', method: 'GET' },
|
|
10
11
|
'answer'
|
|
11
12
|
)
|
|
12
13
|
expect(error.name).toEqual('ResponseError')
|
|
@@ -24,73 +25,98 @@ it('throws an error on non-2xx response', async () => {
|
|
|
24
25
|
}
|
|
25
26
|
}
|
|
26
27
|
await expect(
|
|
27
|
-
request('/a', {
|
|
28
|
+
request('/a', { body: 'body', method: 'GET' }, fetch)
|
|
28
29
|
).rejects.toThrow(
|
|
29
|
-
new ResponseError(403, '/a', {
|
|
30
|
+
new ResponseError(403, '/a', { body: 'body', method: 'GET' }, 'answer')
|
|
30
31
|
)
|
|
31
32
|
})
|
|
32
33
|
|
|
33
34
|
it('parses JSON body', async () => {
|
|
34
35
|
async function fetch() {
|
|
35
36
|
return {
|
|
36
|
-
status: 200,
|
|
37
37
|
async json() {
|
|
38
38
|
return { answer: '1' }
|
|
39
|
-
}
|
|
39
|
+
},
|
|
40
|
+
status: 200
|
|
40
41
|
}
|
|
41
42
|
}
|
|
42
43
|
expect(await request('/a', { method: 'GET' }, fetch)).toEqual({ answer: '1' })
|
|
43
44
|
})
|
|
44
45
|
|
|
45
46
|
it('has shortcut for GET', async () => {
|
|
46
|
-
let fetch =
|
|
47
|
-
status: 200,
|
|
47
|
+
let fetch = spy(async () => ({
|
|
48
48
|
async json() {
|
|
49
49
|
return { answer: '1' }
|
|
50
|
-
}
|
|
50
|
+
},
|
|
51
|
+
status: 200
|
|
51
52
|
}))
|
|
52
53
|
|
|
53
54
|
expect(await get('/a', { headers: { a: 1 } }, fetch)).toEqual({ answer: '1' })
|
|
54
|
-
expect(fetch).
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
55
|
+
expect(fetch.calls).toEqual([
|
|
56
|
+
[
|
|
57
|
+
'/a',
|
|
58
|
+
{
|
|
59
|
+
headers: { a: 1 },
|
|
60
|
+
method: 'GET'
|
|
61
|
+
}
|
|
62
|
+
]
|
|
63
|
+
])
|
|
58
64
|
})
|
|
59
65
|
|
|
60
66
|
it('has shortcut for POST', async () => {
|
|
61
|
-
let fetch =
|
|
67
|
+
let fetch = spy(async () => ({ status: 204 }))
|
|
62
68
|
await post('/a', { headers: { a: 1 } }, fetch)
|
|
63
|
-
expect(fetch).
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
69
|
+
expect(fetch.calls).toEqual([
|
|
70
|
+
[
|
|
71
|
+
'/a',
|
|
72
|
+
{
|
|
73
|
+
headers: { a: 1 },
|
|
74
|
+
method: 'POST'
|
|
75
|
+
}
|
|
76
|
+
]
|
|
77
|
+
])
|
|
67
78
|
})
|
|
68
79
|
|
|
69
80
|
it('has shortcut for PUT', async () => {
|
|
70
|
-
let fetch =
|
|
81
|
+
let fetch = spy(async () => ({ status: 204 }))
|
|
71
82
|
await put('/a', { headers: { a: 1 } }, fetch)
|
|
72
|
-
expect(fetch).
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
83
|
+
expect(fetch.calls).toEqual([
|
|
84
|
+
[
|
|
85
|
+
'/a',
|
|
86
|
+
{
|
|
87
|
+
headers: { a: 1 },
|
|
88
|
+
method: 'PUT'
|
|
89
|
+
}
|
|
90
|
+
]
|
|
91
|
+
])
|
|
76
92
|
})
|
|
77
93
|
|
|
78
94
|
it('has shortcut for PATCH', async () => {
|
|
79
|
-
let fetch =
|
|
95
|
+
let fetch = spy(async () => ({ status: 204 }))
|
|
80
96
|
await patch('/a', { headers: { a: 1 } }, fetch)
|
|
81
|
-
expect(fetch).
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
97
|
+
expect(fetch.calls).toEqual([
|
|
98
|
+
[
|
|
99
|
+
'/a',
|
|
100
|
+
{
|
|
101
|
+
headers: { a: 1 },
|
|
102
|
+
method: 'PATCH'
|
|
103
|
+
}
|
|
104
|
+
]
|
|
105
|
+
])
|
|
85
106
|
})
|
|
86
107
|
|
|
87
108
|
it('has shortcut for DELETE', async () => {
|
|
88
|
-
let fetch =
|
|
109
|
+
let fetch = spy(async () => ({ status: 204 }))
|
|
89
110
|
await del('/a', { headers: { a: 1 } }, fetch)
|
|
90
|
-
expect(fetch).
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
111
|
+
expect(fetch.calls).toEqual([
|
|
112
|
+
[
|
|
113
|
+
'/a',
|
|
114
|
+
{
|
|
115
|
+
headers: { a: 1 },
|
|
116
|
+
method: 'DELETE'
|
|
117
|
+
}
|
|
118
|
+
]
|
|
119
|
+
])
|
|
94
120
|
})
|
|
95
121
|
|
|
96
122
|
it('works without option object', async () => {
|
package/server/index.d.ts
CHANGED
|
@@ -1,22 +1,26 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
BaseServer,
|
|
3
|
+
type BaseServerOptions,
|
|
4
|
+
type Logger
|
|
5
|
+
} from '../base-server/index.js'
|
|
2
6
|
|
|
3
7
|
export interface LoggerOptions {
|
|
4
|
-
/**
|
|
5
|
-
* Logger message format.
|
|
6
|
-
*/
|
|
7
|
-
type?: 'human' | 'json'
|
|
8
|
-
|
|
9
8
|
/**
|
|
10
9
|
* Stream to be used by logger to write log.
|
|
11
10
|
*/
|
|
12
11
|
stream?: {
|
|
13
|
-
write(str: string): void
|
|
14
|
-
|
|
15
12
|
/**
|
|
16
13
|
* Used by pino to synchronously write log messages on application failure.
|
|
17
14
|
*/
|
|
18
15
|
flushSync?(): void
|
|
16
|
+
|
|
17
|
+
write(str: string): void
|
|
19
18
|
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Logger message format.
|
|
22
|
+
*/
|
|
23
|
+
type?: 'human' | 'json'
|
|
20
24
|
}
|
|
21
25
|
|
|
22
26
|
export interface ServerOptions extends BaseServerOptions {
|
|
@@ -73,6 +77,20 @@ export interface ServerOptions extends BaseServerOptions {
|
|
|
73
77
|
* ```
|
|
74
78
|
*/
|
|
75
79
|
export class Server<Headers extends object = {}> extends BaseServer<Headers> {
|
|
80
|
+
/**
|
|
81
|
+
* Server options.
|
|
82
|
+
*
|
|
83
|
+
* ```js
|
|
84
|
+
* console.log('Server options', server.options.subprotocol)
|
|
85
|
+
* ```
|
|
86
|
+
*/
|
|
87
|
+
options: ServerOptions
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* @param opts Server options.
|
|
91
|
+
*/
|
|
92
|
+
constructor(opts: ServerOptions)
|
|
93
|
+
|
|
76
94
|
/**
|
|
77
95
|
* Load options from command-line arguments and/or environment.
|
|
78
96
|
*
|
|
@@ -95,20 +113,6 @@ export class Server<Headers extends object = {}> extends BaseServer<Headers> {
|
|
|
95
113
|
defaults: ServerOptions
|
|
96
114
|
): ServerOptions
|
|
97
115
|
|
|
98
|
-
/**
|
|
99
|
-
* @param opts Server options.
|
|
100
|
-
*/
|
|
101
|
-
constructor(opts: ServerOptions)
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* Server options.
|
|
105
|
-
*
|
|
106
|
-
* ```js
|
|
107
|
-
* console.log('Server options', server.options.subprotocol)
|
|
108
|
-
* ```
|
|
109
|
-
*/
|
|
110
|
-
options: ServerOptions
|
|
111
|
-
|
|
112
116
|
/**
|
|
113
117
|
* Load module creators and apply to the server. By default, it will load
|
|
114
118
|
* files from `modules/*`.
|
|
@@ -119,5 +123,5 @@ export class Server<Headers extends object = {}> extends BaseServer<Headers> {
|
|
|
119
123
|
*
|
|
120
124
|
* @param files Pattern for module files.
|
|
121
125
|
*/
|
|
122
|
-
autoloadModules(files?: string
|
|
126
|
+
autoloadModules(files?: string | string[]): Promise<void>
|
|
123
127
|
}
|