pockethost 1.4.0 → 1.5.0
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/CHANGELOG.md +21 -0
- package/package.json +7 -4
- package/readme.md +6 -5
- package/src/cli/commands/ServeCommand/index.ts +4 -3
- package/src/cli/index.ts +16 -3
- package/src/common/Logger.ts +8 -6
- package/src/common/plugin/filter.ts +18 -0
- package/src/constants.ts +2 -8
- package/src/core/index.ts +1 -0
- package/src/core/logSettings.ts +7 -0
- package/src/instance-app/types/all.d.ts +3 -0
- package/src/instance-app/types/goja.d.ts +58 -0
- package/src/instance-app/types/lib.d.ts +5 -0
- package/src/instance-app/types/types.d.ts +19573 -0
- package/src/plugin.ts +36 -0
- package/src/server.ts +1 -21
package/src/plugin.ts
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { produce } from 'immer'
|
|
2
|
+
import {
|
|
3
|
+
PocketHostPlugin,
|
|
4
|
+
namespace,
|
|
5
|
+
onInstanceConfigFilter,
|
|
6
|
+
onInstanceLogAction,
|
|
7
|
+
onServeAction,
|
|
8
|
+
onServeSlugsFilter,
|
|
9
|
+
} from '../common'
|
|
10
|
+
import { dbg } from './cli'
|
|
11
|
+
import { PH_PROJECT_DIR } from './constants'
|
|
12
|
+
import { serve } from './server'
|
|
13
|
+
|
|
14
|
+
export const pockethost: PocketHostPlugin = async ({}) => {
|
|
15
|
+
onInstanceConfigFilter(async (config) => {
|
|
16
|
+
return produce(config, (draft) => {
|
|
17
|
+
draft.binds.hooks.push({
|
|
18
|
+
src: PH_PROJECT_DIR(`src/instance-app/hooks/**/*`),
|
|
19
|
+
base: PH_PROJECT_DIR(`src/instance-app/hooks`),
|
|
20
|
+
})
|
|
21
|
+
})
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
onInstanceLogAction(async ({ instance, type, data }) => {
|
|
25
|
+
dbg(namespace(instance.subdomain, type), data.toString())
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
onServeAction(async ({ only }) => {
|
|
29
|
+
if (!only.includes(`pockethost`)) return
|
|
30
|
+
serve()
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
onServeSlugsFilter(async (slugs) => {
|
|
34
|
+
return [...slugs, `pockethost`]
|
|
35
|
+
})
|
|
36
|
+
}
|
package/src/server.ts
CHANGED
|
@@ -3,7 +3,6 @@ import 'express-async-errors'
|
|
|
3
3
|
import { default as httpProxy } from 'http-proxy'
|
|
4
4
|
import {
|
|
5
5
|
LoggerService,
|
|
6
|
-
PocketHostPlugin,
|
|
7
6
|
doAfterInstanceFoundAction,
|
|
8
7
|
doAfterServerStartAction,
|
|
9
8
|
doAppMountedAction,
|
|
@@ -12,14 +11,10 @@ import {
|
|
|
12
11
|
doIncomingRequestAction,
|
|
13
12
|
doRequestErrorAction,
|
|
14
13
|
doRequestErrorMessageFilter,
|
|
15
|
-
onInstanceLogAction,
|
|
16
|
-
onServeAction,
|
|
17
|
-
onServeSlugsFilter,
|
|
18
14
|
} from '../common'
|
|
19
15
|
import { APEX_DOMAIN, PORT, asyncExitHook } from '../core'
|
|
20
|
-
import { dbg } from './cli'
|
|
21
16
|
|
|
22
|
-
const serve = async () => {
|
|
17
|
+
export const serve = async () => {
|
|
23
18
|
const _proxyLogger = LoggerService().create('ProxyService')
|
|
24
19
|
const { dbg, error, info, trace, warn } = _proxyLogger
|
|
25
20
|
|
|
@@ -111,18 +106,3 @@ const serve = async () => {
|
|
|
111
106
|
info(`Shutting down pockethost`)
|
|
112
107
|
})
|
|
113
108
|
}
|
|
114
|
-
|
|
115
|
-
export const pockethost: PocketHostPlugin = async ({}) => {
|
|
116
|
-
onInstanceLogAction(async ({ instance, type, data }) => {
|
|
117
|
-
dbg(data.toString())
|
|
118
|
-
})
|
|
119
|
-
|
|
120
|
-
onServeAction(async ({ only }) => {
|
|
121
|
-
if (!only.includes(`pockethost`)) return
|
|
122
|
-
serve()
|
|
123
|
-
})
|
|
124
|
-
|
|
125
|
-
onServeSlugsFilter(async (slugs) => {
|
|
126
|
-
return [...slugs, `pockethost`]
|
|
127
|
-
})
|
|
128
|
-
}
|