pockethost 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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,45 @@
1
1
  # pockethost
2
2
 
3
+ ## 1.6.1
4
+
5
+ ### Patch Changes
6
+
7
+ - dc8f70b: Updated docs
8
+
9
+ ## 1.6.0
10
+
11
+ ### Minor Changes
12
+
13
+ - 40bbb3c: Improve tryFetch by accepting node-fetch params
14
+ - 12f029a: Add changeset maker
15
+ - b7277cf: Add public instance URL calculators and refactor HTTP protocol detection
16
+ - 45a8f45: Add internal app (remote control) support
17
+ - 55b43a1: Remove unneeded params from GetOrProvisionInstanceUrl filter
18
+ - 5be2c9e: Initial commit
19
+ - a236f3e: Added several more filters
20
+ - 35edc77: Enhancement: actions execute sequentially
21
+ - 879845a: Enhancement: unsubscribe from filters
22
+ - c473ed9: Added support for priorities in actions
23
+ - 795fcd7: New action: KillInstance
24
+ - c32b845: Added support for Settings filter whereby all settings are collected and displayed in DEBUG() mode
25
+ - cce72b3: New action: AfterPluginsLoaded
26
+ - 82dde2d: Enhancement: filters now have extensible data types
27
+
28
+ ### Patch Changes
29
+
30
+ - b55c585: Clean up dead code
31
+ - 0e4bf43: Updated commit parser deps
32
+ - f79b067: Added serve command details
33
+ - dd3ceaa: Added filter debugging
34
+ - 7931204: Fixed a bug where adding plugins was not saved correctly
35
+ - 6e14f57: Updated plugin authoring guide
36
+ - 7604930: Minor fix to GetOrProvisionInstanceUrl filter
37
+ - 52b70cb: Fixed bug where --extra-plugins was not defaulting to '' correctly
38
+ - Updated dependencies [c32b845]
39
+ - @pockethost/plugin-launcher-spawn@1.0.0
40
+ - @pockethost/plugin-auto-admin@1.0.0
41
+ - @pockethost/plugin-console-logger@1.0.0
42
+
3
43
  ## 1.5.0
4
44
 
5
45
  ### Minor Changes
