appos 0.2.1 → 0.2.3-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/dist/bin/auth-schema-7KeUwlcd.mjs +2 -0
- package/dist/bin/concurrently.mjs +2 -0
- package/dist/bin/event-v2sCJkNd.mjs +2 -0
- package/dist/bin/extract-blob-metadata-TqNd9w-6.mjs +2 -0
- package/dist/bin/generate-image-variant-D8H9FxgD.mjs +2 -0
- package/dist/bin/generate-preview-5jLZLX6I.mjs +2 -0
- package/dist/bin/main.mjs +362 -0
- package/dist/bin/purge-attachment-CMlJMNOk.mjs +2 -0
- package/dist/bin/purge-audit-logs-hd6q6vnR.mjs +2 -0
- package/dist/bin/purge-unattached-blobs-BYv5b9R9.mjs +2 -0
- package/dist/bin/track-db-changes-q0Vl7Htm.mjs +2 -0
- package/dist/bin/vite.mjs +2 -0
- package/dist/bin/vitest.mjs +2 -0
- package/dist/bin/workflow-BagSlsMp.mjs +2 -0
- package/dist/bin/youch-handler-Jj6i1XIT.mjs +2 -0
- package/dist/exports/api/_virtual/rolldown_runtime.mjs +1 -0
- package/dist/exports/api/app-context.d.mts +115 -0
- package/dist/exports/api/app-context.mjs +1 -0
- package/dist/exports/api/auth-schema.d.mts +4248 -0
- package/dist/exports/api/auth-schema.mjs +1 -0
- package/dist/exports/api/auth.d.mts +398 -0
- package/dist/exports/api/auth.mjs +1 -0
- package/dist/exports/api/cache.d.mts +44 -0
- package/dist/exports/api/cache.mjs +1 -0
- package/dist/exports/api/config.d.mts +28 -0
- package/dist/exports/api/config.mjs +1 -0
- package/dist/exports/api/container.d.mts +210 -0
- package/dist/exports/api/container.mjs +1 -0
- package/dist/exports/api/database.d.mts +99 -0
- package/dist/exports/api/database.mjs +1 -0
- package/dist/exports/api/event.d.mts +235 -0
- package/dist/exports/api/event.mjs +1 -0
- package/dist/exports/api/i18n.d.mts +34 -0
- package/dist/exports/api/i18n.mjs +1 -0
- package/dist/exports/api/index.d.mts +21 -0
- package/dist/exports/api/index.mjs +1 -0
- package/dist/exports/api/logger.d.mts +21 -0
- package/dist/exports/api/logger.mjs +1 -0
- package/dist/exports/api/mailer.d.mts +70 -0
- package/dist/exports/api/mailer.mjs +1 -0
- package/dist/exports/api/middleware/request-logger.d.mts +24 -0
- package/dist/exports/api/middleware.d.mts +39 -0
- package/dist/exports/api/middleware.mjs +1 -0
- package/dist/exports/api/node_modules/.bun/change-case@5.4.4/node_modules/change-case/dist/index.mjs +1 -0
- package/dist/exports/api/openapi.d.mts +271 -0
- package/dist/exports/api/openapi.mjs +1 -0
- package/dist/exports/api/orm.d.mts +13 -0
- package/dist/exports/api/orm.mjs +1 -0
- package/dist/exports/api/otel.d.mts +40 -0
- package/dist/exports/api/otel.mjs +1 -0
- package/dist/exports/api/packages/appos/src/constants.mjs +1 -0
- package/dist/exports/api/packages/appos/src/instrumentation.d.mts +7 -0
- package/dist/exports/api/packages/appos/src/instrumentation.mjs +1 -0
- package/dist/exports/api/packages/appos/src/web/auth.mjs +1 -0
- package/dist/exports/api/redis.d.mts +34 -0
- package/dist/exports/api/redis.mjs +1 -0
- package/dist/exports/api/storage-schema.d.mts +707 -0
- package/dist/exports/api/storage-schema.mjs +1 -0
- package/dist/exports/api/storage.d.mts +506 -0
- package/dist/exports/api/storage.mjs +1 -0
- package/dist/exports/api/workflow.d.mts +250 -0
- package/dist/exports/api/workflow.mjs +1 -0
- package/dist/exports/api/workflows/_virtual/rolldown_runtime.mjs +1 -0
- package/dist/exports/api/workflows/auth-schema.mjs +1 -0
- package/dist/exports/api/workflows/auth.d.mts +375 -0
- package/dist/exports/api/workflows/cache.d.mts +44 -0
- package/dist/exports/api/workflows/config.d.mts +18 -0
- package/dist/exports/api/workflows/container.d.mts +167 -0
- package/dist/exports/api/workflows/database.d.mts +46 -0
- package/dist/exports/api/workflows/event.d.mts +68 -0
- package/dist/exports/api/workflows/event.mjs +1 -0
- package/dist/exports/api/workflows/extract-blob-metadata.mjs +1 -0
- package/dist/exports/api/workflows/generate-image-variant.d.mts +63 -0
- package/dist/exports/api/workflows/generate-image-variant.mjs +1 -0
- package/dist/exports/api/workflows/generate-preview.mjs +1 -0
- package/dist/exports/api/workflows/index.d.mts +2 -0
- package/dist/exports/api/workflows/index.mjs +1 -0
- package/dist/exports/api/workflows/logger.d.mts +21 -0
- package/dist/exports/api/workflows/mailer.d.mts +70 -0
- package/dist/exports/api/workflows/orm.d.mts +13 -0
- package/dist/exports/api/workflows/purge-attachment.mjs +1 -0
- package/dist/exports/api/workflows/purge-audit-logs.mjs +1 -0
- package/dist/exports/api/workflows/purge-unattached-blobs.mjs +1 -0
- package/dist/exports/api/workflows/redis.mjs +1 -0
- package/dist/exports/api/workflows/storage-schema.d.mts +699 -0
- package/dist/exports/api/workflows/storage.d.mts +396 -0
- package/dist/exports/api/workflows/track-db-changes.d.mts +72 -0
- package/dist/exports/api/workflows/track-db-changes.mjs +1 -0
- package/dist/exports/api/workflows/workflow.d.mts +24 -0
- package/dist/exports/api/workflows/workflow.mjs +1 -0
- package/dist/exports/cli/_virtual/rolldown_runtime.mjs +1 -0
- package/dist/exports/cli/api/auth-schema.mjs +1 -0
- package/dist/exports/cli/api/auth.d.mts +375 -0
- package/dist/exports/cli/api/cache.d.mts +44 -0
- package/dist/exports/cli/api/config.d.mts +18 -0
- package/dist/exports/cli/api/container.d.mts +167 -0
- package/dist/exports/cli/api/database.d.mts +46 -0
- package/dist/exports/cli/api/event.d.mts +68 -0
- package/dist/exports/cli/api/event.mjs +1 -0
- package/dist/exports/cli/api/logger.d.mts +21 -0
- package/dist/exports/cli/api/mailer.d.mts +70 -0
- package/dist/exports/cli/api/orm.d.mts +13 -0
- package/dist/exports/cli/api/redis.mjs +1 -0
- package/dist/exports/cli/api/storage-schema.d.mts +699 -0
- package/dist/exports/cli/api/storage.d.mts +396 -0
- package/dist/exports/cli/api/workflow.d.mts +2 -0
- package/dist/exports/cli/api/workflow.mjs +1 -0
- package/dist/exports/cli/api/workflows/extract-blob-metadata.mjs +1 -0
- package/dist/exports/cli/api/workflows/generate-image-variant.d.mts +63 -0
- package/dist/exports/cli/api/workflows/generate-image-variant.mjs +1 -0
- package/dist/exports/cli/api/workflows/generate-preview.mjs +1 -0
- package/dist/exports/cli/api/workflows/purge-attachment.mjs +1 -0
- package/dist/exports/cli/api/workflows/purge-audit-logs.mjs +1 -0
- package/dist/exports/cli/api/workflows/purge-unattached-blobs.mjs +1 -0
- package/dist/exports/cli/api/workflows/track-db-changes.mjs +1 -0
- package/dist/exports/cli/command.d.mts +54 -0
- package/dist/exports/cli/command.mjs +1 -0
- package/dist/exports/cli/context.d.mts +170 -0
- package/dist/exports/cli/index.d.mts +3 -0
- package/dist/exports/cli/index.mjs +1 -0
- package/dist/exports/devtools/index.d.ts +3 -0
- package/dist/exports/devtools/index.js +1 -0
- package/dist/exports/instrumentation.d.mts +1 -0
- package/dist/exports/instrumentation.mjs +1 -0
- package/dist/exports/tests/_virtual/rolldown_runtime.mjs +1 -0
- package/dist/exports/tests/api.d.mts +86 -0
- package/dist/exports/tests/api.mjs +1 -0
- package/dist/exports/tests/mock.d.mts +1 -0
- package/dist/exports/tests/mock.mjs +1 -0
- package/dist/exports/tests/node_modules/.bun/change-case@5.4.4/node_modules/change-case/dist/index.mjs +1 -0
- package/dist/exports/tests/node_modules/.bun/rate-limit-redis@4.3.1_f1fa5524233c9c60/node_modules/rate-limit-redis/dist/index.mjs +25 -0
- package/dist/exports/tests/packages/appos/src/api/app-context.d.mts +115 -0
- package/dist/exports/tests/packages/appos/src/api/auth-schema.d.mts +4248 -0
- package/dist/exports/tests/packages/appos/src/api/auth-schema.mjs +1 -0
- package/dist/exports/tests/packages/appos/src/api/auth.d.mts +398 -0
- package/dist/exports/tests/packages/appos/src/api/cache.d.mts +44 -0
- package/dist/exports/tests/packages/appos/src/api/config.d.mts +28 -0
- package/dist/exports/tests/packages/appos/src/api/container.d.mts +210 -0
- package/dist/exports/tests/packages/appos/src/api/database.d.mts +99 -0
- package/dist/exports/tests/packages/appos/src/api/database.mjs +1 -0
- package/dist/exports/tests/packages/appos/src/api/event.d.mts +235 -0
- package/dist/exports/tests/packages/appos/src/api/event.mjs +1 -0
- package/dist/exports/tests/packages/appos/src/api/i18n.d.mts +34 -0
- package/dist/exports/tests/packages/appos/src/api/index.d.mts +27 -0
- package/dist/exports/tests/packages/appos/src/api/logger.d.mts +21 -0
- package/dist/exports/tests/packages/appos/src/api/mailer.d.mts +70 -0
- package/dist/exports/tests/packages/appos/src/api/middleware/error-handler.mjs +1 -0
- package/dist/exports/tests/packages/appos/src/api/middleware/health.mjs +1 -0
- package/dist/exports/tests/packages/appos/src/api/middleware/i18n.mjs +1 -0
- package/dist/exports/tests/packages/appos/src/api/middleware/request-logger.d.mts +24 -0
- package/dist/exports/tests/packages/appos/src/api/middleware/request-logger.mjs +1 -0
- package/dist/exports/tests/packages/appos/src/api/middleware/shutdown.mjs +1 -0
- package/dist/exports/tests/packages/appos/src/api/middleware/timeout.mjs +1 -0
- package/dist/exports/tests/packages/appos/src/api/middleware/youch-handler.mjs +1 -0
- package/dist/exports/tests/packages/appos/src/api/middleware.d.mts +39 -0
- package/dist/exports/tests/packages/appos/src/api/middleware.mjs +1 -0
- package/dist/exports/tests/packages/appos/src/api/openapi.d.mts +271 -0
- package/dist/exports/tests/packages/appos/src/api/orm.d.mts +13 -0
- package/dist/exports/tests/packages/appos/src/api/otel.d.mts +40 -0
- package/dist/exports/tests/packages/appos/src/api/redis.d.mts +34 -0
- package/dist/exports/tests/packages/appos/src/api/redis.mjs +1 -0
- package/dist/exports/tests/packages/appos/src/api/server.mjs +1 -0
- package/dist/exports/tests/packages/appos/src/api/storage-schema.d.mts +707 -0
- package/dist/exports/tests/packages/appos/src/api/storage.d.mts +506 -0
- package/dist/exports/tests/packages/appos/src/api/workflow.d.mts +250 -0
- package/dist/exports/tests/packages/appos/src/api/workflow.mjs +1 -0
- package/dist/exports/tests/packages/appos/src/api/workflows/extract-blob-metadata.mjs +1 -0
- package/dist/exports/tests/packages/appos/src/api/workflows/generate-image-variant.d.mts +99 -0
- package/dist/exports/tests/packages/appos/src/api/workflows/generate-image-variant.mjs +1 -0
- package/dist/exports/tests/packages/appos/src/api/workflows/generate-preview.mjs +1 -0
- package/dist/exports/tests/packages/appos/src/api/workflows/purge-attachment.mjs +1 -0
- package/dist/exports/tests/packages/appos/src/api/workflows/purge-audit-logs.mjs +1 -0
- package/dist/exports/tests/packages/appos/src/api/workflows/purge-unattached-blobs.mjs +1 -0
- package/dist/exports/tests/packages/appos/src/api/workflows/track-db-changes.mjs +1 -0
- package/dist/exports/tests/packages/appos/src/constants.mjs +1 -0
- package/dist/exports/tests/packages/appos/src/instrumentation.d.mts +7 -0
- package/dist/exports/tests/packages/appos/src/instrumentation.mjs +1 -0
- package/dist/exports/tests/react.d.mts +2 -0
- package/dist/exports/tests/react.mjs +1 -0
- package/dist/exports/tests/setup.d.mts +1 -0
- package/dist/exports/tests/setup.mjs +1 -0
- package/dist/exports/vendors/date.js +1 -0
- package/dist/exports/vendors/toolkit.js +1 -0
- package/dist/exports/vendors/zod.d.ts +1 -0
- package/dist/exports/vendors/zod.js +1 -0
- package/dist/exports/vite/index.d.mts +19 -0
- package/dist/exports/vite/index.mjs +1 -0
- package/dist/exports/vitest/config.d.mts +1 -0
- package/dist/exports/vitest/config.mjs +1 -0
- package/dist/exports/vitest/globals.d.mts +1 -0
- package/dist/exports/vitest/globals.mjs +1 -0
- package/dist/exports/vitest/index.d.mts +1 -0
- package/dist/exports/vitest/index.mjs +1 -0
- package/dist/exports/web/api/auth.d.ts +125 -0
- package/dist/exports/web/api/database.d.ts +4 -0
- package/dist/exports/web/api/logger.d.ts +1 -0
- package/dist/exports/web/auth.d.ts +2388 -0
- package/dist/exports/web/auth.js +1 -0
- package/dist/exports/web/i18n.d.ts +42 -0
- package/dist/exports/web/i18n.js +1 -0
- package/dist/exports/web/index.d.ts +6 -0
- package/dist/exports/web/index.js +1 -0
- package/package.json +138 -98
- package/build/bin/main.mjs +0 -2
- package/build/exports/cli/index.d.mts +0 -325
- package/build/exports/cli/index.mjs +0 -1
- package/build/exports/instrumentation/execAsync-DaIUcs6_.mjs +0 -1
- package/build/exports/instrumentation/getMachineId-bsd-bB6ipDhm.mjs +0 -1
- package/build/exports/instrumentation/getMachineId-darwin-D1Bx5aCe.mjs +0 -2
- package/build/exports/instrumentation/getMachineId-linux-D_R9Tla0.mjs +0 -1
- package/build/exports/instrumentation/getMachineId-unsupported-BZKPE_Ev.mjs +0 -1
- package/build/exports/instrumentation/getMachineId-win-CmPvIqHL.mjs +0 -1
- package/build/exports/instrumentation/instrumentation.d.mts +0 -1
- package/build/exports/instrumentation/instrumentation.mjs +0 -80
- package/build/exports/server/index.d.mts +0 -327
- package/build/exports/server/index.mjs +0 -219
- package/build/exports/server/react-gPO8Jsy-.mjs +0 -13
- package/build/exports/server/server.node-D_9RYjm9.mjs +0 -210
- package/build/exports/store/index.d.mts +0 -58
- package/build/exports/store/index.mjs +0 -15
- package/build/exports/support/datetime.js +0 -1
- package/build/exports/support/utils.js +0 -1
- package/build/exports/support/zod.d.ts +0 -2
- package/build/exports/support/zod.js +0 -23
- package/build/exports/test/dist-DAsoCGWk.mjs +0 -348
- package/build/exports/test/index.d.mts +0 -3
- package/build/exports/test/index.mjs +0 -1
- package/build/exports/test/magic-string.es-BWgiB2kd.mjs +0 -14
- package/build/exports/test/setup.d.mts +0 -1
- package/build/exports/test/setup.mjs +0 -329
- /package/{build/exports/support/datetime.d.ts → dist/exports/vendors/date.d.ts} +0 -0
- /package/{build/exports/support/utils.d.ts → dist/exports/vendors/toolkit.d.ts} +0 -0
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
import { Container } from "./container.mjs";
|
|
2
|
+
import { AppContext } from "./app-context.mjs";
|
|
3
|
+
import { Express, Request, RequestHandler } from "ultimate-express";
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
import * as _node_modules_zod_openapi_dist_components_B1DX_zYv_mjs0 from "#node_modules/zod-openapi/dist/components-B1DX_zYv.mjs";
|
|
6
|
+
|
|
7
|
+
//#region src/api/openapi.d.ts
|
|
8
|
+
declare const appDir: string;
|
|
9
|
+
/**
|
|
10
|
+
* Utility type to enforce exact type matching (no extra properties).
|
|
11
|
+
* This uses a tuple check to prevent objects with extra keys from being assigned.
|
|
12
|
+
* Arrays are handled specially to avoid treating numeric indices as object keys.
|
|
13
|
+
*/
|
|
14
|
+
type Exact<T, Expected> = [T] extends [Expected] ? [Expected] extends [T] ? T : T extends readonly unknown[] ? Expected extends readonly unknown[] ? T extends readonly (infer TItem)[] ? Expected extends readonly (infer ExpectedItem)[] ? readonly Exact<TItem, ExpectedItem>[] : T : T : { [K in keyof T]: K extends keyof Expected ? Exact<T[K], Expected[K]> : ["Error: unexpected key", K] } : { [K in keyof T]: K extends keyof Expected ? Exact<T[K], Expected[K]> : ["Error: unexpected key", K] } : T;
|
|
15
|
+
/**
|
|
16
|
+
* Response marker type for Express compatibility.
|
|
17
|
+
*/
|
|
18
|
+
type ResponseMarker<T = unknown> = {
|
|
19
|
+
__response: true;
|
|
20
|
+
status: number;
|
|
21
|
+
data: T;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Define typed response builders based on defined response schemas.
|
|
25
|
+
*/
|
|
26
|
+
declare function defineTypedResponses<TResponses extends Record<number, {
|
|
27
|
+
description: string;
|
|
28
|
+
schema: z.ZodSchema;
|
|
29
|
+
}>>(responses: TResponses): { [K in keyof TResponses as GetMethodName<K>]: K extends number ? TResponses[K]["schema"] extends z.ZodNull ? () => ResponseMarker<null> : <T extends z.infer<TResponses[K]["schema"]>>(data: Exact<T, z.infer<TResponses[K]["schema"]>>) => ResponseMarker<z.infer<TResponses[K]["schema"]>> : never } & {
|
|
30
|
+
status: <S extends keyof TResponses & number>(statusCode: S, data: TResponses[S]["schema"] extends z.ZodNull ? undefined : Exact<z.infer<TResponses[S]["schema"]>, z.infer<TResponses[S]["schema"]>>) => ResponseMarker;
|
|
31
|
+
};
|
|
32
|
+
type GetMethodName<K$1> = K$1 extends 200 ? "ok" : K$1 extends 201 ? "created" : K$1 extends 202 ? "accepted" : K$1 extends 204 ? "noContent" : K$1 extends 400 ? "badRequest" : K$1 extends 401 ? "unauthorized" : K$1 extends 403 ? "forbidden" : K$1 extends 404 ? "notFound" : K$1 extends 409 ? "conflict" : K$1 extends 422 ? "unprocessableEntity" : K$1 extends 500 ? "internalServerError" : never;
|
|
33
|
+
/**
|
|
34
|
+
* Handler parameters with full type safety for request inputs.
|
|
35
|
+
*/
|
|
36
|
+
type HandlerParams<TParams extends z.ZodSchema | undefined = undefined, TQuery extends z.ZodSchema | undefined = undefined, TBody extends z.ZodSchema | undefined = undefined, THeaders extends z.ZodSchema | undefined = undefined, TResponses extends Record<number, {
|
|
37
|
+
description: string;
|
|
38
|
+
schema: z.ZodSchema;
|
|
39
|
+
}> = Record<number, {
|
|
40
|
+
description: string;
|
|
41
|
+
schema: z.ZodSchema;
|
|
42
|
+
}>> = {
|
|
43
|
+
ctx: AppContext;
|
|
44
|
+
body: TBody extends z.ZodSchema ? z.infer<TBody> : unknown;
|
|
45
|
+
headers: THeaders extends z.ZodSchema ? z.infer<THeaders> : Record<string, string>;
|
|
46
|
+
params: TParams extends z.ZodSchema ? z.infer<TParams> : Record<string, unknown>;
|
|
47
|
+
query: TQuery extends z.ZodSchema ? z.infer<TQuery> : Record<string, unknown>;
|
|
48
|
+
request: Request;
|
|
49
|
+
response: ReturnType<typeof defineTypedResponses<TResponses>>;
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* Helper function to define an OpenAPI endpoint with full type safety.
|
|
53
|
+
*/
|
|
54
|
+
declare function defineOpenAPIEndpoint<TParams extends z.ZodSchema | undefined = undefined, TQuery extends z.ZodSchema | undefined = undefined, TBody extends z.ZodSchema | undefined = undefined, THeaders extends z.ZodSchema | undefined = undefined, TResponses extends Record<number, {
|
|
55
|
+
description: string;
|
|
56
|
+
schema: z.ZodSchema;
|
|
57
|
+
}> = Record<number, {
|
|
58
|
+
description: string;
|
|
59
|
+
schema: z.ZodSchema;
|
|
60
|
+
}>>(spec: {
|
|
61
|
+
summary?: string;
|
|
62
|
+
description?: string;
|
|
63
|
+
params?: TParams;
|
|
64
|
+
query?: TQuery;
|
|
65
|
+
requestBody?: TBody;
|
|
66
|
+
headers?: THeaders;
|
|
67
|
+
responses: TResponses;
|
|
68
|
+
handler: (params: HandlerParams<TParams, TQuery, TBody, THeaders, TResponses>) => Promise<ResponseMarker>;
|
|
69
|
+
}): {
|
|
70
|
+
summary?: string;
|
|
71
|
+
description?: string;
|
|
72
|
+
params?: TParams;
|
|
73
|
+
query?: TQuery;
|
|
74
|
+
requestBody?: TBody;
|
|
75
|
+
headers?: THeaders;
|
|
76
|
+
responses: TResponses;
|
|
77
|
+
handler: (params: HandlerParams<TParams, TQuery, TBody, THeaders, TResponses>) => Promise<ResponseMarker>;
|
|
78
|
+
};
|
|
79
|
+
/**
|
|
80
|
+
* OpenAPI method specification type (for internal use).
|
|
81
|
+
*/
|
|
82
|
+
type OpenAPIMethodSpec = {
|
|
83
|
+
summary?: string;
|
|
84
|
+
description?: string;
|
|
85
|
+
params?: z.ZodSchema;
|
|
86
|
+
query?: z.ZodSchema;
|
|
87
|
+
requestBody?: z.ZodSchema;
|
|
88
|
+
headers?: z.ZodSchema;
|
|
89
|
+
responses: Record<number, {
|
|
90
|
+
description: string;
|
|
91
|
+
schema: z.ZodSchema;
|
|
92
|
+
}>;
|
|
93
|
+
handler: (params: HandlerParams<any, any, any, any, any>) => Promise<ResponseMarker>;
|
|
94
|
+
};
|
|
95
|
+
/**
|
|
96
|
+
* Configuration object for defineOpenApi.
|
|
97
|
+
*/
|
|
98
|
+
type DefineOpenAPIConfig = { [K in "GET" | "HEAD" | "POST" | "PUT" | "PATCH" | "DELETE"]?: OpenAPIMethodSpec };
|
|
99
|
+
/**
|
|
100
|
+
* OpenAPI configuration for document-level settings
|
|
101
|
+
*/
|
|
102
|
+
type OpenAPIObjectConfigV31 = {
|
|
103
|
+
info: {
|
|
104
|
+
title: string;
|
|
105
|
+
version: string;
|
|
106
|
+
description?: string;
|
|
107
|
+
contact?: {
|
|
108
|
+
name?: string;
|
|
109
|
+
email?: string;
|
|
110
|
+
url?: string;
|
|
111
|
+
};
|
|
112
|
+
license?: {
|
|
113
|
+
name: string;
|
|
114
|
+
url?: string;
|
|
115
|
+
};
|
|
116
|
+
};
|
|
117
|
+
servers?: Array<{
|
|
118
|
+
url: string;
|
|
119
|
+
description?: string;
|
|
120
|
+
}>;
|
|
121
|
+
openapi: "3.1.0";
|
|
122
|
+
};
|
|
123
|
+
/**
|
|
124
|
+
* Simplified config input for defineOpenAPIConfig
|
|
125
|
+
*/
|
|
126
|
+
type DefineOpenAPIConfigInput = {
|
|
127
|
+
info: OpenAPIObjectConfigV31["info"];
|
|
128
|
+
servers?: OpenAPIObjectConfigV31["servers"];
|
|
129
|
+
};
|
|
130
|
+
/**
|
|
131
|
+
* OpenAPI registration format (without path - CLI will add it)
|
|
132
|
+
*/
|
|
133
|
+
type OpenAPIRegistration = {
|
|
134
|
+
method: "get" | "post" | "put" | "patch" | "delete" | "head";
|
|
135
|
+
summary?: string;
|
|
136
|
+
description?: string;
|
|
137
|
+
request?: {
|
|
138
|
+
params?: z.ZodSchema;
|
|
139
|
+
query?: z.ZodSchema;
|
|
140
|
+
body?: z.ZodSchema;
|
|
141
|
+
headers?: z.ZodSchema;
|
|
142
|
+
};
|
|
143
|
+
responses: Record<number, {
|
|
144
|
+
description: string;
|
|
145
|
+
content: {
|
|
146
|
+
"application/json": {
|
|
147
|
+
schema: z.ZodSchema;
|
|
148
|
+
};
|
|
149
|
+
};
|
|
150
|
+
}>;
|
|
151
|
+
};
|
|
152
|
+
/**
|
|
153
|
+
* Return type for defineOpenAPI function
|
|
154
|
+
*/
|
|
155
|
+
type DefineOpenAPIReturn = {
|
|
156
|
+
handlers: Record<string, RequestHandler>;
|
|
157
|
+
openAPISpec: OpenAPIRegistration[];
|
|
158
|
+
};
|
|
159
|
+
/**
|
|
160
|
+
* RFC 9457 compliant validation error response
|
|
161
|
+
*/
|
|
162
|
+
type ValidationErrorResponse = {
|
|
163
|
+
error: "validation_error";
|
|
164
|
+
status: number;
|
|
165
|
+
detail: string;
|
|
166
|
+
errors: Array<{
|
|
167
|
+
field: string;
|
|
168
|
+
message: string;
|
|
169
|
+
received: unknown;
|
|
170
|
+
}>;
|
|
171
|
+
};
|
|
172
|
+
/**
|
|
173
|
+
* Define OpenAPI-based route handlers with full type safety.
|
|
174
|
+
*
|
|
175
|
+
* @param config Configuration object with HTTP method specifications
|
|
176
|
+
* @returns Object containing Express handlers and openAPISpec
|
|
177
|
+
*
|
|
178
|
+
* @example
|
|
179
|
+
* ```typescript
|
|
180
|
+
* // Basic usage
|
|
181
|
+
* export default defineOpenAPI({
|
|
182
|
+
* GET: {
|
|
183
|
+
* summary: "Get user by ID",
|
|
184
|
+
* params: z.object({ id: z.uuid() }),
|
|
185
|
+
* responses: {
|
|
186
|
+
* 200: { description: "User data", schema: UserSchema }
|
|
187
|
+
* },
|
|
188
|
+
* handler: async ({ params, response }) => {
|
|
189
|
+
* const user = await getUser(params.id);
|
|
190
|
+
* return response.ok(user); // Fully typed!
|
|
191
|
+
* }
|
|
192
|
+
* },
|
|
193
|
+
* POST: {
|
|
194
|
+
* summary: "Create user",
|
|
195
|
+
* requestBody: CreateUserSchema,
|
|
196
|
+
* responses: {
|
|
197
|
+
* 201: { description: "User created", schema: UserSchema }
|
|
198
|
+
* },
|
|
199
|
+
* handler: async ({ body, response }) => {
|
|
200
|
+
* const user = await createUser(body);
|
|
201
|
+
* return response.created(user); // Fully typed!
|
|
202
|
+
* }
|
|
203
|
+
* }
|
|
204
|
+
* });
|
|
205
|
+
* ```
|
|
206
|
+
*/
|
|
207
|
+
declare function defineOpenAPI(config: DefineOpenAPIConfig): DefineOpenAPIReturn;
|
|
208
|
+
/**
|
|
209
|
+
* Define OpenAPI document configuration with improved DX.
|
|
210
|
+
*
|
|
211
|
+
* Only allows specifying info and servers objects, ensuring a consistent
|
|
212
|
+
* OpenAPI v3.1.0 structure while preventing configuration of other fields.
|
|
213
|
+
*
|
|
214
|
+
* @param config Configuration object with info and optional servers
|
|
215
|
+
* @returns Complete OpenAPI configuration object
|
|
216
|
+
*
|
|
217
|
+
* @example
|
|
218
|
+
* ```typescript
|
|
219
|
+
* export const openAPIConfig = defineOpenAPIConfig({
|
|
220
|
+
* info: {
|
|
221
|
+
* title: "My API",
|
|
222
|
+
* version: "1.0.0",
|
|
223
|
+
* description: "API v1 - Authentication and core features",
|
|
224
|
+
* contact: {
|
|
225
|
+
* name: "API Support",
|
|
226
|
+
* email: "support@example.com",
|
|
227
|
+
* },
|
|
228
|
+
* },
|
|
229
|
+
* servers: [
|
|
230
|
+
* {
|
|
231
|
+
* url: process.env.API_URL || "http://localhost:8000",
|
|
232
|
+
* description: "API Server",
|
|
233
|
+
* },
|
|
234
|
+
* ],
|
|
235
|
+
* });
|
|
236
|
+
* ```
|
|
237
|
+
*/
|
|
238
|
+
declare function defineOpenAPIConfig<TContainer extends Container = Container>(config: (container: TContainer) => DefineOpenAPIConfigInput): (container: TContainer) => OpenAPIObjectConfigV31;
|
|
239
|
+
/**
|
|
240
|
+
* Route module type for scanned API routes
|
|
241
|
+
*/
|
|
242
|
+
type RouteModule = {
|
|
243
|
+
path: string;
|
|
244
|
+
filePath: string;
|
|
245
|
+
handlers: Record<string, RequestHandler>;
|
|
246
|
+
openAPISpec: OpenAPIRegistration[];
|
|
247
|
+
version?: string;
|
|
248
|
+
};
|
|
249
|
+
/**
|
|
250
|
+
* Generate complete OpenAPI 3.1.0 document from routes using zod-openapi
|
|
251
|
+
*/
|
|
252
|
+
declare function generateOpenAPIDocument(routes: RouteModule[], version: string, config?: DefineOpenAPIConfigInput): _node_modules_zod_openapi_dist_components_B1DX_zYv_mjs0.it;
|
|
253
|
+
/**
|
|
254
|
+
* Scan routes directory and convert to Express route paths using remix-flat-routes.
|
|
255
|
+
*/
|
|
256
|
+
declare function scanAPIRoutes(container: Container): Promise<RouteModule[]>;
|
|
257
|
+
/**
|
|
258
|
+
* Register scanned routes with Express app.
|
|
259
|
+
*/
|
|
260
|
+
declare function registerRoutes(app: Express, routes: RouteModule[]): void;
|
|
261
|
+
/**
|
|
262
|
+
* Write OpenAPI specs to api/public/openapi directory.
|
|
263
|
+
*/
|
|
264
|
+
declare function writeOpenAPISpecs<TContainer extends Container>(container: TContainer, routes: RouteModule[]): Promise<void>;
|
|
265
|
+
/**
|
|
266
|
+
* Load and register API routes with Express (convenience function).
|
|
267
|
+
* Also auto-generates OpenAPI specs in development mode.
|
|
268
|
+
*/
|
|
269
|
+
declare function loadAndRegisterAPIRoutes<TContainer extends Container>(app: Express): Promise<void>;
|
|
270
|
+
//#endregion
|
|
271
|
+
export { DefineOpenAPIConfig, DefineOpenAPIConfigInput, DefineOpenAPIReturn, HandlerParams, OpenAPIMethodSpec, OpenAPIObjectConfigV31, OpenAPIRegistration, RouteModule, ValidationErrorResponse, appDir, defineOpenAPI, defineOpenAPIConfig, defineOpenAPIEndpoint, defineTypedResponses, generateOpenAPIDocument, loadAndRegisterAPIRoutes, registerRoutes, scanAPIRoutes, writeOpenAPISpecs };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { __export, __reExport } from "../../../../_virtual/rolldown_runtime.mjs";
|
|
2
|
+
import { index, isPgEnum, isPgMaterializedView, isPgSchema, isPgSequence, isPgView, numeric, parsePgArray, parsePgNestedArray, pgEnum, pgMaterializedView, pgPolicy, pgRole, pgSchema, pgSequence, pgTable as pgTable$1, pgTableCreator, pgView, serial, smallint, smallserial, sparsevec, unique, uniqueIndex, uniqueKeyName, withReplicas } from "drizzle-orm/pg-core";
|
|
3
|
+
export * from "drizzle-orm";
|
|
4
|
+
export * from "drizzle-seed";
|
|
5
|
+
|
|
6
|
+
//#region src/api/orm.d.ts
|
|
7
|
+
declare namespace orm_d_exports {
|
|
8
|
+
export { index, isPgEnum, isPgMaterializedView, isPgSchema, isPgSequence, isPgView, numeric, parsePgArray, parsePgNestedArray, pgEnum, pgMaterializedView, pgPolicy, pgRole, pgSchema, pgSequence, pgTable$1 as pgTable, pgTableCreator, pgView, serial, smallint, smallserial, sparsevec, unique, uniqueIndex, uniqueKeyName, withReplicas };
|
|
9
|
+
}
|
|
10
|
+
import * as import_drizzle_orm from "drizzle-orm";
|
|
11
|
+
import * as import_drizzle_seed from "drizzle-seed";
|
|
12
|
+
//#endregion
|
|
13
|
+
export { import_drizzle_seed as orm_d_exports };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { instrumentation_d_exports } from "../instrumentation.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/api/otel.d.ts
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Wraps an async function with an OpenTelemetry span for distributed tracing.
|
|
7
|
+
*
|
|
8
|
+
* Automatically handles span lifecycle (start/end), error recording, and context propagation.
|
|
9
|
+
* The span will appear as a child of the currently active span (if any).
|
|
10
|
+
*
|
|
11
|
+
* @param tracerName - Fully qualified module path (e.g., "api/routes/payouts", "packages/primitives/mailer")
|
|
12
|
+
* @param spanName - Operation name following {verb} {object} pattern (e.g., "fetch payouts", "send email")
|
|
13
|
+
* @param fn - The async function to execute within the span context. Receives span for custom attributes.
|
|
14
|
+
* @param attributes - Optional span attributes for high-cardinality data (IDs, counts, etc.).
|
|
15
|
+
* Use semantic conventions: https://opentelemetry.io/docs/specs/semconv/
|
|
16
|
+
* @returns Promise resolving to the function's return value.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* // Basic usage - simple business operation
|
|
20
|
+
* await withOtelSpan("api/routes/payouts", "fetch payouts", async () => {
|
|
21
|
+
* return await db.query.payouts.findMany();
|
|
22
|
+
* });
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* // With attributes and custom span data
|
|
26
|
+
* const payouts = await withOtelSpan(
|
|
27
|
+
* "api/routes/payouts",
|
|
28
|
+
* "fetch payouts",
|
|
29
|
+
* async (span) => {
|
|
30
|
+
* const results = await db.query.payouts.findMany();
|
|
31
|
+
* span.setAttribute("payouts.count", results.length);
|
|
32
|
+
* span.addEvent("cache.miss");
|
|
33
|
+
* return results;
|
|
34
|
+
* },
|
|
35
|
+
* { "payouts.limit": 100, "payouts.offset": 0 }
|
|
36
|
+
* );
|
|
37
|
+
*/
|
|
38
|
+
declare function withOtelSpan<T>(fn: (span: instrumentation_d_exports.Span) => Promise<T>, attributes?: Record<string, string | number | boolean>): Promise<T>;
|
|
39
|
+
//#endregion
|
|
40
|
+
export { withOtelSpan };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Logger } from "./logger.mjs";
|
|
2
|
+
import { createClient, createCluster } from "redis";
|
|
3
|
+
|
|
4
|
+
//#region src/api/redis.d.ts
|
|
5
|
+
type RedisClient = ReturnType<typeof createClient> | ReturnType<typeof createCluster>;
|
|
6
|
+
/**
|
|
7
|
+
* Options for defining a Redis client.
|
|
8
|
+
*/
|
|
9
|
+
interface DefineRedisClientOptions {
|
|
10
|
+
/**
|
|
11
|
+
* Logger instance for error reporting.
|
|
12
|
+
*/
|
|
13
|
+
logger: Logger;
|
|
14
|
+
/**
|
|
15
|
+
* Redis URL(s). Single: "redis://localhost:6379", Cluster: comma-separated URLs
|
|
16
|
+
*/
|
|
17
|
+
url: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Defines Redis client based on URL format with lazy connection.
|
|
21
|
+
* Single URL → createClient(), comma-separated URLs → createCluster()
|
|
22
|
+
*
|
|
23
|
+
* Algorithm:
|
|
24
|
+
* 1. Split URL by comma to detect cluster vs single
|
|
25
|
+
* 2. Create appropriate client type
|
|
26
|
+
* 3. Attach error handler with label for debugging
|
|
27
|
+
* 4. Wrap in proxy that auto-connects on first use
|
|
28
|
+
*
|
|
29
|
+
* @param opts Options for defining the Redis client.
|
|
30
|
+
* @returns Redis client that auto-connects on first operation.
|
|
31
|
+
*/
|
|
32
|
+
declare function defineRedisClient(opts: DefineRedisClientOptions): RedisClient;
|
|
33
|
+
//#endregion
|
|
34
|
+
export { DefineRedisClientOptions, RedisClient, defineRedisClient };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createClient as e,createCluster as t}from"redis";export{};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{RedisStore as e}from"../../../../node_modules/.bun/rate-limit-redis@4.3.1_f1fa5524233c9c60/node_modules/rate-limit-redis/dist/index.mjs";import{defineErrorHandlerMiddleware as t}from"./middleware/error-handler.mjs";import{defineHealthMiddleware as n}from"./middleware/health.mjs";import{defineI18nMiddleware as r}from"./middleware/i18n.mjs";import{defineRequestLoggerMiddleware as i}from"./middleware/request-logger.mjs";import{defineShutdownMiddleware as a}from"./middleware/shutdown.mjs";import{defineTimeoutMiddleware as o}from"./middleware/timeout.mjs";import{loadMiddleware as s}from"./middleware.mjs";import{join as c}from"node:path";import l from"cors";import{rateLimit as u}from"express-rate-limit";import d from"helmet";import{createClient as f}from"redis";import p from"ultimate-express";async function m({container:m}){let h=!1,{host:g=`0.0.0.0`,port:_,timeout:v=3e4,bodyLimit:y=`1mb`,healthPath:b=`/health`,cors:x,helmet:S,rateLimit:C,redisUrl:w}=m.server,T=p();T.locals.container=m;let E=null;if(w&&C)try{E=f({url:w}),E.on(`error`,e=>{m.logger.error({error:e.message},`Redis client error`)}),await E.connect(),m.logger.info(`Connected to Redis for rate limiting`)}catch(e){m.logger.error({error:e instanceof Error?e.message:e},`Failed to connect to Redis, falling back to in-memory rate limiting`),E=null}if(T.use(a(m.logger,()=>h),o(m.logger,v),i(m.logger),n(b)),S!==void 0&&T.use(d(S)),x!==void 0&&T.use(l(x)),C)for(let[t,n]of C.entries()){let r=u({windowMs:n.windowMs??60*1e3,limit:n.limit??100,standardHeaders:n.standardHeaders??`draft-8`,legacyHeaders:n.legacyHeaders??!1,skip:n.skip,keyGenerator:n.keyGenerator,handler:n.handler,message:n.message,statusCode:n.statusCode,requestPropertyName:n.requestPropertyName,skipFailedRequests:n.skipFailedRequests,skipSuccessfulRequests:n.skipSuccessfulRequests,requestWasSuccessful:n.requestWasSuccessful,validate:n.validate,store:E?new e({sendCommand:(...e)=>E.sendCommand(e),prefix:`rl:${t}:`}):n.store});T.use(r)}if(T.use(r(m.i18n),p.json({limit:y}),p.urlencoded({extended:!0,limit:y})),await s(c(process.cwd(),`api`,`middleware`),m,T),T.get(`/`,(e,t)=>{t.json({message:`${m.config.APP_NAME} server is running.`})}),process.env.NODE_ENV!==`production`){let{defineYouchErrorHandler:e}=await import(`./middleware/youch-handler.mjs`);T.use(e(m.logger))}else T.use(t(m.logger));return{app:T,host:g,port:_,async start(){await new Promise((e,t)=>{try{T.listen(_,g,()=>{e()})}catch(e){t(e)}})},async close(){if(h=!0,T.uwsApp.close(),E)try{await E.destroy()}catch(e){m.logger.warn({error:e instanceof Error?e.message:e},`Error disconnecting from Redis`)}}}}export{m as defineServer};
|