@karmaniverous/smoz 0.1.8 → 0.2.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/README.md +28 -4
- package/dist/cli/index.cjs +282 -122
- package/package.json +5 -8
- package/templates/{minimal → default}/app/config/app.config.ts +50 -50
- package/templates/{minimal → default}/app/config/openapi.ts +45 -45
- package/templates/{full → default}/app/functions/rest/hello/get/handler.ts +18 -18
- package/templates/{full → default}/app/functions/rest/hello/get/lambda.ts +28 -28
- package/templates/{minimal → default}/app/functions/rest/hello/get/openapi.ts +23 -23
- package/templates/{minimal → default}/app/functions/rest/openapi/get/handler.ts +22 -22
- package/templates/{minimal → default}/app/functions/rest/openapi/get/lambda.ts +29 -29
- package/templates/{full → default}/app/functions/rest/openapi/get/openapi.ts +20 -20
- package/templates/{project → default}/eslint.config.ts +6 -15
- package/templates/default/package.json +44 -0
- package/templates/default/serverless.ts +113 -0
- package/templates/default/tsconfig.eslint.json +13 -0
- package/templates/{minimal → default}/types/registers.d.ts +11 -11
- package/templates/.check/eslint.minimal.config.ts +0 -41
- package/templates/.check/eslint.templates.config.ts +0 -60
- package/templates/.check/tsconfig.eslintconfig.json +0 -6
- package/templates/.check/tsconfig.minimal.json +0 -14
- package/templates/.manifests/package.full.json +0 -22
- package/templates/.manifests/package.minimal.json +0 -22
- package/templates/.manifests/package.project.json +0 -24
- package/templates/full/app/config/app.config.ts +0 -50
- package/templates/full/app/config/openapi.ts +0 -44
- package/templates/full/app/functions/rest/hello/get/openapi.ts +0 -19
- package/templates/full/app/functions/rest/openapi/get/handler.ts +0 -20
- package/templates/full/app/functions/rest/openapi/get/lambda.ts +0 -29
- package/templates/full/app/functions/sqs/tick/handler.ts +0 -7
- package/templates/full/app/functions/sqs/tick/lambda.ts +0 -24
- package/templates/full/app/functions/sqs/tick/serverless.ts +0 -8
- package/templates/full/serverless.ts +0 -33
- package/templates/full/tsconfig.json +0 -25
- package/templates/full/types/registers.d.ts +0 -11
- package/templates/minimal/app/functions/rest/hello/get/handler.ts +0 -18
- package/templates/minimal/app/functions/rest/hello/get/lambda.ts +0 -28
- package/templates/minimal/app/functions/rest/openapi/get/openapi.ts +0 -20
- package/templates/minimal/app/generated/openapi.json +0 -8
- package/templates/minimal/serverless.ts +0 -34
- package/templates/minimal/tsconfig.json +0 -25
- /package/templates/{project → default}/.prettierrc.json +0 -0
- /package/templates/{project → default}/.vscode/extensions.json +0 -0
- /package/templates/{project → default}/.vscode/settings.json +0 -0
- /package/templates/{project → default}/README.md +0 -0
- /package/templates/{full → default}/app/generated/openapi.json +0 -0
- /package/templates/{project → default}/gitignore +0 -0
- /package/templates/{project → default}/test/smoke.test.ts +0 -0
- /package/templates/{project → default}/tsconfig.base.json +0 -0
- /package/templates/{project → default}/tsconfig.json +0 -0
- /package/templates/{project → default}/tsdoc.json +0 -0
- /package/templates/{project → default}/typedoc.json +0 -0
- /package/templates/{project → default}/vitest.config.ts +0 -0
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import type { AWS } from '@serverless/typescript';
|
|
2
|
+
|
|
3
|
+
import { app } from '@/app/config/app.config';
|
|
4
|
+
/**
|
|
5
|
+
* Template note:
|
|
6
|
+
* - Templates do NOT commit generated register files under app/generated; they
|
|
7
|
+
* are declared via ambient types (templates/minimal/types/registers.d.ts) so
|
|
8
|
+
* TypeScript can typecheck without artifacts.
|
|
9
|
+
* - To ensure side effects still run (endpoint/serverless registration) and to
|
|
10
|
+
* satisfy noUncheckedSideEffectImports, import register modules as namespaces
|
|
11
|
+
* and reference them via `void`.
|
|
12
|
+
* - In real apps, `smoz init` seeds placeholders and `smoz register` rewrites
|
|
13
|
+
* app/generated/register.*.ts at author time.
|
|
14
|
+
*/
|
|
15
|
+
import * as __register_functions from '@/app/generated/register.functions';
|
|
16
|
+
import * as __register_serverless from '@/app/generated/register.serverless';
|
|
17
|
+
void __register_functions;
|
|
18
|
+
void __register_serverless;
|
|
19
|
+
|
|
20
|
+
const config: AWS = {
|
|
21
|
+
service: '${param:SERVICE_NAME}',
|
|
22
|
+
frameworkVersion: '4',
|
|
23
|
+
plugins: [
|
|
24
|
+
'serverless-apigateway-log-retention',
|
|
25
|
+
'serverless-deployment-bucket',
|
|
26
|
+
'serverless-domain-manager',
|
|
27
|
+
'serverless-plugin-common-excludes',
|
|
28
|
+
'serverless-offline',
|
|
29
|
+
],
|
|
30
|
+
package: {
|
|
31
|
+
individually: true,
|
|
32
|
+
patterns: ['!**/?(*.)test.+(!(.))'],
|
|
33
|
+
},
|
|
34
|
+
custom: {
|
|
35
|
+
apiGatewayLogRetention: {
|
|
36
|
+
accessLogging: {
|
|
37
|
+
enabled: true,
|
|
38
|
+
days: 5,
|
|
39
|
+
},
|
|
40
|
+
executionLogging: {
|
|
41
|
+
enabled: false,
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
customDomain: {
|
|
45
|
+
autoDomain: true,
|
|
46
|
+
basePath: '',
|
|
47
|
+
certificateArn: '${param:DOMAIN_CERTIFICATE_ARN}',
|
|
48
|
+
domainName: '${param:DOMAIN_NAME}',
|
|
49
|
+
preserveExternalPathMappings: true,
|
|
50
|
+
},
|
|
51
|
+
deploymentBucket: {
|
|
52
|
+
accelerate: true,
|
|
53
|
+
blockPublicAccess: true,
|
|
54
|
+
},
|
|
55
|
+
// Local emulation defaults (serverless-offline)
|
|
56
|
+
'serverless-offline': {
|
|
57
|
+
httpPort: 3000,
|
|
58
|
+
noPrependStageInUrl: true,
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
stages: app.stages as NonNullable<AWS['stages']>,
|
|
62
|
+
provider: {
|
|
63
|
+
apiGateway: {
|
|
64
|
+
apiKeys: ['${param:SERVICE_NAME}-${param:STAGE}'],
|
|
65
|
+
disableDefaultEndpoint: true,
|
|
66
|
+
},
|
|
67
|
+
apiName: '${param:SERVICE_NAME}',
|
|
68
|
+
deploymentBucket: {
|
|
69
|
+
name: '${param:SERVICE_NAME}-deployment',
|
|
70
|
+
serverSideEncryption: 'AES256',
|
|
71
|
+
},
|
|
72
|
+
deploymentMethod: 'direct',
|
|
73
|
+
endpointType: 'edge',
|
|
74
|
+
environment: app.environment as NonNullable<AWS['provider']['environment']>,
|
|
75
|
+
iam: {
|
|
76
|
+
role: {
|
|
77
|
+
managedPolicies: [
|
|
78
|
+
'arn:aws:iam::aws:policy/CloudWatchLambdaInsightsExecutionRolePolicy',
|
|
79
|
+
],
|
|
80
|
+
statements: [{ Effect: 'Allow', Action: '*', Resource: '*' }],
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
logRetentionInDays: 5,
|
|
84
|
+
logs: {
|
|
85
|
+
lambda: { applicationLogLevel: 'DEBUG', logFormat: 'JSON' },
|
|
86
|
+
restApi: {
|
|
87
|
+
accessLogging: true,
|
|
88
|
+
executionLogging: false,
|
|
89
|
+
format:
|
|
90
|
+
'{ "accountId": "$context.accountId", "apiId": "$context.apiId", "domainName": "$context.domainName", "domainPrefix": "$context.domainPrefix", "error": { "message": "$context.error.message", "responseType": "$context.error.responseType" }, "extendedRequestId": "$context.extendedRequestId", "httpMethod": "$context.httpMethod", "identity" { "accountId": "$context.identity.accountId", "apiKey": "$context.identity.apiKey", "caller": "$context.identity.caller", "clientCert": { "clientCertPem": "$context.identity.clientCert.clientCertPem", "subjectDN": "$context.identity.clientCert.subjectDN", "issuerDN": "$context.identity.clientCert.issuerDN", "serialNumber": "$context.identity.clientCert.serialNumber", "validity": { "notBefore": "$context.identity.clientCert.validity.notBefore", "notAfter": "$context.identity.clientCert.validity.notAfter" } }, "sourceIp": "$context.identity.sourceIp", "user": "$context.identity.user", "userArn": "$context.identity.userArn", "userAgent": "$context.identity.userAgent", }, "integration": { "latency": "$context.integration.latency" }, "path": "$context.path", "protocol": "$context.protocol", "requestId": "$context.requestId", "requestTime": "$context.requestTime", "requestTimeEpoch": "$context.requestTimeEpoch", "resourceId": "$context.resourceId", "resourcePath": "$context.resourcePath", "stage": "$context.stage", "responseLatency": "$context.responseLatency", "responseLength": "$context.responseLength", "status": "$context.status" }',
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
memorySize: 256,
|
|
94
|
+
name: 'aws',
|
|
95
|
+
region: '${param:REGION}' as NonNullable<AWS['provider']['region']>,
|
|
96
|
+
runtime: 'nodejs22.x',
|
|
97
|
+
profile: '${param:PROFILE}',
|
|
98
|
+
stackName: '${param:SERVICE_NAME}-${param:STAGE}',
|
|
99
|
+
stackTags: {
|
|
100
|
+
service: '${param:SERVICE_NAME}',
|
|
101
|
+
stage: '${param:STAGE}',
|
|
102
|
+
},
|
|
103
|
+
stage: '${opt:stage, "dev"}',
|
|
104
|
+
tracing: {
|
|
105
|
+
apiGateway: true,
|
|
106
|
+
lambda: true,
|
|
107
|
+
},
|
|
108
|
+
versionFunctions: false,
|
|
109
|
+
},
|
|
110
|
+
functions: app.buildAllServerlessFunctions() as NonNullable<AWS['functions']>,
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
export default config;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
// Ambient declarations to satisfy template typechecking without requiring
|
|
2
|
-
// generated register files to exist on disk.
|
|
3
|
-
declare module '@/app/generated/register.functions' {
|
|
4
|
-
export {};
|
|
5
|
-
}
|
|
6
|
-
declare module '@/app/generated/register.openapi' {
|
|
7
|
-
export {};
|
|
8
|
-
}
|
|
9
|
-
declare module '@/app/generated/register.serverless' {
|
|
10
|
-
export {};
|
|
11
|
-
}
|
|
1
|
+
// Ambient declarations to satisfy template typechecking without requiring
|
|
2
|
+
// generated register files to exist on disk.
|
|
3
|
+
declare module '@/app/generated/register.functions' {
|
|
4
|
+
export {};
|
|
5
|
+
}
|
|
6
|
+
declare module '@/app/generated/register.openapi' {
|
|
7
|
+
export {};
|
|
8
|
+
}
|
|
9
|
+
declare module '@/app/generated/register.serverless' {
|
|
10
|
+
export {};
|
|
11
|
+
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import eslint from '@eslint/js';
|
|
2
|
-
import prettierConfig from 'eslint-config-prettier';
|
|
3
|
-
import prettierPlugin from 'eslint-plugin-prettier';
|
|
4
|
-
import simpleImportSortPlugin from 'eslint-plugin-simple-import-sort';
|
|
5
|
-
import tseslint from 'typescript-eslint';
|
|
6
|
-
import { dirname } from 'path';
|
|
7
|
-
import { fileURLToPath } from 'url';
|
|
8
|
-
|
|
9
|
-
const tsconfigRootDir = dirname(fileURLToPath(import.meta.url));
|
|
10
|
-
|
|
11
|
-
export default tseslint.config(
|
|
12
|
-
{ ignores: [
|
|
13
|
-
'**/node_modules/**',
|
|
14
|
-
'**/dist/**',
|
|
15
|
-
'**/.tsbuild/**',
|
|
16
|
-
],
|
|
17
|
-
},
|
|
18
|
-
eslint.configs.recommended,
|
|
19
|
-
tseslint.configs.strictTypeChecked,
|
|
20
|
-
prettierConfig,
|
|
21
|
-
{
|
|
22
|
-
languageOptions: {
|
|
23
|
-
parser: tseslint.parser,
|
|
24
|
-
parserOptions: {
|
|
25
|
-
project: ['./tsconfig.minimal.json'],
|
|
26
|
-
tsconfigRootDir,
|
|
27
|
-
},
|
|
28
|
-
},
|
|
29
|
-
plugins: { prettier: prettierPlugin,
|
|
30
|
-
'simple-import-sort': simpleImportSortPlugin,
|
|
31
|
-
},
|
|
32
|
-
rules: {
|
|
33
|
-
'@typescript-eslint/consistent-type-imports': 'error',
|
|
34
|
-
'@typescript-eslint/no-unused-expressions': 'off',
|
|
35
|
-
'@typescript-eslint/no-unused-vars': 'error',
|
|
36
|
-
'no-unused-vars': 'off',
|
|
37
|
-
'simple-import-sort/imports': 'error',
|
|
38
|
-
'simple-import-sort/exports': 'error',
|
|
39
|
-
},
|
|
40
|
-
},
|
|
41
|
-
);
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import eslint from '@eslint/js';
|
|
2
|
-
import prettierConfig from 'eslint-config-prettier';
|
|
3
|
-
import prettierPlugin from 'eslint-plugin-prettier';
|
|
4
|
-
import simpleImportSortPlugin from 'eslint-plugin-simple-import-sort';
|
|
5
|
-
import { dirname } from 'path';
|
|
6
|
-
import tseslint from 'typescript-eslint';
|
|
7
|
-
import { fileURLToPath } from 'url';
|
|
8
|
-
|
|
9
|
-
// Unified ESLint config for all templates under templates/*
|
|
10
|
-
// - Uses projectService so type info is picked up from each template's tsconfig.json
|
|
11
|
-
// - ESLint drives Prettier via 'prettier/prettier': 'error'
|
|
12
|
-
const tsconfigRootDir = dirname(fileURLToPath(import.meta.url));
|
|
13
|
-
|
|
14
|
-
export default [
|
|
15
|
-
{
|
|
16
|
-
ignores: [
|
|
17
|
-
'**/node_modules/**',
|
|
18
|
-
'**/dist/**',
|
|
19
|
-
'**/.tsbuild/**',
|
|
20
|
-
'**/generated/**',
|
|
21
|
-
'**/.check/**',
|
|
22
|
-
],
|
|
23
|
-
},
|
|
24
|
-
eslint.configs.recommended,
|
|
25
|
-
...tseslint.configs.strictTypeChecked,
|
|
26
|
-
prettierConfig,
|
|
27
|
-
{
|
|
28
|
-
languageOptions: {
|
|
29
|
-
parser: tseslint.parser,
|
|
30
|
-
parserOptions: {
|
|
31
|
-
// Let the project service discover the nearest tsconfig.json per file
|
|
32
|
-
// (typed where possible; falls back to default project when unmatched).
|
|
33
|
-
project: true,
|
|
34
|
-
projectService: true,
|
|
35
|
-
allowDefaultProject: true,
|
|
36
|
-
tsconfigRootDir,
|
|
37
|
-
},
|
|
38
|
-
},
|
|
39
|
-
plugins: {
|
|
40
|
-
prettier: prettierPlugin,
|
|
41
|
-
'simple-import-sort': simpleImportSortPlugin,
|
|
42
|
-
},
|
|
43
|
-
rules: {
|
|
44
|
-
// Formatting via Prettier
|
|
45
|
-
'prettier/prettier': 'error',
|
|
46
|
-
// Code-quality and sorting
|
|
47
|
-
'@typescript-eslint/consistent-type-imports': 'error',
|
|
48
|
-
'@typescript-eslint/no-empty-object-type': 'off',
|
|
49
|
-
'@typescript-eslint/no-unused-expressions': 'off',
|
|
50
|
-
'@typescript-eslint/no-unused-vars': 'error',
|
|
51
|
-
'no-unused-vars': 'off',
|
|
52
|
-
'simple-import-sort/imports': 'error',
|
|
53
|
-
'simple-import-sort/exports': 'error',
|
|
54
|
-
// Keep strictness reasonable for templates
|
|
55
|
-
'@typescript-eslint/no-unsafe-assignment': 'error',
|
|
56
|
-
'@typescript-eslint/no-unsafe-member-access': 'error',
|
|
57
|
-
'@typescript-eslint/no-unsafe-return': 'error',
|
|
58
|
-
},
|
|
59
|
-
},
|
|
60
|
-
];
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "../project/tsconfig.base.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"rootDir": "../../templates/minimal",
|
|
5
|
-
"baseUrl": "../../templates/minimal",
|
|
6
|
-
"paths": {
|
|
7
|
-
"@/*": ["*"],
|
|
8
|
-
"@karmaniverous/smoz": ["../../.stan/dist/index.d.ts"]
|
|
9
|
-
},
|
|
10
|
-
"types": ["node"]
|
|
11
|
-
}, "include": [
|
|
12
|
-
"../../templates/minimal/**/*.ts"
|
|
13
|
-
]
|
|
14
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"dependencies": {
|
|
3
|
-
"@middy/core": "^6.4.4",
|
|
4
|
-
"zod": "^4.1.5"
|
|
5
|
-
},
|
|
6
|
-
"devDependencies": {
|
|
7
|
-
"eslint": "^9.34.0",
|
|
8
|
-
"eslint-config-prettier": "^10.1.8",
|
|
9
|
-
"eslint-plugin-prettier": "^5.5.4",
|
|
10
|
-
"eslint-plugin-simple-import-sort": "^12.1.1",
|
|
11
|
-
"jiti": "^2.5.1",
|
|
12
|
-
"typedoc": "^0.28.11",
|
|
13
|
-
"typescript": "^5.9.2",
|
|
14
|
-
"typescript-eslint": "^8.41.0",
|
|
15
|
-
"vitest": "^3.2.4"
|
|
16
|
-
},
|
|
17
|
-
"scripts": {
|
|
18
|
-
"lint": "eslint .",
|
|
19
|
-
"lint:fix": "eslint --fix .",
|
|
20
|
-
"typecheck": "tsc -p tsconfig.json --noEmit"
|
|
21
|
-
}
|
|
22
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"dependencies": {
|
|
3
|
-
"@middy/core": "^6.4.4",
|
|
4
|
-
"zod": "^4.1.5"
|
|
5
|
-
},
|
|
6
|
-
"devDependencies": {
|
|
7
|
-
"eslint": "^9.34.0",
|
|
8
|
-
"eslint-config-prettier": "^10.1.8",
|
|
9
|
-
"eslint-plugin-prettier": "^5.5.4",
|
|
10
|
-
"eslint-plugin-simple-import-sort": "^12.1.1",
|
|
11
|
-
"jiti": "^2.5.1",
|
|
12
|
-
"typescript": "^5.9.2",
|
|
13
|
-
"typescript-eslint": "^8.41.0",
|
|
14
|
-
"vitest": "^3.2.4"
|
|
15
|
-
},
|
|
16
|
-
"scripts": {
|
|
17
|
-
"lint": "eslint .",
|
|
18
|
-
"lint:fix": "eslint --fix .",
|
|
19
|
-
"test": "vitest run",
|
|
20
|
-
"typecheck": "tsc -p tsconfig.json --noEmit"
|
|
21
|
-
}
|
|
22
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"dependencies": {
|
|
3
|
-
"@middy/core": "^6.4.4",
|
|
4
|
-
"zod": "^4.1.5"
|
|
5
|
-
},
|
|
6
|
-
"devDependencies": {
|
|
7
|
-
"eslint": "^9.34.0",
|
|
8
|
-
"eslint-config-prettier": "^10.1.8",
|
|
9
|
-
"eslint-plugin-prettier": "^5.5.4",
|
|
10
|
-
"eslint-plugin-simple-import-sort": "^12.1.1",
|
|
11
|
-
"jiti": "^2.5.1",
|
|
12
|
-
"typedoc": "^0.28.11",
|
|
13
|
-
"typescript": "^5.9.2",
|
|
14
|
-
"typescript-eslint": "^8.41.0",
|
|
15
|
-
"vitest": "^3.2.4"
|
|
16
|
-
},
|
|
17
|
-
"scripts": {
|
|
18
|
-
"docs": "typedoc",
|
|
19
|
-
"lint": "eslint .",
|
|
20
|
-
"lint:fix": "eslint --fix .",
|
|
21
|
-
"test": "vitest run",
|
|
22
|
-
"typecheck": "tsc -p tsconfig.json --noEmit"
|
|
23
|
-
}
|
|
24
|
-
}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { join } from 'node:path';
|
|
2
|
-
import { fileURLToPath } from 'node:url';
|
|
3
|
-
|
|
4
|
-
import { App, baseEventTypeMapSchema, toPosixPath } from '@karmaniverous/smoz';
|
|
5
|
-
import { z } from 'zod';
|
|
6
|
-
|
|
7
|
-
// Derive the app root as the parent directory of app/config/
|
|
8
|
-
export const APP_ROOT_ABS = toPosixPath(
|
|
9
|
-
fileURLToPath(new URL('..', import.meta.url)),
|
|
10
|
-
);
|
|
11
|
-
|
|
12
|
-
export const app = App.create({
|
|
13
|
-
appRootAbs: APP_ROOT_ABS,
|
|
14
|
-
globalParamsSchema: z.object({
|
|
15
|
-
PROFILE: z.string(),
|
|
16
|
-
REGION: z.string(),
|
|
17
|
-
SERVICE_NAME: z.string(),
|
|
18
|
-
}),
|
|
19
|
-
stageParamsSchema: z.object({
|
|
20
|
-
STAGE: z.string(),
|
|
21
|
-
}),
|
|
22
|
-
eventTypeMapSchema: baseEventTypeMapSchema,
|
|
23
|
-
serverless: {
|
|
24
|
-
httpContextEventMap: {
|
|
25
|
-
my: {}, // place a Cognito authorizer here if needed
|
|
26
|
-
private: { private: true },
|
|
27
|
-
public: {},
|
|
28
|
-
},
|
|
29
|
-
defaultHandlerFileName: 'handler',
|
|
30
|
-
defaultHandlerFileExport: 'handler',
|
|
31
|
-
},
|
|
32
|
-
global: {
|
|
33
|
-
params: {
|
|
34
|
-
PROFILE: 'dev',
|
|
35
|
-
REGION: 'us-east-1',
|
|
36
|
-
SERVICE_NAME: 'my-smoz-app',
|
|
37
|
-
},
|
|
38
|
-
envKeys: ['REGION', 'SERVICE_NAME'] as const,
|
|
39
|
-
},
|
|
40
|
-
stage: {
|
|
41
|
-
params: {
|
|
42
|
-
dev: { STAGE: 'dev' },
|
|
43
|
-
},
|
|
44
|
-
envKeys: ['STAGE'] as const,
|
|
45
|
-
},
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
export const ENDPOINTS_ROOT_REST = toPosixPath(
|
|
49
|
-
join(APP_ROOT_ABS, 'functions', 'rest'),
|
|
50
|
-
);
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import * as path from 'node:path';
|
|
2
|
-
|
|
3
|
-
import * as fs from 'fs-extra';
|
|
4
|
-
import { packageDirectorySync } from 'pkg-dir';
|
|
5
|
-
import { createDocument } from 'zod-openapi';
|
|
6
|
-
|
|
7
|
-
import { app } from '@/app/config/app.config';
|
|
8
|
-
/**
|
|
9
|
-
* Template note:
|
|
10
|
-
* - Templates do NOT commit generated register files under app/generated; they
|
|
11
|
-
* are declared via ambient types so TypeScript can typecheck without artifacts.
|
|
12
|
-
* - To ensure side effects still run (endpoint registration) and to satisfy
|
|
13
|
-
* noUncheckedSideEffectImports, import the register module as a namespace and
|
|
14
|
-
* reference it via `void`.
|
|
15
|
-
* - In real apps, `smoz init` seeds placeholders and `smoz register` rewrites
|
|
16
|
-
* app/generated/register.*.ts at author time.
|
|
17
|
-
*/
|
|
18
|
-
import * as __register_openapi from '@/app/generated/register.openapi';
|
|
19
|
-
void __register_openapi;
|
|
20
|
-
console.log('Generating OpenAPI document...');
|
|
21
|
-
|
|
22
|
-
const paths = app.buildAllOpenApiPaths();
|
|
23
|
-
export const doc = createDocument({
|
|
24
|
-
openapi: '3.1.0',
|
|
25
|
-
servers: [{ description: 'Dev', url: 'http://localhost' }],
|
|
26
|
-
info: {
|
|
27
|
-
title: process.env.npm_package_name ?? 'smoz-app',
|
|
28
|
-
version: process.env.npm_package_version ?? '0.0.0',
|
|
29
|
-
},
|
|
30
|
-
paths,
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
const pkgDir = packageDirectorySync();
|
|
34
|
-
if (!pkgDir) {
|
|
35
|
-
throw new Error('Could not resolve package root directory');
|
|
36
|
-
}
|
|
37
|
-
const outDir = path.join(pkgDir, 'app', 'generated');
|
|
38
|
-
fs.ensureDirSync(outDir);
|
|
39
|
-
fs.writeFileSync(
|
|
40
|
-
path.join(outDir, 'openapi.json'),
|
|
41
|
-
JSON.stringify(doc, null, 2),
|
|
42
|
-
);
|
|
43
|
-
|
|
44
|
-
console.log('Done!');
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { fn, responseSchema } from './lambda';
|
|
2
|
-
|
|
3
|
-
type FnOpenApiApi = {
|
|
4
|
-
openapi: (op: unknown) => void;
|
|
5
|
-
};
|
|
6
|
-
|
|
7
|
-
const reg = fn as unknown as FnOpenApiApi;
|
|
8
|
-
|
|
9
|
-
reg.openapi({
|
|
10
|
-
summary: 'Hello',
|
|
11
|
-
description: 'Return a simple OK payload.',
|
|
12
|
-
responses: {
|
|
13
|
-
200: {
|
|
14
|
-
description: 'Ok',
|
|
15
|
-
content: { 'application/json': { schema: responseSchema } },
|
|
16
|
-
},
|
|
17
|
-
},
|
|
18
|
-
tags: ['public'],
|
|
19
|
-
});
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import type { z } from 'zod';
|
|
2
|
-
|
|
3
|
-
import openapiDoc from '@/app/generated/openapi.json';
|
|
4
|
-
|
|
5
|
-
import type { responseSchema } from './lambda';
|
|
6
|
-
import { fn } from './lambda';
|
|
7
|
-
|
|
8
|
-
type Response = z.infer<typeof responseSchema>;
|
|
9
|
-
|
|
10
|
-
type FnHandlerApi<T> = {
|
|
11
|
-
handler: (impl: () => Promise<T> | T) => (...args: unknown[]) => Promise<T>;
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
const reg = fn as unknown as FnHandlerApi<Response>;
|
|
15
|
-
|
|
16
|
-
export const handler = reg.handler(async () => {
|
|
17
|
-
// Trivial await to mirror minimal template style
|
|
18
|
-
await Promise.resolve();
|
|
19
|
-
return openapiDoc as Response;
|
|
20
|
-
});
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { join } from 'node:path';
|
|
2
|
-
|
|
3
|
-
import { toPosixPath } from '@karmaniverous/smoz';
|
|
4
|
-
import { z } from 'zod';
|
|
5
|
-
|
|
6
|
-
import { app, APP_ROOT_ABS } from '@/app/config/app.config';
|
|
7
|
-
|
|
8
|
-
export const eventSchema = z.any().optional();
|
|
9
|
-
export const responseSchema = z.unknown();
|
|
10
|
-
|
|
11
|
-
type FnApi = {
|
|
12
|
-
handler: <T>(
|
|
13
|
-
impl: () => Promise<T> | T,
|
|
14
|
-
) => (...args: unknown[]) => Promise<T>;
|
|
15
|
-
openapi: (op: unknown) => void;
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
export const fn = app.defineFunction({
|
|
19
|
-
functionName: 'openapi_get',
|
|
20
|
-
eventType: 'rest',
|
|
21
|
-
httpContexts: ['public'],
|
|
22
|
-
method: 'get',
|
|
23
|
-
basePath: 'openapi',
|
|
24
|
-
contentType: 'application/json',
|
|
25
|
-
eventSchema,
|
|
26
|
-
responseSchema,
|
|
27
|
-
callerModuleUrl: import.meta.url,
|
|
28
|
-
endpointsRootAbs: toPosixPath(join(APP_ROOT_ABS, 'functions', 'rest')),
|
|
29
|
-
}) as unknown as FnApi;
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { join } from 'node:path';
|
|
2
|
-
|
|
3
|
-
import { toPosixPath } from '@karmaniverous/smoz';
|
|
4
|
-
import { z } from 'zod';
|
|
5
|
-
|
|
6
|
-
import { app, APP_ROOT_ABS } from '@/app/config/app.config';
|
|
7
|
-
|
|
8
|
-
export const eventSchema = z.any();
|
|
9
|
-
export const responseSchema = z.void();
|
|
10
|
-
|
|
11
|
-
type FnApi = {
|
|
12
|
-
handler: <T>(
|
|
13
|
-
impl: (e: unknown) => Promise<T> | T,
|
|
14
|
-
) => (...args: unknown[]) => Promise<T>;
|
|
15
|
-
serverless: (extras: unknown) => void;
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
export const fn = app.defineFunction({
|
|
19
|
-
eventType: 'sqs',
|
|
20
|
-
eventSchema,
|
|
21
|
-
responseSchema,
|
|
22
|
-
callerModuleUrl: import.meta.url,
|
|
23
|
-
endpointsRootAbs: toPosixPath(join(APP_ROOT_ABS, 'functions', 'sqs')),
|
|
24
|
-
}) as unknown as FnApi;
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import type { AWS } from '@serverless/typescript';
|
|
2
|
-
|
|
3
|
-
import { app } from '@/app/config/app.config';
|
|
4
|
-
/**
|
|
5
|
-
* Template note:
|
|
6
|
-
* - Templates do NOT commit generated register files under app/generated; they
|
|
7
|
-
* are declared via ambient types so TypeScript can typecheck without artifacts.
|
|
8
|
-
* - To ensure side effects still run (endpoint/serverless registration) and to
|
|
9
|
-
* satisfy noUncheckedSideEffectImports, import register modules as namespaces
|
|
10
|
-
* and reference them via `void`.
|
|
11
|
-
* - In real apps, `smoz init` seeds placeholders and `smoz register` rewrites
|
|
12
|
-
* app/generated/register.*.ts at author time.
|
|
13
|
-
*/
|
|
14
|
-
import * as __register_functions from '@/app/generated/register.functions';
|
|
15
|
-
import * as __register_serverless from '@/app/generated/register.serverless';
|
|
16
|
-
void __register_functions;
|
|
17
|
-
void __register_serverless;
|
|
18
|
-
|
|
19
|
-
const config: AWS = {
|
|
20
|
-
service: '${param:SERVICE_NAME}',
|
|
21
|
-
frameworkVersion: '4',
|
|
22
|
-
stages: app.stages as NonNullable<AWS['stages']>,
|
|
23
|
-
provider: {
|
|
24
|
-
name: 'aws',
|
|
25
|
-
region: '${param:REGION}' as NonNullable<AWS['provider']['region']>,
|
|
26
|
-
runtime: 'nodejs22.x',
|
|
27
|
-
environment: app.environment as NonNullable<AWS['provider']['environment']>,
|
|
28
|
-
stage: '${opt:stage, "dev"}',
|
|
29
|
-
},
|
|
30
|
-
functions: app.buildAllServerlessFunctions() as NonNullable<AWS['functions']>,
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
export default config;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"baseUrl": ".",
|
|
4
|
-
"rootDir": ".",
|
|
5
|
-
"outDir": ".tsbuild",
|
|
6
|
-
"paths": {
|
|
7
|
-
"@/*": ["*"],
|
|
8
|
-
"@karmaniverous/smoz": ["../../.stan/dist/index.d.ts"]
|
|
9
|
-
},
|
|
10
|
-
"typeRoots": ["../../node_modules/@types", "./node_modules/@types"],
|
|
11
|
-
"tsBuildInfoFile": ".tsbuild/tsconfig.tsbuildinfo"
|
|
12
|
-
},
|
|
13
|
-
"exclude": [
|
|
14
|
-
".serverless/**",
|
|
15
|
-
"node_modules/**",
|
|
16
|
-
"app/generated/**",
|
|
17
|
-
"dist/**"
|
|
18
|
-
],
|
|
19
|
-
"extends": "../project/tsconfig.base.json",
|
|
20
|
-
"include": [
|
|
21
|
-
"**/*.ts",
|
|
22
|
-
"**/*.tsx",
|
|
23
|
-
"**/*.d.ts"
|
|
24
|
-
]
|
|
25
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
// Ambient declarations to satisfy template typechecking without requiring
|
|
2
|
-
// generated register files to exist on disk.
|
|
3
|
-
declare module '@/app/generated/register.functions' {
|
|
4
|
-
export {};
|
|
5
|
-
}
|
|
6
|
-
declare module '@/app/generated/register.openapi' {
|
|
7
|
-
export {};
|
|
8
|
-
}
|
|
9
|
-
declare module '@/app/generated/register.serverless' {
|
|
10
|
-
export {};
|
|
11
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { z } from 'zod';
|
|
2
|
-
|
|
3
|
-
import type { responseSchema } from './lambda';
|
|
4
|
-
import { fn } from './lambda';
|
|
5
|
-
|
|
6
|
-
type Response = z.infer<typeof responseSchema>;
|
|
7
|
-
|
|
8
|
-
type FnHandlerApi<T> = {
|
|
9
|
-
handler: (impl: () => Promise<T> | T) => (...args: unknown[]) => Promise<T>;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
const reg = fn as unknown as FnHandlerApi<Response>;
|
|
13
|
-
|
|
14
|
-
export const handler = reg.handler(async () => {
|
|
15
|
-
const res: Response = { ok: true };
|
|
16
|
-
await Promise.resolve(); // satisfy require-await without adding complexity
|
|
17
|
-
return res;
|
|
18
|
-
});
|