package/changesetx.ts ADDED
@@ -0,0 +1,110 @@
1
+ #!/usr/bin/env tsx
2
+ import { execSync } from 'child_process'
3
+ import { sync } from 'conventional-commits-parser'
4
+ import fs, { readFileSync } from 'fs'
5
+ import minimist from 'minimist'
6
+ import { dirname, join } from 'path'
7
+ import { fileURLToPath } from 'url'
8
+
9
+ const __dirname = dirname(fileURLToPath(import.meta.url))
10
+ const repoRootDir = join(__dirname, `../..`)
11
+
12
+ const argv = minimist(process.argv.slice(2))
13
+ const commitMessage = argv._[0]!
14
+ const { type, subject } = sync(commitMessage)
15
+ if (!type) {
16
+ console.log('Invalid commit message type')
17
+ process.exit(1)
18
+ }
19
+
20
+ function getStagedPackageNames(filePaths: string[]): string[] {
21
+ const packageNames = new Set<string>()
22
+
23
+ filePaths.forEach((filePath) => {
24
+ const packageName = getPackageName(filePath)
25
+ if (packageName) {
26
+ packageNames.add(packageName)
27
+ }
28
+ })
29
+
30
+ return Array.from(packageNames)
31
+ }
32
+
33
+ function getPackageName(filePath: string): string | null {
34
+ const packagePath = filePath.split('/').slice(0, 2).join('/')
35
+ const packageJsonPath = join(repoRootDir, `${packagePath}/package.json`)
36
+ const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf8'))
37
+ try {
38
+ return packageJson.name
39
+ } catch (error) {
40
+ return null
41
+ }
42
+ }
43
+
44
+ function getStagedFileNames(): string[] {
45
+ const output = execSync('git diff --name-only --cached').toString()
46
+ const fileNames = output
47
+ .trim()
48
+ .split('\n')
49
+ .filter((fileName) => fileName.startsWith(`packages/`))
50
+ return fileNames
51
+ }
52
+
53
+ async function createChangesetFile() {
54
+ const fileNames = getStagedFileNames()
55
+ const packageNames = getStagedPackageNames(fileNames)
56
+
57
+ if (packageNames.length === 0) {
58
+ console.log('No packages staged for commit')
59
+ process.exit(0)
60
+ }
61
+ console.log('Staged packages:', packageNames)
62
+
63
+ const prefixMap = {
64
+ feat: 'minor',
65
+ enh: 'minor',
66
+ fix: 'patch',
67
+ docs: 'patch',
68
+ chore: 'patch',
69
+ } as const
70
+
71
+ if (!(type! in prefixMap)) {
72
+ console.log('Invalid prefix found in commit message')
73
+ process.exit(1)
74
+ }
75
+
76
+ const versionType = prefixMap[type as keyof typeof prefixMap]
77
+
78
+ const changesetFile = [
79
+ `---`,
80
+ ...packageNames.map((packageName) => `'${packageName}': ${versionType}`),
81
+ `---`,
82
+ ``,
83
+ subject,
84
+ ].join('\n')
85
+ return changesetFile
86
+ }
87
+
88
+ async function writeChangesetFile(changesetFile: string) {
89
+ const filePath = join(repoRootDir, `.changeset`, `${+new Date()}.md`)
90
+ try {
91
+ fs.writeFileSync(filePath, changesetFile)
92
+ console.log(`Changeset file written successfully at ${filePath}`)
93
+ execSync(`git add ${filePath}`)
94
+ console.log(`Changeset file added to git`)
95
+ } catch (error) {
96
+ console.error(`Error writing changeset file: ${error}`)
97
+ }
98
+ }
99
+
100
+ function commit() {
101
+ execSync(`git commit -m "${commitMessage}"`)
102
+ }
103
+
104
+ async function main() {
105
+ const changesetFile = await createChangesetFile()
106
+ await writeChangesetFile(changesetFile)
107
+ commit()
108
+ }
109
+
110
+ main()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pockethost",
3
- "version": "1.5.0",
3
+ "version": "1.6.1",
4
4
  "author": {
5
5
  "name": "Ben Allfree",
6
6
  "url": "https://github.com/benallfree"
@@ -41,19 +41,22 @@
41
41
  "typescript": "^5.4.5",
42
42
  "update-notifier": "^7.0.0",
43
43
  "url-pattern": "^1.0.3",
44
- "@pockethost/plugin-auto-admin": "^0.1.1",
45
- "@pockethost/plugin-console-logger": "^0.2.1",
46
- "@pockethost/plugin-launcher-spawn": "^0.3.0"
44
+ "@pockethost/plugin-auto-admin": "^0.2.0",
45
+ "@pockethost/plugin-console-logger": "^0.3.0",
46
+ "@pockethost/plugin-launcher-spawn": "^0.4.0"
47
47
  },
48
48
  "devDependencies": {
49
+ "@types/conventional-commits-parser": "^5.0.0",
49
50
  "@types/express": "^4.17.21",
50
51
  "@types/http-proxy": "^1.17.13",
52
+ "@types/inquirer": "^9.0.7",
51
53
  "@types/json-stringify-safe": "^5.0.2",
52
54
  "@types/minimist": "^1.2.5",
53
55
  "@types/node": "^20.8.10",
54
56
  "@types/semver": "^7.5.4",
55
57
  "@types/tmp": "^0.2.5",
56
- "@types/update-notifier": "^6.0.8"
58
+ "@types/update-notifier": "^6.0.8",
59
+ "conventional-commits-parser": "^5.0.0"
57
60
  },
