@openapi-typescript-infra/service 4.27.1 → 5.0.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/{.eslintrc.js → .eslintrc.cjs} +1 -1
- package/{.prettierrc.js → .prettierrc.cjs} +1 -1
- package/Makefile +1 -1
- package/build/bin/start-service.js +8 -13
- package/build/bin/start-service.js.map +1 -1
- package/build/bootstrap.d.ts +4 -4
- package/build/bootstrap.js +17 -29
- package/build/bootstrap.js.map +1 -1
- package/build/config/index.d.ts +3 -3
- package/build/config/index.js +15 -36
- package/build/config/index.js.map +1 -1
- package/build/config/schema.js +1 -2
- package/build/config/shortstops.js +19 -25
- package/build/config/shortstops.js.map +1 -1
- package/build/config/validation.d.ts +1 -1
- package/build/config/validation.js +1 -4
- package/build/config/validation.js.map +1 -1
- package/build/development/port-finder.js +6 -12
- package/build/development/port-finder.js.map +1 -1
- package/build/development/repl.d.ts +2 -2
- package/build/development/repl.js +18 -26
- package/build/development/repl.js.map +1 -1
- package/build/env.js +5 -12
- package/build/env.js.map +1 -1
- package/build/error.d.ts +2 -2
- package/build/error.js +1 -5
- package/build/error.js.map +1 -1
- package/build/express-app/app.d.ts +2 -2
- package/build/express-app/app.js +44 -52
- package/build/express-app/app.js.map +1 -1
- package/build/express-app/index.d.ts +3 -3
- package/build/express-app/index.js +3 -19
- package/build/express-app/index.js.map +1 -1
- package/build/express-app/internal-server.d.ts +2 -2
- package/build/express-app/internal-server.js +5 -11
- package/build/express-app/internal-server.js.map +1 -1
- package/build/express-app/modules.d.ts +0 -1
- package/build/express-app/modules.js +6 -24
- package/build/express-app/modules.js.map +1 -1
- package/build/express-app/route-loader.d.ts +2 -2
- package/build/express-app/route-loader.js +10 -16
- package/build/express-app/route-loader.js.map +1 -1
- package/build/express-app/types.d.ts +2 -2
- package/build/express-app/types.js +1 -2
- package/build/hook.d.ts +2 -2
- package/build/hook.js +1 -4
- package/build/hook.js.map +1 -1
- package/build/index.d.ts +9 -9
- package/build/index.js +9 -27
- package/build/index.js.map +1 -1
- package/build/openapi.d.ts +3 -3
- package/build/openapi.js +17 -46
- package/build/openapi.js.map +1 -1
- package/build/telemetry/DummyExporter.js +3 -7
- package/build/telemetry/DummyExporter.js.map +1 -1
- package/build/telemetry/index.d.ts +3 -3
- package/build/telemetry/index.js +22 -51
- package/build/telemetry/index.js.map +1 -1
- package/build/telemetry/instrumentations.js +19 -22
- package/build/telemetry/instrumentations.js.map +1 -1
- package/build/telemetry/requestLogger.d.ts +2 -2
- package/build/telemetry/requestLogger.js +10 -18
- package/build/telemetry/requestLogger.js.map +1 -1
- package/build/tsconfig.build.tsbuildinfo +1 -1
- package/build/types.d.ts +2 -2
- package/build/types.js +1 -2
- package/package.json +14 -13
- package/src/bin/start-service.ts +3 -3
- package/src/bootstrap.ts +12 -17
- package/src/config/index.ts +4 -4
- package/src/config/validation.ts +1 -1
- package/src/development/port-finder.ts +1 -1
- package/src/development/repl.ts +8 -9
- package/src/error.ts +2 -2
- package/src/express-app/app.ts +11 -11
- package/src/express-app/index.ts +3 -3
- package/src/express-app/internal-server.ts +3 -3
- package/src/express-app/modules.ts +4 -22
- package/src/express-app/route-loader.ts +6 -6
- package/src/express-app/types.ts +2 -2
- package/src/hook.ts +2 -2
- package/src/index.ts +9 -9
- package/src/openapi.ts +6 -6
- package/src/telemetry/index.ts +5 -5
- package/src/telemetry/requestLogger.ts +7 -7
- package/src/types.ts +2 -2
- package/tsconfig.json +4 -3
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
const configModule = require('@openapi-typescript-infra/coconfig');
|
|
9
9
|
|
|
10
10
|
const configItem = configModule.default || configModule.config || configModule;
|
|
11
|
-
const { configuration } = configItem && configItem['.eslintrc.
|
|
11
|
+
const { configuration } = configItem && configItem['.eslintrc.cjs'];
|
|
12
12
|
const resolved = typeof configuration === 'function' ? configuration() : configuration;
|
|
13
13
|
|
|
14
14
|
module.exports = resolved;
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
const configModule = require('@openapi-typescript-infra/coconfig');
|
|
9
9
|
|
|
10
10
|
const configItem = configModule.default || configModule.config || configModule;
|
|
11
|
-
const { configuration } = configItem && configItem['.prettierrc.
|
|
11
|
+
const { configuration } = configItem && configItem['.prettierrc.cjs'];
|
|
12
12
|
const resolved = typeof configuration === 'function' ? configuration() : configuration;
|
|
13
13
|
|
|
14
14
|
module.exports = resolved;
|
package/Makefile
CHANGED
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
# all: service dbi ts
|
|
21
21
|
#
|
|
22
22
|
|
|
23
|
-
build_dir := $(shell node -e "console.log(require('./package.json').
|
|
23
|
+
build_dir := $(shell node -e "console.log(require('./package.json').exports.replace(/^.\//, '').split('/')[0])")
|
|
24
24
|
src_files := $(shell find src -name '*.ts')
|
|
25
25
|
build_files := $(patsubst src/%.ts,$(build_dir)/%.js,$(src_files))
|
|
26
26
|
camel_case_name := $(shell echo $(SERVICE_NAME) | awk -F- '{result=""; for(i=1; i<=NF; i++) result = result toupper(substr($$i,1,1)) substr($$i,2); print result}' | tr -d '\n')
|
|
@@ -1,29 +1,24 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
};
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
const minimist_1 = __importDefault(require("minimist"));
|
|
8
|
-
const repl_1 = require("../development/repl");
|
|
9
|
-
const env_1 = require("../env");
|
|
10
|
-
const bootstrap_1 = require("../bootstrap");
|
|
2
|
+
import minimist from 'minimist';
|
|
3
|
+
import { serviceRepl } from '../development/repl.js';
|
|
4
|
+
import { isDev } from '../env.js';
|
|
5
|
+
import { bootstrap } from '../bootstrap.js';
|
|
11
6
|
/**
|
|
12
7
|
* built - forces the use of the build directory. Defaults to true in stage/prod, not in dev
|
|
13
8
|
* repl - launch the REPL (defaults to disabling telemetry)
|
|
14
9
|
* telemetry - whether to use OpenTelemetry. Defaults to false in dev or with repl
|
|
15
10
|
* nobind - do not listen on http port or expose metrics
|
|
16
11
|
*/
|
|
17
|
-
const argv = (
|
|
12
|
+
const argv = minimist(process.argv.slice(2), {
|
|
18
13
|
boolean: ['built', 'repl', 'telemetry', 'nobind'],
|
|
19
14
|
});
|
|
20
|
-
const noTelemetry = (argv.repl ||
|
|
21
|
-
|
|
15
|
+
const noTelemetry = (argv.repl || isDev()) && !argv.telemetry;
|
|
16
|
+
bootstrap({
|
|
22
17
|
...argv,
|
|
23
18
|
telemetry: !noTelemetry,
|
|
24
19
|
}).then(({ app, codepath, server }) => {
|
|
25
20
|
if (argv.repl) {
|
|
26
|
-
|
|
21
|
+
serviceRepl(app, codepath, () => {
|
|
27
22
|
server?.close();
|
|
28
23
|
});
|
|
29
24
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"start-service.js","sourceRoot":"","sources":["../../src/bin/start-service.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"start-service.js","sourceRoot":"","sources":["../../src/bin/start-service.ts"],"names":[],"mappings":";AACA,OAAO,QAAQ,MAAM,UAAU,CAAC;AAEhC,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C;;;;;GAKG;AACH,MAAM,IAAI,GAAG,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE;IAC3C,OAAO,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,QAAQ,CAAC;CAClD,CAAC,CAAC;AAEH,MAAM,WAAW,GAAG,CAAC,IAAI,CAAC,IAAI,IAAI,KAAK,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC;AAC9D,SAAS,CAAC;IACR,GAAG,IAAI;IACP,SAAS,EAAE,CAAC,WAAW;CACxB,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE;IACpC,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;QACd,WAAW,CAAC,GAAG,EAAE,QAAQ,EAAE,GAAG,EAAE;YAC9B,MAAM,EAAE,KAAK,EAAE,CAAC;QAClB,CAAC,CAAC,CAAC;IACL,CAAC;AACH,CAAC,CAAC,CAAC"}
|
package/build/bootstrap.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { AnyServiceLocals, RequestLocals, ServiceLocals } from './types';
|
|
2
|
-
import { ConfigurationSchema } from './config/schema';
|
|
1
|
+
import type { AnyServiceLocals, RequestLocals, ServiceLocals } from './types.js';
|
|
2
|
+
import { ConfigurationSchema } from './config/schema.js';
|
|
3
3
|
interface BootstrapArguments {
|
|
4
4
|
name?: string;
|
|
5
5
|
main?: string;
|
|
@@ -11,12 +11,12 @@ interface BootstrapArguments {
|
|
|
11
11
|
version?: string;
|
|
12
12
|
}
|
|
13
13
|
export declare function bootstrap<SLocals extends AnyServiceLocals = ServiceLocals<ConfigurationSchema>, RLocals extends RequestLocals = RequestLocals>(argv?: BootstrapArguments): Promise<{
|
|
14
|
-
app: import("./types").ServiceExpress<SLocals>;
|
|
14
|
+
app: import("./types.js").ServiceExpress<SLocals>;
|
|
15
15
|
codepath: "build" | "src" | "dist" | undefined;
|
|
16
16
|
server: import("http").Server<typeof import("http").IncomingMessage, typeof import("http").ServerResponse> | import("https").Server<typeof import("http").IncomingMessage, typeof import("http").ServerResponse>;
|
|
17
17
|
} | {
|
|
18
18
|
server: import("http").Server<typeof import("http").IncomingMessage, typeof import("http").ServerResponse> | import("https").Server<typeof import("http").IncomingMessage, typeof import("http").ServerResponse> | undefined;
|
|
19
|
-
app: import("./types").ServiceExpress<SLocals>;
|
|
19
|
+
app: import("./types.js").ServiceExpress<SLocals>;
|
|
20
20
|
codepath: "build" | "src" | "dist";
|
|
21
21
|
}>;
|
|
22
22
|
export {};
|
package/build/bootstrap.js
CHANGED
|
@@ -1,15 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const node_path_1 = __importDefault(require("node:path"));
|
|
8
|
-
const node_assert_1 = __importDefault(require("node:assert"));
|
|
9
|
-
const dotenv_1 = __importDefault(require("dotenv"));
|
|
10
|
-
const read_pkg_up_1 = __importDefault(require("read-pkg-up"));
|
|
11
|
-
const env_1 = require("./env");
|
|
12
|
-
const index_1 = require("./telemetry/index");
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import assert from 'node:assert';
|
|
3
|
+
import { config } from 'dotenv';
|
|
4
|
+
import { readPackageUp } from 'read-package-up';
|
|
5
|
+
import { isDev } from './env.js';
|
|
6
|
+
import { startWithTelemetry } from './telemetry/index.js';
|
|
13
7
|
function resolveMain(packageJson) {
|
|
14
8
|
if (typeof packageJson.main === 'string') {
|
|
15
9
|
return packageJson.main;
|
|
@@ -22,11 +16,11 @@ async function getServiceDetails(argv = {}) {
|
|
|
22
16
|
rootDirectory: argv.root,
|
|
23
17
|
name: argv.name,
|
|
24
18
|
version: argv.version || '0.0.0',
|
|
25
|
-
main: argv.main || (
|
|
19
|
+
main: argv.main || (isDev() && !argv.built ? 'src/index.ts' : 'build/index.js'),
|
|
26
20
|
};
|
|
27
21
|
}
|
|
28
|
-
const cwd = argv.packageDir ?
|
|
29
|
-
const pkg = await (
|
|
22
|
+
const cwd = argv.packageDir ? path.resolve(argv.packageDir) : process.cwd();
|
|
23
|
+
const pkg = await readPackageUp({ cwd });
|
|
30
24
|
if (!pkg) {
|
|
31
25
|
throw new Error(`Unable to find package.json in ${cwd} to get main module. Make sure you are running from the package root directory.`);
|
|
32
26
|
}
|
|
@@ -34,34 +28,28 @@ async function getServiceDetails(argv = {}) {
|
|
|
34
28
|
const parts = pkg.packageJson.name.split('/');
|
|
35
29
|
return {
|
|
36
30
|
main,
|
|
37
|
-
rootDirectory:
|
|
31
|
+
rootDirectory: path.dirname(pkg.path),
|
|
38
32
|
name: parts[parts.length - 1],
|
|
39
33
|
version: pkg.packageJson.version,
|
|
40
34
|
};
|
|
41
35
|
}
|
|
42
36
|
function getBuildDir(main) {
|
|
43
37
|
const dir = /^(?:\.?\/?)(build|dist)\//.exec(main);
|
|
44
|
-
(
|
|
38
|
+
assert(dir, 'Could not determine build directory - should be dist or build');
|
|
45
39
|
return dir[1];
|
|
46
40
|
}
|
|
47
41
|
// Automagically start your app by using common patterns
|
|
48
42
|
// to find your implementation and settings. This is most useful
|
|
49
43
|
// for jobs or other scripts that need service infra but are
|
|
50
44
|
// not simply the service
|
|
51
|
-
async function bootstrap(argv) {
|
|
45
|
+
export async function bootstrap(argv) {
|
|
52
46
|
const { main, rootDirectory, name, version } = await getServiceDetails(argv);
|
|
53
47
|
let entrypoint;
|
|
54
48
|
let codepath = 'build';
|
|
55
|
-
if (
|
|
49
|
+
if (isDev() && argv?.built !== true) {
|
|
56
50
|
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
57
51
|
const { register } = await import('ts-node');
|
|
58
52
|
register();
|
|
59
|
-
try {
|
|
60
|
-
require('tsconfig-paths/register');
|
|
61
|
-
}
|
|
62
|
-
catch (error) {
|
|
63
|
-
// No action needed
|
|
64
|
-
}
|
|
65
53
|
if (main) {
|
|
66
54
|
entrypoint = main.replace(/^(\.?\/?)(build|dist)\//, '$1src/').replace(/\.js$/, '.ts');
|
|
67
55
|
}
|
|
@@ -77,10 +65,10 @@ async function bootstrap(argv) {
|
|
|
77
65
|
else {
|
|
78
66
|
entrypoint = './build/index.js';
|
|
79
67
|
}
|
|
80
|
-
|
|
81
|
-
const absoluteEntrypoint =
|
|
68
|
+
config();
|
|
69
|
+
const absoluteEntrypoint = path.resolve(rootDirectory, entrypoint);
|
|
82
70
|
if (argv?.telemetry) {
|
|
83
|
-
return
|
|
71
|
+
return startWithTelemetry({
|
|
84
72
|
name,
|
|
85
73
|
rootDirectory,
|
|
86
74
|
service: absoluteEntrypoint,
|
|
@@ -90,7 +78,7 @@ async function bootstrap(argv) {
|
|
|
90
78
|
}
|
|
91
79
|
// This needs to be required for TS on-the-fly to work
|
|
92
80
|
// eslint-disable-next-line global-require, import/no-dynamic-require, @typescript-eslint/no-var-requires
|
|
93
|
-
const impl =
|
|
81
|
+
const impl = await import(absoluteEntrypoint);
|
|
94
82
|
const opts = {
|
|
95
83
|
name,
|
|
96
84
|
version,
|
package/build/bootstrap.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bootstrap.js","sourceRoot":"","sources":["../src/bootstrap.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"bootstrap.js","sourceRoot":"","sources":["../src/bootstrap.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,MAAM,MAAM,aAAa,CAAC;AAEjC,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAIhD,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACjC,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAsB1D,SAAS,WAAW,CAAC,WAAkC;IACrD,IAAI,OAAO,WAAW,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;QACzC,OAAO,WAAW,CAAC,IAAI,CAAC;IAC1B,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,KAAK,UAAU,iBAAiB,CAAC,OAA2B,EAAE;IAC5D,IAAI,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;QAC3B,OAAO;YACL,aAAa,EAAE,IAAI,CAAC,IAAI;YACxB,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,OAAO,EAAE,IAAI,CAAC,OAAO,IAAI,OAAO;YAChC,IAAI,EAAE,IAAI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OAAO;QACrC,QAAQ;KACT,CAAC;IACF,gDAAgD;IAChD,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,MAAM,MAAM,CAAC,sBAAsB,CAAC,CAAC;IAClE,MAAM,GAAG,GAAG,MAAM,QAAQ,CAAmB,IAAI,CAAC,CAAC;IACnD,MAAM,MAAM,GAAG,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,MAAM,CAAC,GAAG,CAAC,CAAC;IAC5D,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,QAAQ,EAAE,CAAC;AACnC,CAAC"}
|
package/build/config/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { ShortstopHandler } from '@sesamecare-oss/confit';
|
|
2
|
-
import type { ConfigurationSchema } from './schema';
|
|
2
|
+
import type { ConfigurationSchema } from './schema.js';
|
|
3
3
|
export interface ServiceConfigurationSpec {
|
|
4
4
|
configurationDirectories: string[];
|
|
5
5
|
shortstopHandlers: Record<string, ShortstopHandler<string, unknown>>;
|
|
6
6
|
}
|
|
7
7
|
export declare function loadConfiguration<Config extends ConfigurationSchema>({ configurationDirectories: dirs, shortstopHandlers, }: ServiceConfigurationSpec): Promise<Config>;
|
|
8
8
|
export declare function insertConfigurationBefore(configDirs: string[] | undefined, insert: string, before: string): string[];
|
|
9
|
-
export * from './schema';
|
|
10
|
-
export * from './validation';
|
|
9
|
+
export * from './schema.js';
|
|
10
|
+
export * from './validation.js';
|
package/build/config/index.js
CHANGED
|
@@ -1,33 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
17
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
|
-
};
|
|
19
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
exports.loadConfiguration = loadConfiguration;
|
|
21
|
-
exports.insertConfigurationBefore = insertConfigurationBefore;
|
|
22
|
-
const fs_1 = __importDefault(require("fs"));
|
|
23
|
-
const path_1 = __importDefault(require("path"));
|
|
24
|
-
const confit_1 = require("@sesamecare-oss/confit");
|
|
25
|
-
const port_finder_1 = require("../development/port-finder");
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { confit, } from '@sesamecare-oss/confit';
|
|
4
|
+
import { getAvailablePort } from '../development/port-finder.js';
|
|
26
5
|
// Order matters here.
|
|
27
6
|
const ENVIRONMENTS = ['production', 'staging', 'test', 'development'];
|
|
28
7
|
async function pathExists(f) {
|
|
29
8
|
return new Promise((accept, reject) => {
|
|
30
|
-
|
|
9
|
+
fs.stat(f, (err) => {
|
|
31
10
|
if (!err) {
|
|
32
11
|
accept(true);
|
|
33
12
|
}
|
|
@@ -42,7 +21,7 @@ async function pathExists(f) {
|
|
|
42
21
|
}
|
|
43
22
|
async function addDefaultConfiguration(configFactory, directory, envConfit) {
|
|
44
23
|
const addIfEnv = async (e) => {
|
|
45
|
-
const c =
|
|
24
|
+
const c = path.join(directory, `${e}.json`);
|
|
46
25
|
if (envConfit.get().env[e] && (await pathExists(c))) {
|
|
47
26
|
configFactory.addDefault(c);
|
|
48
27
|
return true;
|
|
@@ -50,16 +29,16 @@ async function addDefaultConfiguration(configFactory, directory, envConfit) {
|
|
|
50
29
|
return false;
|
|
51
30
|
};
|
|
52
31
|
await ENVIRONMENTS.reduce((runningPromise, environment) => runningPromise.then((prev) => prev || addIfEnv(environment)), Promise.resolve(false));
|
|
53
|
-
const baseConfig =
|
|
32
|
+
const baseConfig = path.join(directory, 'config.json');
|
|
54
33
|
if (await pathExists(baseConfig)) {
|
|
55
34
|
configFactory.addDefault(baseConfig);
|
|
56
35
|
}
|
|
57
36
|
}
|
|
58
|
-
async function loadConfiguration({ configurationDirectories: dirs, shortstopHandlers, }) {
|
|
37
|
+
export async function loadConfiguration({ configurationDirectories: dirs, shortstopHandlers, }) {
|
|
59
38
|
const specificConfig = dirs[dirs.length - 1];
|
|
60
39
|
// This confit version just gets us environment info
|
|
61
|
-
const envConfit = await
|
|
62
|
-
const configFactory =
|
|
40
|
+
const envConfit = await confit({ basedir: specificConfig }).create();
|
|
41
|
+
const configFactory = confit({
|
|
63
42
|
basedir: specificConfig,
|
|
64
43
|
protocols: shortstopHandlers,
|
|
65
44
|
});
|
|
@@ -69,14 +48,14 @@ async function loadConfiguration({ configurationDirectories: dirs, shortstopHand
|
|
|
69
48
|
* if you override this method, you should register your defaults first.
|
|
70
49
|
*/
|
|
71
50
|
const defaultOrder = dirs.slice(0, dirs.length - 1).reverse();
|
|
72
|
-
defaultOrder.push(
|
|
51
|
+
defaultOrder.push(path.join(__dirname, '../..', 'config'));
|
|
73
52
|
await defaultOrder.reduce((promise, dir) => promise.then(() => addDefaultConfiguration(configFactory, dir, envConfit)), Promise.resolve());
|
|
74
53
|
const loaded = await configFactory.create();
|
|
75
54
|
// Because other things need to know the port we choose, we pick it here if it's
|
|
76
55
|
// configured to auto-select
|
|
77
56
|
const serverConfig = loaded.get().server;
|
|
78
57
|
if (serverConfig.port === 0) {
|
|
79
|
-
const port = await
|
|
58
|
+
const port = await getAvailablePort(8001);
|
|
80
59
|
const store = loaded.get();
|
|
81
60
|
store.server = store.server || {};
|
|
82
61
|
store.server.port = port;
|
|
@@ -86,7 +65,7 @@ async function loadConfiguration({ configurationDirectories: dirs, shortstopHand
|
|
|
86
65
|
// Not sure why this is necessary, but it is
|
|
87
66
|
return loaded.get();
|
|
88
67
|
}
|
|
89
|
-
function insertConfigurationBefore(configDirs, insert, before) {
|
|
68
|
+
export function insertConfigurationBefore(configDirs, insert, before) {
|
|
90
69
|
const copy = [...(configDirs || [])];
|
|
91
70
|
const index = copy.indexOf(before);
|
|
92
71
|
if (index === -1) {
|
|
@@ -97,6 +76,6 @@ function insertConfigurationBefore(configDirs, insert, before) {
|
|
|
97
76
|
}
|
|
98
77
|
return copy;
|
|
99
78
|
}
|
|
100
|
-
|
|
101
|
-
|
|
79
|
+
export * from './schema.js';
|
|
80
|
+
export * from './validation.js';
|
|
102
81
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAKL,MAAM,GACP,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAIjE,sBAAsB;AACtB,MAAM,YAAY,GAAG,CAAC,YAAY,EAAE,SAAS,EAAE,MAAM,EAAE,aAAa,CAAU,CAAC;AAE/E,KAAK,UAAU,UAAU,CAAC,CAAS;IACjC,OAAO,IAAI,OAAO,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE;QACpC,EAAE,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,GAAG,EAAE,EAAE;YACjB,IAAI,CAAC,GAAG,EAAE,CAAC;gBACT,MAAM,CAAC,IAAI,CAAC,CAAC;YACf,CAAC;iBAAM,IAAI,GAAG,CAAC,IAAI,KAAK,QAAQ,EAAE,CA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AG,EAAE,CAAC;AACtB,CAAC;AAED,MAAM,UAAU,yBAAyB,CACvC,UAAgC,EAChC,MAAc,EACd,MAAc;IAEd,MAAM,IAAI,GAAG,CAAC,GAAG,CAAC,UAAU,IAAI,EAAE,CAAC,CAAC,CAAC;IACrC,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IACnC,IAAI,KAAK,KAAK,CAAC,CAAC,EAAE,CAAC;QACjB,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC5B,CAAC;SAAM,CAAC;QACN,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC;IAChC,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC"}
|
package/build/config/schema.js
CHANGED
|
@@ -1,12 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.shortstops = shortstops;
|
|
7
|
-
const os_1 = __importDefault(require("os"));
|
|
8
|
-
const path_1 = __importDefault(require("path"));
|
|
9
|
-
const confit_1 = require("@sesamecare-oss/confit");
|
|
1
|
+
import os from 'os';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { base64Handler, envHandler, fileHandler, pathHandler, requireHandler, yamlHandler, } from '@sesamecare-oss/confit';
|
|
10
4
|
/**
|
|
11
5
|
* Default shortstop handlers for GasBuddy service configuration
|
|
12
6
|
*/
|
|
@@ -15,7 +9,7 @@ const confit_1 = require("@sesamecare-oss/confit");
|
|
|
15
9
|
* with a url-like hash pattern
|
|
16
10
|
*/
|
|
17
11
|
function betterRequire(basepath) {
|
|
18
|
-
const baseRequire =
|
|
12
|
+
const baseRequire = requireHandler(basepath);
|
|
19
13
|
return function hashRequire(v) {
|
|
20
14
|
const [moduleName, func] = v.split('#');
|
|
21
15
|
const module = baseRequire(moduleName);
|
|
@@ -32,10 +26,10 @@ function betterRequire(basepath) {
|
|
|
32
26
|
* Just like path, but resolve ~/ to the home directory
|
|
33
27
|
*/
|
|
34
28
|
function betterPath(basepath) {
|
|
35
|
-
const basePath =
|
|
29
|
+
const basePath = pathHandler(basepath);
|
|
36
30
|
return function pathWithHomeDir(v) {
|
|
37
31
|
if (v.startsWith('~/')) {
|
|
38
|
-
return basePath(
|
|
32
|
+
return basePath(path.join(os.homedir(), v.slice(2)));
|
|
39
33
|
}
|
|
40
34
|
return basePath(v);
|
|
41
35
|
};
|
|
@@ -44,10 +38,10 @@ function betterPath(basepath) {
|
|
|
44
38
|
* Just like file, but resolve ~/ to the home directory
|
|
45
39
|
*/
|
|
46
40
|
function betterFile(basepath) {
|
|
47
|
-
const baseFile =
|
|
41
|
+
const baseFile = fileHandler(basepath);
|
|
48
42
|
return function fileWithHomeDir(v) {
|
|
49
43
|
if (v.startsWith('~/')) {
|
|
50
|
-
return baseFile(
|
|
44
|
+
return baseFile(path.join(os.homedir(), v.slice(2)));
|
|
51
45
|
}
|
|
52
46
|
return baseFile(v);
|
|
53
47
|
};
|
|
@@ -84,18 +78,18 @@ function serviceTypeFactory(name) {
|
|
|
84
78
|
};
|
|
85
79
|
}
|
|
86
80
|
const osMethods = {
|
|
87
|
-
hostname:
|
|
88
|
-
platform:
|
|
89
|
-
type:
|
|
90
|
-
version:
|
|
81
|
+
hostname: os.hostname,
|
|
82
|
+
platform: os.platform,
|
|
83
|
+
type: os.type,
|
|
84
|
+
version: os.version,
|
|
91
85
|
};
|
|
92
|
-
function shortstops(service, sourcedir) {
|
|
86
|
+
export function shortstops(service, sourcedir) {
|
|
93
87
|
/**
|
|
94
88
|
* Since we use transpiled sources a lot,
|
|
95
89
|
* basedir and sourcedir are meaningfully different reference points.
|
|
96
90
|
*/
|
|
97
|
-
const basedir =
|
|
98
|
-
const env =
|
|
91
|
+
const basedir = path.join(sourcedir, '..');
|
|
92
|
+
const env = envHandler();
|
|
99
93
|
return {
|
|
100
94
|
env,
|
|
101
95
|
// A version of env that can default to false
|
|
@@ -106,7 +100,7 @@ function shortstops(service, sourcedir) {
|
|
|
106
100
|
}
|
|
107
101
|
return !!env(v);
|
|
108
102
|
},
|
|
109
|
-
base64:
|
|
103
|
+
base64: base64Handler(),
|
|
110
104
|
regex(v) {
|
|
111
105
|
const [, pattern, flags] = v.match(/^\/(.*)\/([a-z]*)$/) || [];
|
|
112
106
|
if (pattern === undefined) {
|
|
@@ -116,13 +110,13 @@ function shortstops(service, sourcedir) {
|
|
|
116
110
|
},
|
|
117
111
|
// handle source and base directory intelligently
|
|
118
112
|
path: betterPath(basedir),
|
|
119
|
-
sourcepath:
|
|
113
|
+
sourcepath: pathHandler(sourcedir),
|
|
120
114
|
file: betterFile(basedir),
|
|
121
|
-
sourcefile:
|
|
115
|
+
sourcefile: fileHandler(sourcedir),
|
|
122
116
|
require: betterRequire(basedir),
|
|
123
117
|
sourcerequire: betterRequire(sourcedir),
|
|
124
118
|
// Sometimes yaml is more pleasant for configuration
|
|
125
|
-
yaml:
|
|
119
|
+
yaml: yamlHandler(basedir),
|
|
126
120
|
// Switch on service type
|
|
127
121
|
servicetype: serviceTypeFactory(service.name),
|
|
128
122
|
servicename: (v) => v.replace(/\$\{name\}/g, service.name),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shortstops.js","sourceRoot":"","sources":["../../src/config/shortstops.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"shortstops.js","sourceRoot":"","sources":["../../src/config/shortstops.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EACL,aAAa,EACb,UAAU,EACV,WAAW,EACX,WAAW,EACX,cAAc,EACd,WAAW,GAEZ,MAAM,wBAAwB,CAAC;AAEhC;;GAEG;AAEH;;;GAGG;AACH,SAAS,aAAa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,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,aAAa,EAAE,OAAO,CAAC,IAAI,CAAC;QAElE,EAAE,CAAC,CAAyB;YAC1B,OAAO,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC;QACxB,CAAC;QACD,qFAAqF;QACrF,OAAO,CAAC,CAAS;YACf,OAAO,CAAC,CAAC;QACX,CAAC;KACmD,CAAC;AACzD,CAAC"}
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.validateConfiguration = validateConfiguration;
|
|
4
|
-
function validateConfiguration(config, validator) {
|
|
1
|
+
export function validateConfiguration(config, validator) {
|
|
5
2
|
const result = validator(config);
|
|
6
3
|
if (!result.success) {
|
|
7
4
|
throw new Error(`Configuration validation failed:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validation.js","sourceRoot":"","sources":["../../src/config/validation.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"validation.js","sourceRoot":"","sources":["../../src/config/validation.ts"],"names":[],"mappings":"AAYA,MAAM,UAAU,qBAAqB,CACnC,MAAc,EACd,SAAyC;IAEzC,MAAM,MAAM,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC;IACjC,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QACpB,MAAM,IAAI,KAAK,CAAC;EAClB,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACtE,CAAC;AACH,CAAC"}
|
|
@@ -1,15 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getAvailablePort = getAvailablePort;
|
|
7
|
-
const net_1 = __importDefault(require("net"));
|
|
8
|
-
const env_1 = require("../env");
|
|
1
|
+
import net from 'net';
|
|
2
|
+
import { isTest } from '../env.js';
|
|
9
3
|
// Inspired by https://github.com/kessler/find-port/blob/master/lib/findPort.js
|
|
10
4
|
async function isAvailable(port) {
|
|
11
5
|
return new Promise((accept, reject) => {
|
|
12
|
-
const server =
|
|
6
|
+
const server = net.createServer().listen(port);
|
|
13
7
|
const timeoutRef = setTimeout(() => {
|
|
14
8
|
accept(false);
|
|
15
9
|
}, 2000);
|
|
@@ -40,7 +34,7 @@ async function findPort(start) {
|
|
|
40
34
|
}
|
|
41
35
|
async function getEphemeralPort() {
|
|
42
36
|
return new Promise((resolve, reject) => {
|
|
43
|
-
const server =
|
|
37
|
+
const server = net.createServer();
|
|
44
38
|
server.listen(0, () => {
|
|
45
39
|
const address = server.address();
|
|
46
40
|
if (typeof address === 'string' || !address) {
|
|
@@ -59,7 +53,7 @@ async function getEphemeralPort() {
|
|
|
59
53
|
});
|
|
60
54
|
});
|
|
61
55
|
}
|
|
62
|
-
async function getAvailablePort(basePort) {
|
|
63
|
-
return (
|
|
56
|
+
export async function getAvailablePort(basePort) {
|
|
57
|
+
return (isTest() || process.env.TEST_RUNNER) ? getEphemeralPort() : findPort(basePort);
|
|
64
58
|
}
|
|
65
59
|
//# sourceMappingURL=port-finder.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"port-finder.js","sourceRoot":"","sources":["../../src/development/port-finder.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"port-finder.js","sourceRoot":"","sources":["../../src/development/port-finder.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,KAAK,CAAC;AAEtB,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAEnC,+EAA+E;AAC/E,KAAK,UAAU,WAAW,CAAC,IAAY;IACrC,OAAO,IAAI,OAAO,CAAC,C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MAAM,CAAC,CAAC,EAAE,GAAG,EAAE;YACpB,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,EAAE,CAAC;YACjC,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,CAAC,OAAO,EAAE,CAAC;gBAC5C,MAAM,CAAC,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC,CAAC;gBACrC,OAAO;YACT,CAAC;YACD,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,8BAA8B;YACzD,MAAM,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;gBACnB,IAAI,GAAG,EAAE,CAAC;oBACR,MAAM,CAAC,GAAG,CAAC,CAAC;gBACd,CAAC;qBAAM,CAAC;oBACN,OAAO,CAAC,IAAI,CAAC,CAAC;gBAChB,CAAC;YACH,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,QAAgB;IACrD,OAAO,CAAC,MAAM,EAAE,IAAI,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,gBAAgB,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;AACzF,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { AnyServiceLocals, ServiceExpress, ServiceLocals } from '../types';
|
|
2
|
-
import { ConfigurationSchema } from '../config/schema';
|
|
1
|
+
import { AnyServiceLocals, ServiceExpress, ServiceLocals } from '../types.js';
|
|
2
|
+
import { ConfigurationSchema } from '../config/schema.js';
|
|
3
3
|
export declare function serviceRepl<SLocals extends AnyServiceLocals = ServiceLocals<ConfigurationSchema>>(app: ServiceExpress<SLocals>, codepath: string | undefined, onExit: () => void): void;
|
|
4
4
|
type ReplAny = any;
|
|
5
5
|
/**
|