@geekmidas/cli 0.9.0 → 0.12.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/README.md +525 -0
- package/dist/bundler-DRXCw_YR.mjs +70 -0
- package/dist/bundler-DRXCw_YR.mjs.map +1 -0
- package/dist/bundler-WsEvH_b2.cjs +71 -0
- package/dist/bundler-WsEvH_b2.cjs.map +1 -0
- package/dist/{config-CFls09Ey.cjs → config-AmInkU7k.cjs} +10 -8
- package/dist/config-AmInkU7k.cjs.map +1 -0
- package/dist/{config-Bq72aj8e.mjs → config-DYULeEv8.mjs} +6 -4
- package/dist/config-DYULeEv8.mjs.map +1 -0
- package/dist/config.cjs +1 -1
- package/dist/config.d.cts +2 -1
- package/dist/config.d.cts.map +1 -0
- package/dist/config.d.mts +2 -1
- package/dist/config.d.mts.map +1 -0
- package/dist/config.mjs +1 -1
- package/dist/encryption-C8H-38Yy.mjs +42 -0
- package/dist/encryption-C8H-38Yy.mjs.map +1 -0
- package/dist/encryption-Dyf_r1h-.cjs +44 -0
- package/dist/encryption-Dyf_r1h-.cjs.map +1 -0
- package/dist/index.cjs +2125 -184
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +2143 -197
- package/dist/index.mjs.map +1 -1
- package/dist/{openapi--vOy9mo4.mjs → openapi-BfFlOBCG.mjs} +812 -49
- package/dist/openapi-BfFlOBCG.mjs.map +1 -0
- package/dist/{openapi-CHhTPief.cjs → openapi-Bt_1FDpT.cjs} +805 -42
- package/dist/openapi-Bt_1FDpT.cjs.map +1 -0
- package/dist/{openapi-react-query-o5iMi8tz.cjs → openapi-react-query-B-sNWHFU.cjs} +5 -5
- package/dist/openapi-react-query-B-sNWHFU.cjs.map +1 -0
- package/dist/{openapi-react-query-CcciaVu5.mjs → openapi-react-query-B6XTeGqS.mjs} +5 -5
- package/dist/openapi-react-query-B6XTeGqS.mjs.map +1 -0
- package/dist/openapi-react-query.cjs +1 -1
- package/dist/openapi-react-query.d.cts.map +1 -0
- package/dist/openapi-react-query.d.mts.map +1 -0
- package/dist/openapi-react-query.mjs +1 -1
- package/dist/openapi.cjs +2 -2
- package/dist/openapi.d.cts +1 -1
- package/dist/openapi.d.cts.map +1 -0
- package/dist/openapi.d.mts +1 -1
- package/dist/openapi.d.mts.map +1 -0
- package/dist/openapi.mjs +2 -2
- package/dist/storage-BUYQJgz7.cjs +4 -0
- package/dist/storage-BXoJvmv2.cjs +149 -0
- package/dist/storage-BXoJvmv2.cjs.map +1 -0
- package/dist/storage-C9PU_30f.mjs +101 -0
- package/dist/storage-C9PU_30f.mjs.map +1 -0
- package/dist/storage-DLJAYxzJ.mjs +3 -0
- package/dist/{types-b-vwGpqc.d.cts → types-BR0M2v_c.d.mts} +100 -1
- package/dist/types-BR0M2v_c.d.mts.map +1 -0
- package/dist/{types-DXgiA1sF.d.mts → types-BhkZc-vm.d.cts} +100 -1
- package/dist/types-BhkZc-vm.d.cts.map +1 -0
- package/examples/cron-example.ts +27 -27
- package/examples/env.ts +27 -27
- package/examples/function-example.ts +31 -31
- package/examples/gkm.config.json +20 -20
- package/examples/gkm.config.ts +8 -8
- package/examples/gkm.minimal.config.json +5 -5
- package/examples/gkm.production.config.json +25 -25
- package/examples/logger.ts +2 -2
- package/package.json +6 -6
- package/src/__tests__/EndpointGenerator.hooks.spec.ts +191 -191
- package/src/__tests__/config.spec.ts +55 -55
- package/src/__tests__/loadEnvFiles.spec.ts +93 -93
- package/src/__tests__/normalizeHooksConfig.spec.ts +58 -58
- package/src/__tests__/openapi-react-query.spec.ts +497 -497
- package/src/__tests__/openapi.spec.ts +428 -428
- package/src/__tests__/test-helpers.ts +77 -76
- package/src/auth/__tests__/credentials.spec.ts +204 -0
- package/src/auth/__tests__/index.spec.ts +168 -0
- package/src/auth/credentials.ts +187 -0
- package/src/auth/index.ts +226 -0
- package/src/build/__tests__/index-new.spec.ts +474 -474
- package/src/build/__tests__/manifests.spec.ts +333 -333
- package/src/build/bundler.ts +141 -0
- package/src/build/endpoint-analyzer.ts +236 -0
- package/src/build/handler-templates.ts +1253 -0
- package/src/build/index.ts +250 -179
- package/src/build/manifests.ts +52 -52
- package/src/build/providerResolver.ts +145 -145
- package/src/build/types.ts +64 -43
- package/src/config.ts +39 -37
- package/src/deploy/__tests__/docker.spec.ts +111 -0
- package/src/deploy/__tests__/dokploy.spec.ts +245 -0
- package/src/deploy/__tests__/init.spec.ts +662 -0
- package/src/deploy/docker.ts +128 -0
- package/src/deploy/dokploy.ts +204 -0
- package/src/deploy/index.ts +136 -0
- package/src/deploy/init.ts +484 -0
- package/src/deploy/types.ts +48 -0
- package/src/dev/__tests__/index.spec.ts +266 -266
- package/src/dev/index.ts +647 -593
- package/src/docker/__tests__/compose.spec.ts +531 -0
- package/src/docker/__tests__/templates.spec.ts +280 -0
- package/src/docker/compose.ts +273 -0
- package/src/docker/index.ts +230 -0
- package/src/docker/templates.ts +446 -0
- package/src/generators/CronGenerator.ts +72 -72
- package/src/generators/EndpointGenerator.ts +699 -398
- package/src/generators/FunctionGenerator.ts +84 -84
- package/src/generators/Generator.ts +72 -72
- package/src/generators/OpenApiTsGenerator.ts +589 -589
- package/src/generators/SubscriberGenerator.ts +124 -124
- package/src/generators/__tests__/CronGenerator.spec.ts +433 -433
- package/src/generators/__tests__/EndpointGenerator.spec.ts +532 -382
- package/src/generators/__tests__/FunctionGenerator.spec.ts +244 -244
- package/src/generators/__tests__/SubscriberGenerator.spec.ts +397 -382
- package/src/generators/index.ts +4 -4
- package/src/index.ts +628 -206
- package/src/init/__tests__/generators.spec.ts +334 -334
- package/src/init/__tests__/init.spec.ts +332 -332
- package/src/init/__tests__/utils.spec.ts +89 -89
- package/src/init/generators/config.ts +175 -175
- package/src/init/generators/docker.ts +41 -41
- package/src/init/generators/env.ts +72 -72
- package/src/init/generators/index.ts +1 -1
- package/src/init/generators/models.ts +64 -64
- package/src/init/generators/monorepo.ts +161 -161
- package/src/init/generators/package.ts +71 -71
- package/src/init/generators/source.ts +6 -6
- package/src/init/index.ts +203 -208
- package/src/init/templates/api.ts +115 -115
- package/src/init/templates/index.ts +75 -75
- package/src/init/templates/minimal.ts +98 -98
- package/src/init/templates/serverless.ts +89 -89
- package/src/init/templates/worker.ts +98 -98
- package/src/init/utils.ts +54 -56
- package/src/openapi-react-query.ts +194 -194
- package/src/openapi.ts +63 -63
- package/src/secrets/__tests__/encryption.spec.ts +226 -0
- package/src/secrets/__tests__/generator.spec.ts +319 -0
- package/src/secrets/__tests__/index.spec.ts +91 -0
- package/src/secrets/__tests__/storage.spec.ts +403 -0
- package/src/secrets/encryption.ts +91 -0
- package/src/secrets/generator.ts +164 -0
- package/src/secrets/index.ts +383 -0
- package/src/secrets/storage.ts +134 -0
- package/src/secrets/types.ts +53 -0
- package/src/types.ts +295 -176
- package/tsconfig.json +9 -0
- package/tsdown.config.ts +11 -8
- package/dist/config-Bq72aj8e.mjs.map +0 -1
- package/dist/config-CFls09Ey.cjs.map +0 -1
- package/dist/openapi--vOy9mo4.mjs.map +0 -1
- package/dist/openapi-CHhTPief.cjs.map +0 -1
- package/dist/openapi-react-query-CcciaVu5.mjs.map +0 -1
- package/dist/openapi-react-query-o5iMi8tz.cjs.map +0 -1
package/src/types.ts
CHANGED
|
@@ -1,239 +1,358 @@
|
|
|
1
1
|
export type MainProvider = 'aws' | 'server';
|
|
2
2
|
export type LegacyProvider =
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
| 'server'
|
|
4
|
+
| 'aws-apigatewayv1'
|
|
5
|
+
| 'aws-apigatewayv2'
|
|
6
|
+
| 'aws-lambda';
|
|
7
7
|
|
|
8
8
|
export type Routes = string | string[];
|
|
9
9
|
|
|
10
10
|
export interface ProviderConfig {
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
enabled?: boolean;
|
|
12
|
+
outputDir?: string;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
export interface AWSApiGatewayConfig extends ProviderConfig {
|
|
16
|
-
|
|
16
|
+
// Additional AWS API Gateway specific options
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
export interface AWSLambdaConfig extends ProviderConfig {
|
|
20
|
-
|
|
20
|
+
// Additional AWS Lambda specific options
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface ProductionConfig {
|
|
24
|
+
/** Enable production mode (default: false) */
|
|
25
|
+
enabled?: boolean;
|
|
26
|
+
/** Bundle server into single file (default: true) */
|
|
27
|
+
bundle?: boolean;
|
|
28
|
+
/** Minify bundled output (default: true) */
|
|
29
|
+
minify?: boolean;
|
|
30
|
+
/** Health check endpoint path (default: '/health') */
|
|
31
|
+
healthCheck?: string;
|
|
32
|
+
/** Enable graceful shutdown handling (default: true) */
|
|
33
|
+
gracefulShutdown?: boolean;
|
|
34
|
+
/** Packages to exclude from bundling (default: []) */
|
|
35
|
+
external?: string[];
|
|
36
|
+
/** Include subscribers in production build (default: 'exclude' for serverless) */
|
|
37
|
+
subscribers?: 'include' | 'exclude';
|
|
38
|
+
/** Include OpenAPI spec in production (default: false) */
|
|
39
|
+
openapi?: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Enable build-time optimized handler generation (default: true)
|
|
42
|
+
* Generates specialized handlers based on endpoint tier:
|
|
43
|
+
* - minimal: Near-raw-Hono performance for simple endpoints
|
|
44
|
+
* - standard: Optimized handlers for auth/services
|
|
45
|
+
* - full: Uses HonoEndpoint.addRoutes for complex endpoints
|
|
46
|
+
*/
|
|
47
|
+
optimizedHandlers?: boolean;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** Service-specific configuration for docker-compose */
|
|
51
|
+
export interface ServiceConfig {
|
|
52
|
+
/**
|
|
53
|
+
* Full Docker image reference (e.g., 'postgis/postgis:16-3.4-alpine').
|
|
54
|
+
* When specified, overrides the default image entirely.
|
|
55
|
+
*/
|
|
56
|
+
image?: string;
|
|
57
|
+
/**
|
|
58
|
+
* Docker image version/tag (e.g., '15-alpine' for postgres).
|
|
59
|
+
* Only used when `image` is not specified.
|
|
60
|
+
*/
|
|
61
|
+
version?: string;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** Supported docker-compose service names */
|
|
65
|
+
export type ComposeServiceName = 'postgres' | 'redis' | 'rabbitmq';
|
|
66
|
+
|
|
67
|
+
/** Services configuration - can be boolean (use defaults) or object with version */
|
|
68
|
+
export type ComposeServicesConfig = {
|
|
69
|
+
[K in ComposeServiceName]?: boolean | ServiceConfig;
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
export interface DockerConfig {
|
|
73
|
+
/** Container registry URL (e.g., 'ghcr.io/myorg') */
|
|
74
|
+
registry?: string;
|
|
75
|
+
/** Docker image name (default: derived from package.json name) */
|
|
76
|
+
imageName?: string;
|
|
77
|
+
/** Base Docker image (default: 'node:22-alpine') */
|
|
78
|
+
baseImage?: string;
|
|
79
|
+
/** Container port (default: 3000) */
|
|
80
|
+
port?: number;
|
|
81
|
+
/** docker-compose services to include */
|
|
82
|
+
compose?: {
|
|
83
|
+
/**
|
|
84
|
+
* Services to include in docker-compose.
|
|
85
|
+
* Can be an object with service configs or an array of service names (legacy).
|
|
86
|
+
*
|
|
87
|
+
* @example Object format (recommended)
|
|
88
|
+
* services: {
|
|
89
|
+
* postgres: { version: '15-alpine' },
|
|
90
|
+
* redis: true, // use default version
|
|
91
|
+
* }
|
|
92
|
+
*
|
|
93
|
+
* @example Array format (legacy, uses default versions)
|
|
94
|
+
* services: ['postgres', 'redis']
|
|
95
|
+
*/
|
|
96
|
+
services?: ComposeServicesConfig | ComposeServiceName[];
|
|
97
|
+
};
|
|
21
98
|
}
|
|
22
99
|
|
|
23
100
|
export interface ServerConfig extends ProviderConfig {
|
|
24
|
-
|
|
25
|
-
|
|
101
|
+
enableOpenApi?: boolean;
|
|
102
|
+
port?: number;
|
|
103
|
+
/** Production build configuration */
|
|
104
|
+
production?: ProductionConfig;
|
|
26
105
|
}
|
|
27
106
|
|
|
28
107
|
export type Runtime = 'node' | 'bun';
|
|
29
108
|
|
|
30
109
|
export interface TelescopeConfig {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
110
|
+
/** Enable/disable telescope (default: true in development) */
|
|
111
|
+
enabled?: boolean;
|
|
112
|
+
/** Port for telescope to use (defaults to server port) */
|
|
113
|
+
port?: number;
|
|
114
|
+
/** Path prefix for telescope UI (default: /__telescope) */
|
|
115
|
+
path?: string;
|
|
116
|
+
/** Ignore patterns for telescope (e.g., ['/health', '/metrics']) */
|
|
117
|
+
ignore?: string[];
|
|
118
|
+
/** Record request/response bodies (default: true) */
|
|
119
|
+
recordBody?: boolean;
|
|
120
|
+
/** Maximum entries to keep in memory (default: 1000) */
|
|
121
|
+
maxEntries?: number;
|
|
122
|
+
/** Enable WebSocket for real-time updates (default: true, requires @hono/node-ws for Node.js) */
|
|
123
|
+
websocket?: boolean;
|
|
45
124
|
}
|
|
46
125
|
|
|
47
126
|
export interface StudioConfig {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
127
|
+
/** Enable/disable studio (default: true in development) */
|
|
128
|
+
enabled?: boolean;
|
|
129
|
+
/** Path prefix for studio UI (default: /__studio) */
|
|
130
|
+
path?: string;
|
|
131
|
+
/** Schema to introspect (default: 'public') */
|
|
132
|
+
schema?: string;
|
|
54
133
|
}
|
|
55
134
|
|
|
56
135
|
export interface OpenApiConfig {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
136
|
+
/** Enable OpenAPI generation (default: true) */
|
|
137
|
+
enabled?: boolean;
|
|
138
|
+
/** API title */
|
|
139
|
+
title?: string;
|
|
140
|
+
/** API version */
|
|
141
|
+
version?: string;
|
|
142
|
+
/** API description */
|
|
143
|
+
description?: string;
|
|
65
144
|
}
|
|
66
145
|
|
|
67
146
|
export interface HooksConfig {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
147
|
+
/**
|
|
148
|
+
* Path to a module exporting server lifecycle hooks.
|
|
149
|
+
* The module should export `beforeSetup` and/or `afterSetup` functions.
|
|
150
|
+
*
|
|
151
|
+
* @example
|
|
152
|
+
* ```typescript
|
|
153
|
+
* // src/config/hooks.ts
|
|
154
|
+
* import type { Hono } from 'hono';
|
|
155
|
+
* import type { Logger } from '@geekmidas/logger';
|
|
156
|
+
* import type { EnvironmentParser } from '@geekmidas/envkit';
|
|
157
|
+
*
|
|
158
|
+
* // Called BEFORE gkm endpoints are registered
|
|
159
|
+
* export function beforeSetup(app: Hono, ctx: { envParser: EnvironmentParser; logger: Logger }) {
|
|
160
|
+
* app.use('*', cors());
|
|
161
|
+
* app.get('/custom/health', (c) => c.json({ status: 'ok' }));
|
|
162
|
+
* }
|
|
163
|
+
*
|
|
164
|
+
* // Called AFTER gkm endpoints are registered
|
|
165
|
+
* export function afterSetup(app: Hono, ctx: { envParser: EnvironmentParser; logger: Logger }) {
|
|
166
|
+
* app.notFound((c) => c.json({ error: 'Not found' }, 404));
|
|
167
|
+
* app.onError((err, c) => c.json({ error: err.message }, 500));
|
|
168
|
+
* }
|
|
169
|
+
* ```
|
|
170
|
+
*/
|
|
171
|
+
server?: string;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/** Dokploy deployment configuration */
|
|
175
|
+
export interface DokployProviderConfig {
|
|
176
|
+
/** Dokploy API endpoint (e.g., 'https://dokploy.example.com') */
|
|
177
|
+
endpoint: string;
|
|
178
|
+
/** Project ID in Dokploy */
|
|
179
|
+
projectId: string;
|
|
180
|
+
/** Application ID in Dokploy */
|
|
181
|
+
applicationId: string;
|
|
182
|
+
/** Container registry (overrides docker.registry if set) */
|
|
183
|
+
registry?: string;
|
|
93
184
|
}
|
|
94
185
|
|
|
95
186
|
export interface ProvidersConfig {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
187
|
+
aws?: {
|
|
188
|
+
apiGateway?: {
|
|
189
|
+
v1?: boolean | AWSApiGatewayConfig;
|
|
190
|
+
v2?: boolean | AWSApiGatewayConfig;
|
|
191
|
+
};
|
|
192
|
+
lambda?: {
|
|
193
|
+
functions?: boolean | AWSLambdaConfig;
|
|
194
|
+
crons?: boolean | AWSLambdaConfig;
|
|
195
|
+
};
|
|
196
|
+
};
|
|
197
|
+
server?: boolean | ServerConfig;
|
|
198
|
+
/** Dokploy deployment configuration */
|
|
199
|
+
dokploy?: boolean | DokployProviderConfig;
|
|
107
200
|
}
|
|
108
201
|
|
|
109
202
|
export interface GkmConfig {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
203
|
+
routes: Routes;
|
|
204
|
+
functions?: Routes;
|
|
205
|
+
crons?: Routes;
|
|
206
|
+
subscribers?: Routes;
|
|
207
|
+
envParser: string;
|
|
208
|
+
logger: string;
|
|
209
|
+
providers?: ProvidersConfig;
|
|
210
|
+
/**
|
|
211
|
+
* Server lifecycle hooks for customizing the Hono app.
|
|
212
|
+
* Allows adding custom routes, middleware, error handlers, etc.
|
|
213
|
+
*
|
|
214
|
+
* @example
|
|
215
|
+
* hooks: {
|
|
216
|
+
* server: './src/config/hooks'
|
|
217
|
+
* }
|
|
218
|
+
*/
|
|
219
|
+
hooks?: HooksConfig;
|
|
220
|
+
/**
|
|
221
|
+
* Telescope configuration for debugging/monitoring.
|
|
222
|
+
* Can be:
|
|
223
|
+
* - A string path to a module that exports a Telescope instance (recommended)
|
|
224
|
+
* - A boolean to enable/disable with defaults
|
|
225
|
+
* - A TelescopeConfig object for inline configuration
|
|
226
|
+
*/
|
|
227
|
+
telescope?: string | boolean | TelescopeConfig;
|
|
228
|
+
/**
|
|
229
|
+
* Studio configuration for database browsing.
|
|
230
|
+
* Can be:
|
|
231
|
+
* - A string path to a module that exports a Studio instance (recommended)
|
|
232
|
+
* - A boolean to enable/disable with defaults
|
|
233
|
+
* - A StudioConfig object for inline configuration
|
|
234
|
+
*
|
|
235
|
+
* Requires a database connection configured via services.
|
|
236
|
+
*/
|
|
237
|
+
studio?: string | boolean | StudioConfig;
|
|
238
|
+
/**
|
|
239
|
+
* OpenAPI generation configuration.
|
|
240
|
+
* Can be:
|
|
241
|
+
* - A boolean to enable/disable with defaults (output: ./src/api/openapi.ts)
|
|
242
|
+
* - An OpenApiConfig object for customization
|
|
243
|
+
*
|
|
244
|
+
* When enabled, OpenAPI spec is generated on startup and regenerated on route changes.
|
|
245
|
+
*
|
|
246
|
+
* @example
|
|
247
|
+
* openapi: true
|
|
248
|
+
*
|
|
249
|
+
* @example
|
|
250
|
+
* openapi: {
|
|
251
|
+
* output: './src/api/openapi.ts',
|
|
252
|
+
* title: 'My API',
|
|
253
|
+
* version: '1.0.0',
|
|
254
|
+
* }
|
|
255
|
+
*/
|
|
256
|
+
openapi?: boolean | OpenApiConfig;
|
|
257
|
+
/** Runtime to use for dev server (default: 'node') */
|
|
258
|
+
runtime?: Runtime;
|
|
259
|
+
/**
|
|
260
|
+
* Environment file(s) to load for development.
|
|
261
|
+
* Can be:
|
|
262
|
+
* - A string path to a single env file (e.g., '.env.local')
|
|
263
|
+
* - An array of paths to load in order (later files override earlier)
|
|
264
|
+
* - Defaults to '.env' if not specified
|
|
265
|
+
*
|
|
266
|
+
* @example
|
|
267
|
+
* env: '.env.local'
|
|
268
|
+
*
|
|
269
|
+
* @example
|
|
270
|
+
* env: ['.env', '.env.local']
|
|
271
|
+
*/
|
|
272
|
+
env?: string | string[];
|
|
273
|
+
/**
|
|
274
|
+
* Docker deployment configuration.
|
|
275
|
+
* Used by `gkm docker` and `gkm prepack` commands.
|
|
276
|
+
*
|
|
277
|
+
* @example
|
|
278
|
+
* docker: {
|
|
279
|
+
* registry: 'ghcr.io/myorg',
|
|
280
|
+
* imageName: 'my-api',
|
|
281
|
+
* compose: {
|
|
282
|
+
* services: ['postgres', 'redis']
|
|
283
|
+
* }
|
|
284
|
+
* }
|
|
285
|
+
*/
|
|
286
|
+
docker?: DockerConfig;
|
|
180
287
|
}
|
|
181
288
|
|
|
182
289
|
export interface BuildOptions {
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
290
|
+
provider?: MainProvider;
|
|
291
|
+
// Legacy support - will be deprecated
|
|
292
|
+
providers?: LegacyProvider[];
|
|
293
|
+
enableOpenApi?: boolean;
|
|
294
|
+
/** Build for production (no dev tools, bundled output) */
|
|
295
|
+
production?: boolean;
|
|
296
|
+
/** Skip bundling step in production build */
|
|
297
|
+
skipBundle?: boolean;
|
|
298
|
+
/** Stage for secrets injection (e.g., 'production', 'staging') */
|
|
299
|
+
stage?: string;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
/** Result from build command when secrets are injected */
|
|
303
|
+
export interface BuildResult {
|
|
304
|
+
/** Ephemeral master key for deployment (only if stage was provided) */
|
|
305
|
+
masterKey?: string;
|
|
187
306
|
}
|
|
188
307
|
|
|
189
308
|
export interface RouteInfo {
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
309
|
+
path: string;
|
|
310
|
+
method: string;
|
|
311
|
+
handler: string;
|
|
312
|
+
timeout?: number;
|
|
313
|
+
memorySize?: number;
|
|
314
|
+
environment?: string[];
|
|
315
|
+
authorizer: string;
|
|
197
316
|
}
|
|
198
317
|
|
|
199
318
|
export interface FunctionInfo {
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
319
|
+
name: string;
|
|
320
|
+
handler: string;
|
|
321
|
+
timeout?: number;
|
|
322
|
+
memorySize?: number;
|
|
323
|
+
environment?: string[];
|
|
205
324
|
}
|
|
206
325
|
|
|
207
326
|
export interface CronInfo {
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
327
|
+
name: string;
|
|
328
|
+
handler: string;
|
|
329
|
+
schedule: string;
|
|
330
|
+
timeout?: number;
|
|
331
|
+
memorySize?: number;
|
|
332
|
+
environment?: string[];
|
|
214
333
|
}
|
|
215
334
|
|
|
216
335
|
export interface SubscriberInfo {
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
336
|
+
name: string;
|
|
337
|
+
handler: string;
|
|
338
|
+
subscribedEvents: string[];
|
|
339
|
+
timeout?: number;
|
|
340
|
+
memorySize?: number;
|
|
341
|
+
environment?: string[];
|
|
223
342
|
}
|
|
224
343
|
|
|
225
344
|
export interface RoutesManifest {
|
|
226
|
-
|
|
345
|
+
routes: RouteInfo[];
|
|
227
346
|
}
|
|
228
347
|
|
|
229
348
|
export interface FunctionsManifest {
|
|
230
|
-
|
|
349
|
+
functions: FunctionInfo[];
|
|
231
350
|
}
|
|
232
351
|
|
|
233
352
|
export interface CronsManifest {
|
|
234
|
-
|
|
353
|
+
crons: CronInfo[];
|
|
235
354
|
}
|
|
236
355
|
|
|
237
356
|
export interface SubscribersManifest {
|
|
238
|
-
|
|
357
|
+
subscribers: SubscriberInfo[];
|
|
239
358
|
}
|
package/tsconfig.json
ADDED
package/tsdown.config.ts
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import { defineConfig } from 'tsdown';
|
|
2
2
|
|
|
3
3
|
export default defineConfig({
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
4
|
+
entry: [
|
|
5
|
+
'src/index.ts',
|
|
6
|
+
'src/config.ts',
|
|
7
|
+
'src/openapi.ts',
|
|
8
|
+
'src/openapi-react-query.ts',
|
|
9
|
+
],
|
|
10
|
+
dts: true,
|
|
11
|
+
format: ['cjs', 'esm'],
|
|
12
|
+
outExtensions: (ctx) => ({
|
|
13
|
+
js: ctx.format === 'es' ? '.mjs' : '.cjs',
|
|
14
|
+
}),
|
|
12
15
|
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"config-Bq72aj8e.mjs","names":["config: GkmConfig","configString: string","defaultAlias: string","cwd: string"],"sources":["../src/config.ts"],"sourcesContent":["import { existsSync } from 'fs';\nimport { join } from 'path';\nimport type { GkmConfig } from './types.ts';\n\nexport type { GkmConfig } from './types.ts';\n/**\n * Define GKM configuration with full TypeScript support.\n * This is an identity function that provides type safety and autocomplete.\n *\n * @example\n * ```ts\n * // gkm.config.ts\n * import { defineConfig } from '@geekmidas/cli/config';\n *\n * export default defineConfig({\n * routes: './src/endpoints/**\\/*.ts',\n * envParser: './src/config/env',\n * logger: './src/config/logger',\n * telescope: true,\n * });\n * ```\n */\nexport function defineConfig(config: GkmConfig): GkmConfig {\n return config;\n}\n\nexport interface ParsedModuleConfig {\n path: string;\n importPattern: string;\n}\n\n/**\n * Parse a module config string into path and import pattern.\n *\n * @param configString - Config string in format \"./path/to/module\" or \"./path/to/module#exportName\"\n * @param defaultAlias - The default alias name to use if no export name specified\n * @returns Object with path and import pattern\n *\n * @example\n * parseModuleConfig('./src/config/env', 'envParser')\n * // { path: './src/config/env', importPattern: 'envParser' }\n *\n * parseModuleConfig('./src/config/env#envParser', 'envParser')\n * // { path: './src/config/env', importPattern: '{ envParser }' }\n *\n * parseModuleConfig('./src/config/env#myEnv', 'envParser')\n * // { path: './src/config/env', importPattern: '{ myEnv as envParser }' }\n */\nexport function parseModuleConfig(\n configString: string,\n defaultAlias: string,\n): ParsedModuleConfig {\n const [path, exportName] = configString.split('#');\n const importPattern = !exportName\n ? defaultAlias\n : exportName === defaultAlias\n ? `{ ${defaultAlias} }`\n : `{ ${exportName} as ${defaultAlias} }`;\n\n return { path, importPattern };\n}\n\nexport async function loadConfig(\n cwd: string = process.cwd(),\n): Promise<GkmConfig> {\n const files = ['gkm.config.json', 'gkm.config.ts', 'gkm.config.js'];\n let configPath = '';\n\n for (const file of files) {\n const path = join(cwd, file);\n if (existsSync(path)) {\n configPath = path;\n break;\n }\n }\n\n if (!configPath) {\n throw new Error(\n 'Configuration file not found. Please create gkm.config.json, gkm.config.ts, or gkm.config.js in the project root.',\n );\n }\n\n try {\n const config = await import(configPath);\n return config.default;\n } catch (error) {\n throw new Error(\n `Failed to load gkm.config.json: ${(error as Error).message}`,\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAsBA,SAAgB,aAAaA,QAA8B;AACzD,QAAO;AACR;;;;;;;;;;;;;;;;;;AAwBD,SAAgB,kBACdC,cACAC,cACoB;CACpB,MAAM,CAAC,MAAM,WAAW,GAAG,aAAa,MAAM,IAAI;CAClD,MAAM,iBAAiB,aACnB,eACA,eAAe,gBACZ,IAAI,aAAa,OACjB,IAAI,WAAW,MAAM,aAAa;AAEzC,QAAO;EAAE;EAAM;CAAe;AAC/B;AAED,eAAsB,WACpBC,MAAc,QAAQ,KAAK,EACP;CACpB,MAAM,QAAQ;EAAC;EAAmB;EAAiB;CAAgB;CACnE,IAAI,aAAa;AAEjB,MAAK,MAAM,QAAQ,OAAO;EACxB,MAAM,OAAO,KAAK,KAAK,KAAK;AAC5B,MAAI,WAAW,KAAK,EAAE;AACpB,gBAAa;AACb;EACD;CACF;AAED,MAAK,WACH,OAAM,IAAI,MACR;AAIJ,KAAI;EACF,MAAM,SAAS,MAAM,OAAO;AAC5B,SAAO,OAAO;CACf,SAAQ,OAAO;AACd,QAAM,IAAI,OACP,kCAAmC,MAAgB,QAAQ;CAE/D;AACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"config-CFls09Ey.cjs","names":["config: GkmConfig","configString: string","defaultAlias: string","path","cwd: string"],"sources":["../src/config.ts"],"sourcesContent":["import { existsSync } from 'fs';\nimport { join } from 'path';\nimport type { GkmConfig } from './types.ts';\n\nexport type { GkmConfig } from './types.ts';\n/**\n * Define GKM configuration with full TypeScript support.\n * This is an identity function that provides type safety and autocomplete.\n *\n * @example\n * ```ts\n * // gkm.config.ts\n * import { defineConfig } from '@geekmidas/cli/config';\n *\n * export default defineConfig({\n * routes: './src/endpoints/**\\/*.ts',\n * envParser: './src/config/env',\n * logger: './src/config/logger',\n * telescope: true,\n * });\n * ```\n */\nexport function defineConfig(config: GkmConfig): GkmConfig {\n return config;\n}\n\nexport interface ParsedModuleConfig {\n path: string;\n importPattern: string;\n}\n\n/**\n * Parse a module config string into path and import pattern.\n *\n * @param configString - Config string in format \"./path/to/module\" or \"./path/to/module#exportName\"\n * @param defaultAlias - The default alias name to use if no export name specified\n * @returns Object with path and import pattern\n *\n * @example\n * parseModuleConfig('./src/config/env', 'envParser')\n * // { path: './src/config/env', importPattern: 'envParser' }\n *\n * parseModuleConfig('./src/config/env#envParser', 'envParser')\n * // { path: './src/config/env', importPattern: '{ envParser }' }\n *\n * parseModuleConfig('./src/config/env#myEnv', 'envParser')\n * // { path: './src/config/env', importPattern: '{ myEnv as envParser }' }\n */\nexport function parseModuleConfig(\n configString: string,\n defaultAlias: string,\n): ParsedModuleConfig {\n const [path, exportName] = configString.split('#');\n const importPattern = !exportName\n ? defaultAlias\n : exportName === defaultAlias\n ? `{ ${defaultAlias} }`\n : `{ ${exportName} as ${defaultAlias} }`;\n\n return { path, importPattern };\n}\n\nexport async function loadConfig(\n cwd: string = process.cwd(),\n): Promise<GkmConfig> {\n const files = ['gkm.config.json', 'gkm.config.ts', 'gkm.config.js'];\n let configPath = '';\n\n for (const file of files) {\n const path = join(cwd, file);\n if (existsSync(path)) {\n configPath = path;\n break;\n }\n }\n\n if (!configPath) {\n throw new Error(\n 'Configuration file not found. Please create gkm.config.json, gkm.config.ts, or gkm.config.js in the project root.',\n );\n }\n\n try {\n const config = await import(configPath);\n return config.default;\n } catch (error) {\n throw new Error(\n `Failed to load gkm.config.json: ${(error as Error).message}`,\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAsBA,SAAgB,aAAaA,QAA8B;AACzD,QAAO;AACR;;;;;;;;;;;;;;;;;;AAwBD,SAAgB,kBACdC,cACAC,cACoB;CACpB,MAAM,CAACC,QAAM,WAAW,GAAG,aAAa,MAAM,IAAI;CAClD,MAAM,iBAAiB,aACnB,eACA,eAAe,gBACZ,IAAI,aAAa,OACjB,IAAI,WAAW,MAAM,aAAa;AAEzC,QAAO;EAAE;EAAM;CAAe;AAC/B;AAED,eAAsB,WACpBC,MAAc,QAAQ,KAAK,EACP;CACpB,MAAM,QAAQ;EAAC;EAAmB;EAAiB;CAAgB;CACnE,IAAI,aAAa;AAEjB,MAAK,MAAM,QAAQ,OAAO;EACxB,MAAMD,SAAO,eAAK,KAAK,KAAK;AAC5B,MAAI,mBAAWA,OAAK,EAAE;AACpB,gBAAaA;AACb;EACD;CACF;AAED,MAAK,WACH,OAAM,IAAI,MACR;AAIJ,KAAI;EACF,MAAM,SAAS,MAAM,OAAO;AAC5B,SAAO,OAAO;CACf,SAAQ,OAAO;AACd,QAAM,IAAI,OACP,kCAAmC,MAAgB,QAAQ;CAE/D;AACF"}
|