58
61
  "scripts": {
59
62
  "check-types": "tsc --noEmit ",
package/readme.md CHANGED
@@ -10,21 +10,75 @@ Extend PocketHost with its Plugin ecosystem. Start with the bare-bones dev serve
10
10
 
11
11
  ---
12
12
 
13
+ <!-- @import "[TOC]" {cmd="toc" depthFrom=2 depthTo=2 orderedList=false} -->
14
+
15
+ <!-- code_chunk_output -->
16
+
17
+ - [Quickstart](#quickstart)
18
+ - [Introduction](#introduction)
19
+ - [The magic `serve` command](#the-magic-serve-command)
20
+ - [Configuration](#configuration)
21
+ - [Plugins Directory](#plugins-directory)
22
+ - [Writing Plugins](#writing-plugins)
23
+ - [Support](#support)
24
+
25
+ <!-- /code_chunk_output -->
26
+
27
+ ---
28
+
13
29
  ## Quickstart
14
30
 
15
31
  ```
16
32
  npx pockethost serve
17
33
  ```
18
34
 
35
+ ## Introduction
36
+
37
+ PocketHost is a multitenant PocketBase hosting system. With it, you can run multiple instances of PocketBase on different subdomains, all on the same server.
38
+
39
+ Use PocketHost for development or production purposes.
40
+
41
+ PocketHost can be easily extended using its thoughtful plugin architecture. By choosing additional plugins, PocketHost's features can be extended according to your exact needs. You can even write your own plugins.
42
+
43
+ ## The magic `serve` command
44
+
45
+ `pockethost serve` is a special command that can be decorated with plugins. Plugins can respond to the `serve` command by running their own services.
46
+
47
+ By convention, plugins that have some kind of `serve` functionality such as running a server, will make it available in two ways.
48
+
49
+ The first way runs ONLY the plugin's `serve` functionality:
50
+
51
+ ```bash
52
+ pockethost <plugin-name> serve
53
+ ```
54
+
55
+ The second way runs ALL `serve` functionality from ALL plugins:
56
+
57
+ ```bash
58
+ pockethost serve
59
+ ```
60
+
61
+ The exact plugins can also be narrowed:
62
+
63
+ ```bash
64
+ pockethost serve --only=plugin1,plugin2,plugin3
65
+ ```
66
+
67
+ See the plugin authoring guide for more information on how to make a plugin that responds to both methods.
68
+
19
69
  ## Configuration
20
70
 
21
- PocketHost supports configuration by environment variable. All PocketHost environment variables begin with `PH_`.
71
+ PocketHost supports configuration by environment variable, `.env` file, and also built-in settings via `pockethost config`.
72
+
73
+ All PocketHost variables begin with `PH_`.
22
74
 
23
75
  PocketHost will search the current directory for an `.env` when it loads. Anything in `.env` will be merged with and override any `<PH_HOME>/.env` that may exist.
24
76
 
25
- Use `pockethost config` to set global defaults stored in `<PH_HOME>/.env`.
77
+ Use `pockethost config` to list and set global defaults.
26
78
 
27
- ### Variables
79
+ ### Core Variables
80
+
81
+ See `pockethost config ls` for a full list of variables. Plugin variables will also be listed for loaded plugins.
28
82
 
29
83
  | Name | Default | Discussion |
30
84
  | -------------- | -------------------------- | ----------------------------------------------------------------------------- |
@@ -42,29 +96,33 @@ Use `pockethost config` to set global defaults stored in `<PH_HOME>/.env`.
42
96
  - `@pockethost/plugin-launcher-spawn`
43
97
  - `@pockethost/plugin-auto-admin`
44
98
 
45
- ## Plugins
99
+ ## Plugins Directory
100
+
101
+ PocketHost uses an action/filter architecture to support a growing list plugins. Some plugins have a CLI component, whereas others add purely programmatic support to alter how PocketHost works.
46
102
 
47
- PocketHost uses a hook architecture and features a growing list plugins. Some plugins have a CLI component, whereas others add purely programmatic support to alter how PocketHost works:
103
+ ### Core plugins
48
104
 
49
- Current plugins:
105
+ These plugins are maintained by the PocketHost project.
50
106
 
51
- | name | description |
52
- | -------------------------------- | ------------------------------------------------------------------------------------------------- |
53
- | plugin-console-logger | Routes log messages to the console |
54
- | plugin-auto-admin | Auto-creates a default admin account on instance launch |
55
- | plugin-launcher-spawn | Launches PocketBase instances via `spawn()` on the local machine. PocketHost uses this by default |
56
- | plugin-cloudflare-request-logger | Log additional data when running behind Cloudflare |
107
+ | Name | Description |
108
+ | ---------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------- |
109
+ | `@pockethost/plugin-console-logger` | Routes log messages to the console |
110
+ | `@pockethost/plugin-auto-admin` | Auto-creates a default admin account on instance launch |
111
+ | `@pockethost/plugin-launcher-spawn` | Launches PocketBase instances via `spawn()` on the local machine. PocketHost uses this by default |
112
+ | `@pockethost/plugin-cloudflare-request-logger` | Log additional data when running behind Cloudflare |
113
+ | `@pockethost/plugin-ftp-server` | Used to provide secure FTPS access to PocketBase instance data. This FTP server can run along-side a PocketHost server. |
114
+ | `@pockethost/plugin-local-auth` | A light-weight username/password auth provider for associating instances with users. |
57
115
 
58
116
  Coming soon:
59
117
  | name | description |
60
118
  | ---------------------- | -------------------------------------------------------------------------------------------------------------------------------------- |
61
- | plugin-ftp-server | Used to provide secure FTPS access to PocketBase instance data. This FTP server can run along-side a PocketHost server. |
62
119
  | plugin-launcher-docker | Launches PocketBase instances via Docker. This is useful for running untrusted PocketBase code and instances. pockethost.io uses this. |
63
120
  | plugin-waf | A Web Application Firewall |
64
- | plugin-waf-enforce-ssl | Enforce SSL at the
65
- WAF
121
+ | plugin-waf-enforce-ssl | Enforce SSL at the WAF
122
+
123
+ ## Writing Plugins
66
124
 
67
- See the [Plugin Authoring Guide](https://github.com/pockethost/pockethost/blob/master/packages/pockethost/plugin-guide.md) for details about what hooks and filters are available.
125
+ See the [Plugin Authoring Guide](https://github.com/pockethost/pockethost/blob/master/packages/pockethost/plugin-guide.md) for details about how to write your own plugins.
68
126
 
69
127
  ## Support
70
128
 
@@ -1,20 +1,5 @@
1
- import { forEach, keys, omit } from '@s-libs/micro-dash'
2
1
  import { Command } from 'commander'
3
- import { parse } from 'dotenv'
4
- import { existsSync, readFileSync, writeFileSync } from 'fs'
5
- import { info } from '../..'
6
- import { PH_HOME, isSettingKey, settings } from '../../../constants'
7
-
8
- const envFile = () => {
9
- const envFile = PH_HOME(`.env`)
10
- if (!existsSync(envFile)) {
11
- writeFileSync(envFile, '')
12
- }
13
- return envFile
14
- }
15
-
16
- const _parse = () =>
17
- parse(readFileSync(envFile(), { encoding: 'utf8' }).toString())
2
+ import { listConfig, setConfig, unsetConfig } from '../../../core'
18
3
 
19
4
  export const ConfigCommand = () => {
20
5
  const cmd = new Command(`config`)
@@ -24,76 +9,20 @@ export const ConfigCommand = () => {
24
9
  .argument(`<name>`, `Config name`)
25
10
  .argument(`<value>`, `Config value`)
26
11
  .description(`Set a config value`)
27
- .action((name, value) => {
28
- if (!isSettingKey(name))
29
- throw new Error(`Invalid setting name ${name}`)
30
-
31
- if (value === '=') throw new Error(`Invalid value ${value}`)
32
-
33
- const values = _parse()
34
- values[name] = value
35
- writeFileSync(
36
- envFile(),
37
- Object.entries(values)
38
- .map(([k, v]) => `${k}=${v}`)
39
- .join('\n'),
40
- )
41
- info(`Set ${name}=${value}`)
42
- info(`Written to ${envFile()}`)
43
- }),
12
+ .action(setConfig),
44
13
  )
45
14
 
46
15
  .addCommand(
47
16
  new Command(`unset`)
48
17
  .argument(`<name>`, `Config name`)
49
18
  .description(`Unset a config value`)
50
- .action((name) => {
51
- if (!isSettingKey(name))
52
- throw new Error(`Invalid setting name ${name}`)
53
-
54
- const values = _parse()
55
- delete values[name]
56
- writeFileSync(
57
- envFile(),
58
- Object.entries(values)
59
- .map(([k, v]) => `${k}=${v}`)
60
- .join('\n'),
61
- )
62
- info(`Unset ${name}`)
63
- info(`Written to ${envFile()}`)
64
- }),
19
+ .action(unsetConfig),
65
20
  )
66
21
  .addCommand(
67
22
  new Command(`list`)
68
23
  .description(`List all config values`)
69
24
  .alias(`ls`)
70
- .action(() => {
71
- const values = _parse()
72
-
73
- if (keys(values).length > 0) {
74
- info()
75
- info(`Config values from ${envFile()}:`)
76
- forEach(values, (v, k) => {
77
- info(`\t${k}=${v}`)
78
- })
79
- info()
80
- } else {
81
- info(`No config values found in ${envFile()}`)
82
- }
83
-
84
- const defaults = omit(settings, keys(values) as any)
85
- if (keys(defaults).length > 0) {
86
- info(`Default values:`)
87
- forEach(settings, (v, k) => {
88
- if (k in values) return
89
- info(`\t${k}=${v}`)
90
- })
91
- } else {
92
- info(
93
- `No default values because all values are defined in ${envFile()}`,
94
- )
95
- }
96
- }),
25
+ .action(listConfig),
97
26
  )
98
27
  return cmd
99
28
  }
@@ -1,22 +1,10 @@
1
- import { uniq } from '@s-libs/micro-dash'
2
1
  import { Command } from 'commander'
3
- import { parse } from 'dotenv'
4
- import { existsSync, readFileSync, writeFileSync } from 'fs'
2
+ import { readFileSync } from 'fs'
5
3
  import { error, info } from '../..'
6
- import { PH_HOME, PH_PLUGINS, PH_PROJECT_DIR } from '../../../constants'
4
+ import { PH_PLUGINS, PH_PROJECT_DIR } from '../../../constants'
5
+ import { appendConfig, filterConfig } from '../../../core'
7
6
  import { getCompatibleVersions, getPackageJson, removePackage } from './util'
8
7
 
9
- const envFile = () => {
10
- const envFile = PH_HOME(`.env`)
11
- if (!existsSync(envFile)) {
12
- writeFileSync(envFile, '')
13
- }
14
- return envFile
15
- }
16
-
17
- const _parse = () =>
18
- parse(readFileSync(envFile(), { encoding: 'utf8' }).toString())
19
-
20
8
  export const PluginCommand = () => {
21
9
  const cmd = new Command(`plugin`)
22
10
  .description(`Manage PocketHost plugins`)
@@ -33,22 +21,7 @@ export const PluginCommand = () => {
33
21
  const { version } = pkg
34
22
  await getCompatibleVersions(`pockethost`, version, [name])
35
23
 
36
- const values = _parse()
37
- values[`PH_PLUGINS`] = uniq([
38
- ...(values[`PH_PLUGINS`]
39
- ?.split(/,/)
40
- .map((v) => v.trim())
41
- .filter((v) => !!v) || []),
42
- name,
43
- ]).join(`,`)
44
- writeFileSync(
45
- envFile(),
46
- Object.entries(values)
47
- .map(([k, v]) => `${k}=${v}`)
48
- .join('\n'),
49
- )
50
- info(`Installed ${name}`)
51
- info(`Written to ${envFile()}`)
24
+ appendConfig(`PH_PLUGINS`, name)
52
25
  } catch (e) {
53
26
  error(`${e}`)
54
27
  }
@@ -81,21 +54,7 @@ export const PluginCommand = () => {
81
54
  .action(async (name) => {
82
55
  try {
83
56
  await removePackage(name)
84
- const values = _parse()
85
- values[`PH_PLUGINS`] = uniq([
86
- ...(values[`PH_PLUGINS`]
87
- ?.split(/,/)
88
- .map((v) => v.trim())
89
- .filter((v) => v !== name) || []),
90
- ]).join(`,`)
91
- writeFileSync(
92
- envFile(),
93
- Object.entries(values)
94
- .map(([k, v]) => `${k}=${v}`)
95
- .join('\n'),
96
- )
97
- info(`Removed ${name}`)
98
- info(`Written to ${envFile()}`)
57
+ filterConfig(`PH_PLUGINS`, name)
99
58
  } catch (e) {
100
59
  error(`${e}`)
101
60
  }
package/src/cli/index.ts CHANGED
@@ -10,6 +10,7 @@ import {
10
10
  DEBUG,
11
11
  LogLevelName,
12
12
  LoggerService,
13
+ doAfterPluginsLoadedAction,
13
14
  doCliCommandsFilter,
14
15
  loadPlugins,
15
16
  } from '../common'
@@ -36,13 +37,17 @@ export const main = async () => {
36
37
 
37
38
  const argv = minimist<{ e: string }>(process.argv.slice(2), {
38
39
  alias: { e: 'extra-plugins' },
40
+ default: { e: '' },
39
41
  })
40
42
  const extraPlugins = argv.e
41
43
  .split(/,/)
42
44
  .map((s) => s.trim())
43
45
  .filter((v) => !!v)
46
+
44
47
  await loadPlugins([pockethost, ...uniq(PH_PLUGINS()), ...extraPlugins])
45
48
 
49
+ await doAfterPluginsLoadedAction()
50
+
46
51
  program
47
52
  .name('pockethost')
48
53
  .description('Multitenant PocketBase hosting')
@@ -1,9 +1,12 @@
1
+ import { uniqueId } from '@s-libs/micro-dash'
1
2
  import { Express, Request, Response } from 'express'
3
+ import { dbg } from '../../cli'
2
4
  import { LogLevelName } from '../Logger'
3
5
  import { DEBUG } from '../debug'
4
6
  import { InstanceFields } from '../schema'
5
7
 
6
8
  enum CoreActions {
9
+ AfterPluginsLoaded = 'core_after_plugins_loaded',
7
10
  Init = 'core_init',
8
11
  Serve = 'core_serve',
9
12
  AppMounted = 'core_on_app_mount',
@@ -18,6 +21,8 @@ enum CoreActions {
18
21
  BeforeInstanceStarted = 'core_before_instance_started',
19
22
  AfterInstanceStarted = 'core_after_instance_started',
20
23
 
24
+ KillInstance = 'core_kill_instance',
25
+
21
26
  BeforeInstanceStopped = 'core_before_instance_stopped',
22
27
  AfterInstanceStopped = 'core_after_instance_stopped',
23
28
 
@@ -27,20 +32,34 @@ enum CoreActions {
27
32
  Request = 'core_edge_request',
28
33
  }
29
34
 
30
- const actions: {
31
- [key: string]: ActionHandler<any>[]
32
- } = {}
33
-
34
35
  export type ActionHandler<TContext = {}> = (
35
36
  context: TContext extends never ? [] : TContext,
36
37
  ) => Promise<void>
37
38
 
38
- async function registerAction(
39
+ interface Action {
40
+ priority: number
41
+ handler: ActionHandler<any>
42
+ }
43
+
44
+ const actions: {
45
+ [key: string]: Action[]
46
+ } = {}
47
+
48
+ function registerAction(
39
49
  action: string,
40
50
  handler: (...args: any[]) => Promise<void>,
41
- ) {
51
+ priority: number = 10,
52
+ ): () => void {
42
53
  if (!(action in actions)) actions[action] = []
43
- actions[action]!.push(handler)
54
+ const uid = uniqueId(`a:${action}:`)
55
+ dbg(`${uid}:subscribe`)
56
+ actions[action]!.push({ priority, handler })
57
+ actions[action]!.sort((a, b) => a.priority - b.priority)
58
+
59
+ return () => {
60
+ dbg(`${uid}:unsubscribe`)
61
+ actions[action] = actions[action]!.filter((a) => a.handler !== handler)
62
+ }
44
63
  }
45
64
 
46
65
  async function action(actionName: string, context: any) {
@@ -49,7 +68,9 @@ async function action(actionName: string, context: any) {
49
68
  }
50
69
  const action = actions[actionName]
51
70
  if (!action) return false
52
- await Promise.all(action.map((handler) => handler(context)))
71
+ for (const { handler } of action) {
72
+ await handler(context)
73
+ }
53
74
  return true
54
75
  }
55
76
 
@@ -58,18 +79,22 @@ export function createCustomActionWithContext<TContext extends {}>(
58
79
  ) {
59
80
  return [
60
81
  async (context: TContext) => action(actionName, context),
61
- async (handler: ActionHandler<TContext>) =>
62
- registerAction(actionName, handler),
82
+ (handler: ActionHandler<TContext>, priority = 10) =>
83
+ registerAction(actionName, handler, priority),
63
84
  ] as const
64
85
  }
65
86
 
66
87
  export function createCustomAction(actionName: CoreActions) {
67
88
  return [
68
89
  async () => action(actionName, {}),
69
- async (handler: ActionHandler) => registerAction(actionName, handler),
90
+ (handler: ActionHandler, priority = 10) =>
91
+ registerAction(actionName, handler, priority),
70
92
  ] as const
71
93
  }
72
94
 
95
+ export const [doAfterPluginsLoadedAction, onAfterPluginsLoadedAction] =
96
+ createCustomAction(CoreActions.AfterPluginsLoaded)
97
+
73
98
  export const [doRequestErrorAction, onRequestErrorAction] =
74
99
  createCustomActionWithContext<{
75
100
  err: Error
@@ -92,7 +117,9 @@ export const [doInstanceLogAction, onInstanceLogAction] =
92
117
  }>(CoreActions.InstanceLog)
93
118
 
94
119
  export const [doAppMountedAction, onAppMountedAction] =
95
- createCustomActionWithContext<{ app: Express }>(CoreActions.AppMounted)
120
+ createCustomActionWithContext<{ app: Express; internalApp: Express }>(
121
+ CoreActions.AppMounted,
122
+ )
96
123
 
97
124
  export const [doIncomingRequestAction, onIncomingRequestAction] =
98
125
  createCustomActionWithContext<{ req: Request; res: Response; host: string }>(
@@ -117,6 +144,11 @@ export const [doAfterInstanceStartedAction, onAfterInstanceStartedAction] =
117
144
  CoreActions.AfterInstanceStarted,
118
145
  )
119
146
 
147
+ export const [doKillInstanceAction, onKillInstanceAction] =
148
+ createCustomActionWithContext<{ instance: InstanceFields }>(
149
+ CoreActions.KillInstance,
150
+ )
151
+
120
152
  export const [doBeforeInstanceStoppedAction, onBeforeInstanceStoppedAction] =
121
153
  createCustomActionWithContext<{ instance: InstanceFields; url: string }>(
122
154
  CoreActions.BeforeInstanceStopped,