@openapi-typescript-infra/service 4.4.0 → 4.5.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/.github/workflows/nodejs.yml +39 -3
- package/CHANGELOG.md +14 -0
- package/Makefile +12 -0
- package/build/config/index.d.ts +1 -0
- package/build/config/index.js +1 -0
- package/build/config/index.js.map +1 -1
- package/build/config/schema.d.ts +1 -9
- package/build/config/validation.d.ts +10 -0
- package/build/config/validation.js +12 -0
- package/build/config/validation.js.map +1 -0
- package/build/express-app/app.js +1 -1
- package/build/express-app/app.js.map +1 -1
- package/build/tsconfig.build.tsbuildinfo +1 -1
- package/config/development.json +0 -5
- package/package.json +1 -1
- package/src/config/index.ts +1 -0
- package/src/config/schema.ts +1 -10
- package/src/config/validation.ts +22 -0
- package/src/express-app/app.ts +1 -1
- package/.github/workflows/npmpublish.yml +0 -48
package/config/development.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openapi-typescript-infra/service",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.5.1",
|
|
4
4
|
"description": "An opinionated framework for building configuration driven services - web, api, or ob. Uses OpenAPI, pino logging, express, confit, Typescript and vitest.",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"scripts": {
|
package/src/config/index.ts
CHANGED
package/src/config/schema.ts
CHANGED
|
@@ -1,14 +1,6 @@
|
|
|
1
1
|
import type { BaseConfitSchema } from '@sesamecare-oss/confit';
|
|
2
2
|
import type { Level } from 'pino';
|
|
3
3
|
|
|
4
|
-
export interface ServiceConfiguration {
|
|
5
|
-
protocol?: string;
|
|
6
|
-
port?: number;
|
|
7
|
-
host?: string;
|
|
8
|
-
basePath?: string;
|
|
9
|
-
proxy?: string | false;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
4
|
export interface ConfigurationItemEnabled {
|
|
13
5
|
enabled?: boolean;
|
|
14
6
|
}
|
|
@@ -66,10 +58,9 @@ export interface ConfigurationSchema extends BaseConfitSchema {
|
|
|
66
58
|
// Note that generally it's better to offload tls termination,
|
|
67
59
|
// but this is useful for dev.
|
|
68
60
|
key?: string | Uint8Array;
|
|
69
|
-
certificate?: string;
|
|
61
|
+
certificate?: string | Uint8Array;
|
|
70
62
|
// If you have an alternate host name (other than localhost) that
|
|
71
63
|
// should be used when referring to this service, set it here.
|
|
72
64
|
hostname?: string;
|
|
73
65
|
};
|
|
74
|
-
connections: Record<string, ServiceConfiguration>;
|
|
75
66
|
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ConfigurationSchema } from './schema';
|
|
2
|
+
|
|
3
|
+
export interface ConfigValidationError {
|
|
4
|
+
path: string;
|
|
5
|
+
message: string;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export type ConfigurationValidator<Config extends ConfigurationSchema> = (config: Config) => {
|
|
9
|
+
success: boolean;
|
|
10
|
+
errors: ConfigValidationError[];
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export function validateConfiguration<Config extends ConfigurationSchema>(
|
|
14
|
+
config: Config,
|
|
15
|
+
validator: ConfigurationValidator<Config>,
|
|
16
|
+
) {
|
|
17
|
+
const result = validator(config);
|
|
18
|
+
if (!result.success) {
|
|
19
|
+
throw new Error(`Configuration validation failed:
|
|
20
|
+
${result.errors.map((e) => ` - ${e.path}: ${e.message}`).join('\n')}`);
|
|
21
|
+
}
|
|
22
|
+
}
|
package/src/express-app/app.ts
CHANGED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
name: Node.js Package
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
push:
|
|
5
|
-
branches:
|
|
6
|
-
- main
|
|
7
|
-
|
|
8
|
-
permissions:
|
|
9
|
-
contents: read
|
|
10
|
-
|
|
11
|
-
jobs:
|
|
12
|
-
build:
|
|
13
|
-
runs-on: ubuntu-latest
|
|
14
|
-
steps:
|
|
15
|
-
- uses: actions/checkout@v3
|
|
16
|
-
|
|
17
|
-
- uses: actions/setup-node@v3
|
|
18
|
-
with:
|
|
19
|
-
node-version: 18
|
|
20
|
-
- run: yarn install --immutable
|
|
21
|
-
- run: yarn build
|
|
22
|
-
- run: yarn lint
|
|
23
|
-
- run: yarn test
|
|
24
|
-
|
|
25
|
-
publish-npm:
|
|
26
|
-
needs: build
|
|
27
|
-
permissions:
|
|
28
|
-
contents: write
|
|
29
|
-
issues: write
|
|
30
|
-
id-token: write
|
|
31
|
-
pull-requests: write
|
|
32
|
-
runs-on: ubuntu-latest
|
|
33
|
-
steps:
|
|
34
|
-
- uses: actions/checkout@v1
|
|
35
|
-
|
|
36
|
-
- uses: actions/setup-node@v3
|
|
37
|
-
with:
|
|
38
|
-
node-version: 18
|
|
39
|
-
registry-url: https://registry.npmjs.org/
|
|
40
|
-
- run: yarn install --immutable
|
|
41
|
-
- run: yarn build
|
|
42
|
-
|
|
43
|
-
- name: Release
|
|
44
|
-
env:
|
|
45
|
-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
46
|
-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
47
|
-
run: |
|
|
48
|
-
yarn dlx semantic-release
|