wexts 4.1.0 → 4.1.5
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 +49 -49
- package/bin/wexts.cjs +2 -2
- package/package.json +153 -148
- package/templates/.dockerignore +43 -43
- package/templates/.env.example +17 -17
- package/templates/Dockerfile +60 -60
- package/templates/Procfile +1 -1
- package/templates/README.md +67 -67
- package/templates/api-sdk.ts +115 -115
- package/templates/docker-compose.yml +34 -34
- package/templates/nestjs-api/.env.example +3 -3
- package/templates/nestjs-api/README.md +87 -87
- package/templates/nestjs-api/nest-cli.json +6 -6
- package/templates/nestjs-api/package.json +40 -40
- package/templates/nestjs-api/prisma/migrations/20251123205437_init/migration.sql +24 -24
- package/templates/nestjs-api/prisma/migrations/migration_lock.toml +3 -3
- package/templates/nestjs-api/prisma/schema.prisma +29 -29
- package/templates/nestjs-api/src/app.module.ts +17 -17
- package/templates/nestjs-api/src/auth/auth.controller.ts +27 -27
- package/templates/nestjs-api/src/auth/auth.module.ts +37 -37
- package/templates/nestjs-api/src/auth/auth.service.ts +86 -86
- package/templates/nestjs-api/src/auth/dto/auth.dto.ts +22 -22
- package/templates/nestjs-api/src/auth/guards/jwt-auth.guard.ts +5 -5
- package/templates/nestjs-api/src/auth/strategies/jwt.strategy.ts +27 -27
- package/templates/nestjs-api/src/main.ts +32 -32
- package/templates/nestjs-api/src/prisma/prisma.module.ts +9 -9
- package/templates/nestjs-api/src/prisma/prisma.service.ts +14 -14
- package/templates/nestjs-api/src/todos/dto/todo.dto.ts +24 -24
- package/templates/nestjs-api/src/todos/todos.controller.ts +39 -39
- package/templates/nestjs-api/src/todos/todos.module.ts +11 -11
- package/templates/nestjs-api/src/todos/todos.service.ts +53 -53
- package/templates/nestjs-api/src/users/users.controller.ts +14 -14
- package/templates/nestjs-api/src/users/users.module.ts +12 -12
- package/templates/nestjs-api/src/users/users.service.ts +19 -19
- package/templates/nestjs-api/tsconfig.json +39 -39
- package/templates/nextjs-web/README.md +76 -76
- package/templates/nextjs-web/app/actions/auth.ts +108 -108
- package/templates/nextjs-web/app/dashboard/error.tsx +39 -39
- package/templates/nextjs-web/app/dashboard/loading.tsx +14 -14
- package/templates/nextjs-web/app/dashboard/page.tsx +5 -5
- package/templates/nextjs-web/app/globals.css +93 -93
- package/templates/nextjs-web/app/layout.tsx +29 -29
- package/templates/nextjs-web/app/login/page.tsx +5 -5
- package/templates/nextjs-web/app/page.tsx +28 -28
- package/templates/nextjs-web/app/register/page.tsx +5 -5
- package/templates/nextjs-web/components/ui/button.tsx +56 -56
- package/templates/nextjs-web/components/ui/card.tsx +79 -79
- package/templates/nextjs-web/components/ui/input.tsx +25 -25
- package/templates/nextjs-web/components/ui/label.tsx +24 -24
- package/templates/nextjs-web/features/auth/LoginForm.tsx +140 -140
- package/templates/nextjs-web/features/auth/RegisterForm.tsx +159 -159
- package/templates/nextjs-web/features/auth/api.ts +35 -35
- package/templates/nextjs-web/features/auth/index.ts +3 -3
- package/templates/nextjs-web/features/dashboard/DashboardView.tsx +204 -204
- package/templates/nextjs-web/features/dashboard/api.ts +9 -9
- package/templates/nextjs-web/features/dashboard/components.tsx +74 -74
- package/templates/nextjs-web/features/dashboard/index.ts +3 -3
- package/templates/nextjs-web/hooks/index.ts +4 -4
- package/templates/nextjs-web/lib/api-client.ts +89 -89
- package/templates/nextjs-web/lib/api.ts +115 -115
- package/templates/nextjs-web/lib/axios-global-config.ts +17 -17
- package/templates/nextjs-web/lib/utils.ts +6 -6
- package/templates/nextjs-web/lib/wexts-client.ts +4 -4
- package/templates/nextjs-web/next-env.d.ts +6 -6
- package/templates/nextjs-web/next.config.ts +20 -20
- package/templates/nextjs-web/package.json +37 -37
- package/templates/nextjs-web/postcss.config.js +6 -6
- package/templates/nextjs-web/tailwind.config.ts +69 -69
- package/templates/nextjs-web/tsconfig.json +41 -41
- package/templates/nixpacks.toml +11 -11
- package/templates/root-package.json +31 -31
- package/templates/server.ts +66 -66
- package/templates/tsconfig.json +30 -30
- package/dist/chunk-2KAQYLVN.js +0 -1
- package/dist/chunk-2KAQYLVN.js.map +0 -1
- package/dist/chunk-2LJVUMXW.js +0 -228
- package/dist/chunk-2LJVUMXW.js.map +0 -1
- package/dist/chunk-342VRT25.mjs +0 -504
- package/dist/chunk-342VRT25.mjs.map +0 -1
- package/dist/chunk-7HNQWJWV.js +0 -504
- package/dist/chunk-7HNQWJWV.js.map +0 -1
- package/dist/chunk-7QKLIVRF.js +0 -94
- package/dist/chunk-7QKLIVRF.js.map +0 -1
- package/dist/chunk-7SSCNCTW.mjs +0 -137
- package/dist/chunk-7SSCNCTW.mjs.map +0 -1
- package/dist/chunk-7TLSPR65.mjs +0 -95
- package/dist/chunk-7TLSPR65.mjs.map +0 -1
- package/dist/chunk-7WULUGLH.mjs +0 -22
- package/dist/chunk-7WULUGLH.mjs.map +0 -1
- package/dist/chunk-AVMQJWYD.js +0 -95
- package/dist/chunk-AVMQJWYD.js.map +0 -1
- package/dist/chunk-BG56B4DE.js +0 -106
- package/dist/chunk-BG56B4DE.js.map +0 -1
- package/dist/chunk-CLM5PNSG.mjs +0 -496
- package/dist/chunk-CLM5PNSG.mjs.map +0 -1
- package/dist/chunk-DNLGCKTT.js +0 -31
- package/dist/chunk-DNLGCKTT.js.map +0 -1
- package/dist/chunk-JHOVXH3X.mjs +0 -65
- package/dist/chunk-JHOVXH3X.mjs.map +0 -1
- package/dist/chunk-MXINIFPC.js +0 -105
- package/dist/chunk-MXINIFPC.js.map +0 -1
- package/dist/chunk-O4II6N34.js +0 -137
- package/dist/chunk-O4II6N34.js.map +0 -1
- package/dist/chunk-SE32ZPOZ.js +0 -496
- package/dist/chunk-SE32ZPOZ.js.map +0 -1
- package/dist/chunk-UAL54DVV.mjs +0 -106
- package/dist/chunk-UAL54DVV.mjs.map +0 -1
- package/dist/chunk-WCKSKU3C.js +0 -65
- package/dist/chunk-WCKSKU3C.js.map +0 -1
- package/dist/chunk-WU6FW77M.mjs +0 -105
- package/dist/chunk-WU6FW77M.mjs.map +0 -1
- package/dist/chunk-XE4OXN2W.js +0 -12
- package/dist/chunk-XE4OXN2W.js.map +0 -1
- package/dist/chunk-YBM3IJEA.mjs +0 -94
- package/dist/chunk-YBM3IJEA.mjs.map +0 -1
- package/dist/chunk-YN6WIWNQ.mjs +0 -228
- package/dist/chunk-YN6WIWNQ.mjs.map +0 -1
- package/dist/chunk-YSLEF5C5.mjs +0 -1
- package/dist/chunk-YSLEF5C5.mjs.map +0 -1
- package/dist/chunk-ZX7QIN24.mjs +0 -31
- package/dist/chunk-ZX7QIN24.mjs.map +0 -1
- package/dist/cli/index.d.mts +0 -23
- package/dist/cli/index.d.ts +0 -23
- package/dist/cli/index.js +0 -716
- package/dist/cli/index.js.map +0 -1
- package/dist/cli/index.mjs +0 -718
- package/dist/cli/index.mjs.map +0 -1
- package/dist/client/index.d.mts +0 -21
- package/dist/client/index.d.ts +0 -21
- package/dist/client/index.js +0 -13
- package/dist/client/index.js.map +0 -1
- package/dist/client/index.mjs +0 -13
- package/dist/client/index.mjs.map +0 -1
- package/dist/codegen/index.d.mts +0 -2
- package/dist/codegen/index.d.ts +0 -2
- package/dist/codegen/index.js +0 -16
- package/dist/codegen/index.js.map +0 -1
- package/dist/codegen/index.mjs +0 -16
- package/dist/codegen/index.mjs.map +0 -1
- package/dist/decorators-BT1FFqN0.d.mts +0 -29
- package/dist/decorators-DvS58PqC.d.ts +0 -29
- package/dist/dev-server/index.d.mts +0 -1
- package/dist/dev-server/index.d.ts +0 -1
- package/dist/dev-server/index.js +0 -13
- package/dist/dev-server/index.js.map +0 -1
- package/dist/dev-server/index.mjs +0 -13
- package/dist/dev-server/index.mjs.map +0 -1
- package/dist/index-7QeQEf37.d.ts +0 -92
- package/dist/index-7RvU-jGE.d.mts +0 -66
- package/dist/index-7RvU-jGE.d.ts +0 -66
- package/dist/index-8nzxy0NN.d.mts +0 -92
- package/dist/index-Co5ZsLqq.d.ts +0 -58
- package/dist/index-D94W1__r.d.mts +0 -58
- package/dist/index-DQmyVp6F.d.mts +0 -27
- package/dist/index-KL_1BrQb.d.ts +0 -27
- package/dist/index.d.mts +0 -294
- package/dist/index.d.ts +0 -294
- package/dist/index.js +0 -424
- package/dist/index.js.map +0 -1
- package/dist/index.mjs +0 -424
- package/dist/index.mjs.map +0 -1
- package/dist/nest/index.d.mts +0 -3
- package/dist/nest/index.d.ts +0 -3
- package/dist/nest/index.js +0 -38
- package/dist/nest/index.js.map +0 -1
- package/dist/nest/index.mjs +0 -38
- package/dist/nest/index.mjs.map +0 -1
- package/dist/next/index.d.mts +0 -66
- package/dist/next/index.d.ts +0 -66
- package/dist/next/index.js +0 -289
- package/dist/next/index.js.map +0 -1
- package/dist/next/index.mjs +0 -251
- package/dist/next/index.mjs.map +0 -1
- package/dist/rpc/index.d.mts +0 -2
- package/dist/rpc/index.d.ts +0 -2
- package/dist/rpc/index.js +0 -23
- package/dist/rpc/index.js.map +0 -1
- package/dist/rpc/index.mjs +0 -23
- package/dist/rpc/index.mjs.map +0 -1
- package/dist/runtime/index.d.mts +0 -55
- package/dist/runtime/index.d.ts +0 -55
- package/dist/runtime/index.js +0 -221
- package/dist/runtime/index.js.map +0 -1
- package/dist/runtime/index.mjs +0 -221
- package/dist/runtime/index.mjs.map +0 -1
- package/dist/types/index.d.mts +0 -12
- package/dist/types/index.d.ts +0 -12
- package/dist/types/index.js +0 -2
- package/dist/types/index.js.map +0 -1
- package/dist/types/index.mjs +0 -3
- package/dist/types/index.mjs.map +0 -1
- package/dist/types-7d_fC-C3.d.mts +0 -32
- package/dist/types-7d_fC-C3.d.ts +0 -32
- package/dist/vercel-builder/index.d.mts +0 -58
- package/dist/vercel-builder/index.d.ts +0 -58
- package/dist/vercel-builder/index.js +0 -330
- package/dist/vercel-builder/index.js.map +0 -1
- package/dist/vercel-builder/index.mjs +0 -330
- package/dist/vercel-builder/index.mjs.map +0 -1
package/dist/runtime/index.mjs
DELETED
|
@@ -1,221 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
WextsRuntimeError
|
|
3
|
-
} from "../chunk-7TLSPR65.mjs";
|
|
4
|
-
import {
|
|
5
|
-
__name
|
|
6
|
-
} from "../chunk-7WULUGLH.mjs";
|
|
7
|
-
|
|
8
|
-
// src/runtime/rpc-router.ts
|
|
9
|
-
async function registerRpcRoutes(fastify, options) {
|
|
10
|
-
const serviceMap = new Map(options.manifest.services.map((service) => [
|
|
11
|
-
service.name,
|
|
12
|
-
service
|
|
13
|
-
]));
|
|
14
|
-
fastify.post("/rpc/:service/:method", async (request, reply) => {
|
|
15
|
-
const service = serviceMap.get(request.params.service);
|
|
16
|
-
if (!service) {
|
|
17
|
-
reply.status(404);
|
|
18
|
-
return {
|
|
19
|
-
error: "WEXTS_RPC_SERVICE_NOT_FOUND"
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
const method = service.methods.find((candidate) => candidate.name === request.params.method);
|
|
23
|
-
if (!method) {
|
|
24
|
-
reply.status(404);
|
|
25
|
-
return {
|
|
26
|
-
error: "WEXTS_RPC_METHOD_NOT_FOUND"
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
if (method.requireAuth || service.requireAuth) {
|
|
30
|
-
const authorized = await options.authorize?.(request, service, method.name);
|
|
31
|
-
if (!authorized) {
|
|
32
|
-
reply.status(401);
|
|
33
|
-
return {
|
|
34
|
-
error: "WEXTS_RPC_AUTH_REQUIRED"
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
const instance = options.services[service.name];
|
|
39
|
-
const handler = instance?.[method.handlerName];
|
|
40
|
-
if (!handler) {
|
|
41
|
-
reply.status(500);
|
|
42
|
-
return {
|
|
43
|
-
error: "WEXTS_RPC_HANDLER_NOT_BOUND"
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
const args = Array.isArray(request.body?.args) ? request.body.args : [];
|
|
47
|
-
const data = await handler.apply(instance, args);
|
|
48
|
-
return {
|
|
49
|
-
data
|
|
50
|
-
};
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
__name(registerRpcRoutes, "registerRpcRoutes");
|
|
54
|
-
|
|
55
|
-
// src/runtime/server.ts
|
|
56
|
-
import * as fs from "fs";
|
|
57
|
-
import * as path from "path";
|
|
58
|
-
import Fastify from "fastify";
|
|
59
|
-
import { registerWextsShield } from "@wexts/security";
|
|
60
|
-
async function createWextsRuntimeServer(config = {}) {
|
|
61
|
-
const rootDir = path.resolve(config.rootDir ?? process.cwd());
|
|
62
|
-
const fastify = Fastify({
|
|
63
|
-
logger: config.logger ?? true,
|
|
64
|
-
bodyLimit: config.security?.bodyLimitBytes ?? 1048576,
|
|
65
|
-
requestTimeout: config.security?.requestTimeoutMs ?? 3e4
|
|
66
|
-
});
|
|
67
|
-
const manifest = config.rpcManifest ?? loadJson(rootDir, config.rpcManifestPath);
|
|
68
|
-
const routePolicies = [
|
|
69
|
-
...config.security?.routePolicies ?? [],
|
|
70
|
-
...rpcPoliciesFromManifest(manifest)
|
|
71
|
-
];
|
|
72
|
-
await registerWextsShield(fastify, {
|
|
73
|
-
...config.security,
|
|
74
|
-
routePolicies
|
|
75
|
-
});
|
|
76
|
-
fastify.get("/health", async () => ({
|
|
77
|
-
ok: true,
|
|
78
|
-
runtime: "wexts"
|
|
79
|
-
}));
|
|
80
|
-
fastify.get("/api/health", async () => ({
|
|
81
|
-
ok: true,
|
|
82
|
-
runtime: "wexts",
|
|
83
|
-
scope: "api"
|
|
84
|
-
}));
|
|
85
|
-
if (manifest && config.rpcServices) {
|
|
86
|
-
await registerRpcRoutes(fastify, {
|
|
87
|
-
manifest,
|
|
88
|
-
services: config.rpcServices,
|
|
89
|
-
authorize: /* @__PURE__ */ __name((request) => Boolean(request.headers.authorization || request.headers.cookie), "authorize")
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
if (config.nestAppModule || config.nestAppModulePath) {
|
|
93
|
-
await mountNest(fastify, rootDir, config);
|
|
94
|
-
}
|
|
95
|
-
if (config.nextDir) {
|
|
96
|
-
await mountNext(fastify, rootDir, config);
|
|
97
|
-
}
|
|
98
|
-
const start = /* @__PURE__ */ __name(async () => {
|
|
99
|
-
await fastify.listen({
|
|
100
|
-
port: config.port ?? Number(process.env.PORT ?? 3e3),
|
|
101
|
-
host: config.host ?? "0.0.0.0"
|
|
102
|
-
});
|
|
103
|
-
}, "start");
|
|
104
|
-
const close = /* @__PURE__ */ __name(async () => {
|
|
105
|
-
await fastify.close();
|
|
106
|
-
}, "close");
|
|
107
|
-
registerShutdown(close);
|
|
108
|
-
return {
|
|
109
|
-
fastify,
|
|
110
|
-
start,
|
|
111
|
-
close
|
|
112
|
-
};
|
|
113
|
-
}
|
|
114
|
-
__name(createWextsRuntimeServer, "createWextsRuntimeServer");
|
|
115
|
-
async function startWextsRuntime(config = {}) {
|
|
116
|
-
const server = await createWextsRuntimeServer(config);
|
|
117
|
-
await server.start();
|
|
118
|
-
return server;
|
|
119
|
-
}
|
|
120
|
-
__name(startWextsRuntime, "startWextsRuntime");
|
|
121
|
-
function rpcPoliciesFromManifest(manifest) {
|
|
122
|
-
if (!manifest) return [];
|
|
123
|
-
return manifest.services.flatMap((service) => service.methods.map((method) => ({
|
|
124
|
-
path: `/rpc/${service.name}/${method.name}`,
|
|
125
|
-
methods: [
|
|
126
|
-
"POST"
|
|
127
|
-
],
|
|
128
|
-
mode: service.requireAuth || method.requireAuth ? "requireAuth" : "public"
|
|
129
|
-
})));
|
|
130
|
-
}
|
|
131
|
-
__name(rpcPoliciesFromManifest, "rpcPoliciesFromManifest");
|
|
132
|
-
function loadJson(rootDir, filePath) {
|
|
133
|
-
if (!filePath) return void 0;
|
|
134
|
-
const absolutePath = path.isAbsolute(filePath) ? filePath : path.join(rootDir, filePath);
|
|
135
|
-
if (!fs.existsSync(absolutePath)) return void 0;
|
|
136
|
-
return JSON.parse(fs.readFileSync(absolutePath, "utf8"));
|
|
137
|
-
}
|
|
138
|
-
__name(loadJson, "loadJson");
|
|
139
|
-
async function mountNest(fastify, rootDir, config) {
|
|
140
|
-
const [{ NestFactory }, { FastifyAdapter }] = await Promise.all([
|
|
141
|
-
import("@nestjs/core"),
|
|
142
|
-
import("@nestjs/platform-fastify")
|
|
143
|
-
]);
|
|
144
|
-
const AppModule = config.nestAppModule ?? await importModule(rootDir, config.nestAppModulePath);
|
|
145
|
-
const moduleValue = AppModule.AppModule ?? AppModule;
|
|
146
|
-
const nestApp = await NestFactory.create(moduleValue, new FastifyAdapter(fastify), {
|
|
147
|
-
logger: config.dev ? [
|
|
148
|
-
"log",
|
|
149
|
-
"error",
|
|
150
|
-
"warn"
|
|
151
|
-
] : [
|
|
152
|
-
"error",
|
|
153
|
-
"warn"
|
|
154
|
-
]
|
|
155
|
-
});
|
|
156
|
-
nestApp.setGlobalPrefix("api");
|
|
157
|
-
await nestApp.init();
|
|
158
|
-
}
|
|
159
|
-
__name(mountNest, "mountNest");
|
|
160
|
-
async function mountNext(fastify, rootDir, config) {
|
|
161
|
-
const nextModule = await import("next");
|
|
162
|
-
const next = nextModule.default;
|
|
163
|
-
if (!next) {
|
|
164
|
-
throw new WextsRuntimeError({
|
|
165
|
-
code: "WEXTS_RUNTIME_NEXT_MISSING",
|
|
166
|
-
message: "Next.js could not be loaded. Install next or omit nextDir.",
|
|
167
|
-
suggestedFix: "Install `next` in the application or remove `nextDir` from wexts.runtime.js.",
|
|
168
|
-
docsSlug: "runtime"
|
|
169
|
-
});
|
|
170
|
-
}
|
|
171
|
-
const nextApp = next({
|
|
172
|
-
dev: config.dev ?? process.env.NODE_ENV !== "production",
|
|
173
|
-
dir: path.isAbsolute(config.nextDir) ? config.nextDir : path.join(rootDir, config.nextDir)
|
|
174
|
-
});
|
|
175
|
-
await nextApp.prepare();
|
|
176
|
-
const handler = nextApp.getRequestHandler();
|
|
177
|
-
fastify.all("/*", async (request, reply) => {
|
|
178
|
-
await handler(request.raw, reply.raw);
|
|
179
|
-
reply.hijack();
|
|
180
|
-
});
|
|
181
|
-
}
|
|
182
|
-
__name(mountNext, "mountNext");
|
|
183
|
-
async function importModule(rootDir, modulePath) {
|
|
184
|
-
const absolutePath = path.isAbsolute(modulePath) ? modulePath : path.join(rootDir, modulePath);
|
|
185
|
-
return import(pathToFileUrl(absolutePath));
|
|
186
|
-
}
|
|
187
|
-
__name(importModule, "importModule");
|
|
188
|
-
function pathToFileUrl(filePath) {
|
|
189
|
-
return `file://${filePath}`;
|
|
190
|
-
}
|
|
191
|
-
__name(pathToFileUrl, "pathToFileUrl");
|
|
192
|
-
function registerShutdown(close) {
|
|
193
|
-
const handler = /* @__PURE__ */ __name(async () => {
|
|
194
|
-
await close();
|
|
195
|
-
process.exit(0);
|
|
196
|
-
}, "handler");
|
|
197
|
-
process.once("SIGINT", handler);
|
|
198
|
-
process.once("SIGTERM", handler);
|
|
199
|
-
}
|
|
200
|
-
__name(registerShutdown, "registerShutdown");
|
|
201
|
-
|
|
202
|
-
// src/runtime/vercel-handler.ts
|
|
203
|
-
async function createWextsHandler(config = {}) {
|
|
204
|
-
const server = await createWextsRuntimeServer({
|
|
205
|
-
...config,
|
|
206
|
-
// Serverless does not use long-lived logging
|
|
207
|
-
logger: config.logger ?? false
|
|
208
|
-
});
|
|
209
|
-
await server.fastify.ready();
|
|
210
|
-
return (req, res) => {
|
|
211
|
-
server.fastify.server.emit("request", req, res);
|
|
212
|
-
};
|
|
213
|
-
}
|
|
214
|
-
__name(createWextsHandler, "createWextsHandler");
|
|
215
|
-
export {
|
|
216
|
-
createWextsHandler,
|
|
217
|
-
createWextsRuntimeServer,
|
|
218
|
-
registerRpcRoutes,
|
|
219
|
-
startWextsRuntime
|
|
220
|
-
};
|
|
221
|
-
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/runtime/rpc-router.ts","../../src/runtime/server.ts","../../src/runtime/vercel-handler.ts"],"sourcesContent":["import type { FastifyInstance, FastifyReply, FastifyRequest } from 'fastify';\nimport type { RpcManifest, RpcServiceManifest } from '../rpc/types';\n\nexport type RpcServiceInstances = Record<string, Record<string, (...args: unknown[]) => unknown | Promise<unknown>>>;\n\nexport interface RegisterRpcRoutesOptions {\n manifest: RpcManifest;\n services: RpcServiceInstances;\n authorize?: (request: FastifyRequest, service: RpcServiceManifest, methodName: string) => boolean | Promise<boolean>;\n}\n\nexport async function registerRpcRoutes(fastify: FastifyInstance, options: RegisterRpcRoutesOptions): Promise<void> {\n const serviceMap = new Map(options.manifest.services.map((service) => [service.name, service]));\n\n fastify.post('/rpc/:service/:method', async (request: FastifyRequest<{\n Params: { service: string; method: string };\n Body: { args?: unknown[] };\n }>, reply: FastifyReply) => {\n const service = serviceMap.get(request.params.service);\n if (!service) {\n reply.status(404);\n return { error: 'WEXTS_RPC_SERVICE_NOT_FOUND' };\n }\n\n const method = service.methods.find((candidate) => candidate.name === request.params.method);\n if (!method) {\n reply.status(404);\n return { error: 'WEXTS_RPC_METHOD_NOT_FOUND' };\n }\n\n if (method.requireAuth || service.requireAuth) {\n const authorized = await options.authorize?.(request, service, method.name);\n if (!authorized) {\n reply.status(401);\n return { error: 'WEXTS_RPC_AUTH_REQUIRED' };\n }\n }\n\n const instance = options.services[service.name];\n const handler = instance?.[method.handlerName];\n if (!handler) {\n reply.status(500);\n return { error: 'WEXTS_RPC_HANDLER_NOT_BOUND' };\n }\n\n const args = Array.isArray(request.body?.args) ? request.body.args : [];\n const data = await handler.apply(instance, args);\n return { data };\n });\n}\n","import * as fs from 'fs';\nimport * as path from 'path';\nimport Fastify, { FastifyInstance, FastifyServerOptions } from 'fastify';\nimport { registerWextsShield, type WextsShieldConfig, type WextsShieldRoutePolicy } from '@wexts/security';\nimport type { RpcManifest } from '../rpc/types';\nimport { registerRpcRoutes, type RpcServiceInstances } from './rpc-router';\nimport { WextsRuntimeError } from '../errors';\n\nexport interface WextsRuntimeConfig {\n rootDir?: string;\n port?: number;\n host?: string;\n dev?: boolean;\n nextDir?: string;\n nestAppModule?: unknown;\n nestAppModulePath?: string;\n rpcManifest?: RpcManifest;\n rpcManifestPath?: string;\n rpcServices?: RpcServiceInstances;\n security?: WextsShieldConfig;\n logger?: FastifyServerOptions['logger'];\n}\n\nexport interface WextsRuntimeServer {\n fastify: FastifyInstance;\n start: () => Promise<void>;\n close: () => Promise<void>;\n}\n\nexport async function createWextsRuntimeServer(config: WextsRuntimeConfig = {}): Promise<WextsRuntimeServer> {\n const rootDir = path.resolve(config.rootDir ?? process.cwd());\n const fastify = Fastify({\n logger: config.logger ?? true,\n bodyLimit: config.security?.bodyLimitBytes ?? 1_048_576,\n requestTimeout: config.security?.requestTimeoutMs ?? 30_000,\n });\n\n const manifest = config.rpcManifest ?? loadJson<RpcManifest>(rootDir, config.rpcManifestPath);\n const routePolicies = [\n ...(config.security?.routePolicies ?? []),\n ...rpcPoliciesFromManifest(manifest),\n ];\n\n await registerWextsShield(fastify, {\n ...config.security,\n routePolicies,\n });\n\n fastify.get('/health', async () => ({\n ok: true,\n runtime: 'wexts',\n }));\n\n fastify.get('/api/health', async () => ({\n ok: true,\n runtime: 'wexts',\n scope: 'api',\n }));\n\n if (manifest && config.rpcServices) {\n await registerRpcRoutes(fastify, {\n manifest,\n services: config.rpcServices,\n authorize: (request) => Boolean(request.headers.authorization || request.headers.cookie),\n });\n }\n\n if (config.nestAppModule || config.nestAppModulePath) {\n await mountNest(fastify, rootDir, config);\n }\n\n if (config.nextDir) {\n await mountNext(fastify, rootDir, config);\n }\n\n const start = async () => {\n await fastify.listen({\n port: config.port ?? Number(process.env.PORT ?? 3000),\n host: config.host ?? '0.0.0.0',\n });\n };\n\n const close = async () => {\n await fastify.close();\n };\n\n registerShutdown(close);\n\n return {\n fastify,\n start,\n close,\n };\n}\n\nexport async function startWextsRuntime(config: WextsRuntimeConfig = {}): Promise<WextsRuntimeServer> {\n const server = await createWextsRuntimeServer(config);\n await server.start();\n return server;\n}\n\nfunction rpcPoliciesFromManifest(manifest?: RpcManifest): WextsShieldRoutePolicy[] {\n if (!manifest) return [];\n\n return manifest.services.flatMap((service) => service.methods.map((method) => ({\n path: `/rpc/${service.name}/${method.name}`,\n methods: ['POST'],\n mode: service.requireAuth || method.requireAuth ? 'requireAuth' : 'public',\n })));\n}\n\nfunction loadJson<T>(rootDir: string, filePath?: string): T | undefined {\n if (!filePath) return undefined;\n\n const absolutePath = path.isAbsolute(filePath) ? filePath : path.join(rootDir, filePath);\n if (!fs.existsSync(absolutePath)) return undefined;\n return JSON.parse(fs.readFileSync(absolutePath, 'utf8')) as T;\n}\n\nasync function mountNest(fastify: FastifyInstance, rootDir: string, config: WextsRuntimeConfig): Promise<void> {\n const [{ NestFactory }, { FastifyAdapter }] = await Promise.all([\n import('@nestjs/core'),\n import('@nestjs/platform-fastify'),\n ]);\n const AppModule = config.nestAppModule ?? await importModule(rootDir, config.nestAppModulePath!);\n const moduleValue = (AppModule as { AppModule?: unknown }).AppModule ?? AppModule;\n const nestApp = await NestFactory.create(moduleValue as never, new FastifyAdapter(fastify as never), {\n logger: config.dev ? ['log', 'error', 'warn'] : ['error', 'warn'],\n });\n nestApp.setGlobalPrefix('api');\n await nestApp.init();\n}\n\nasync function mountNext(fastify: FastifyInstance, rootDir: string, config: WextsRuntimeConfig): Promise<void> {\n const nextModule = await import('next') as unknown as { default?: (options: unknown) => { prepare: () => Promise<void>; getRequestHandler: () => (req: unknown, res: unknown) => Promise<void> } };\n const next = nextModule.default;\n if (!next) {\n throw new WextsRuntimeError({\n code: 'WEXTS_RUNTIME_NEXT_MISSING',\n message: 'Next.js could not be loaded. Install next or omit nextDir.',\n suggestedFix: 'Install `next` in the application or remove `nextDir` from wexts.runtime.js.',\n docsSlug: 'runtime',\n });\n }\n const nextApp = next({\n dev: config.dev ?? process.env.NODE_ENV !== 'production',\n dir: path.isAbsolute(config.nextDir!) ? config.nextDir : path.join(rootDir, config.nextDir!),\n });\n await nextApp.prepare();\n const handler = nextApp.getRequestHandler();\n\n fastify.all('/*', async (request, reply) => {\n await handler(request.raw, reply.raw);\n reply.hijack();\n });\n}\n\nasync function importModule(rootDir: string, modulePath: string): Promise<unknown> {\n const absolutePath = path.isAbsolute(modulePath) ? modulePath : path.join(rootDir, modulePath);\n return import(pathToFileUrl(absolutePath));\n}\n\nfunction pathToFileUrl(filePath: string): string {\n return `file://${filePath}`;\n}\n\nfunction registerShutdown(close: () => Promise<void>): void {\n const handler = async () => {\n await close();\n process.exit(0);\n };\n\n process.once('SIGINT', handler);\n process.once('SIGTERM', handler);\n}\n","/**\n * Vercel / serverless handler adapter for the Wexts runtime.\n *\n * Creates a standard Node.js (req, res) handler that delegates to the\n * Fastify-backed Wexts runtime **without** calling fastify.listen().\n *\n * Usage:\n * const handler = await createWextsHandler({ ... });\n * export default handler; // Vercel function entry\n */\n\nimport type { IncomingMessage, ServerResponse } from 'http';\nimport type { WextsRuntimeConfig } from './server';\nimport { createWextsRuntimeServer } from './server';\n\nexport type WextsHandler = (req: IncomingMessage, res: ServerResponse) => void;\n\n/**\n * Build a serverless-compatible handler from the Wexts runtime.\n * The returned function accepts Node http (req, res) and passes them\n * into the Fastify instance without ever calling listen().\n */\nexport async function createWextsHandler(\n config: WextsRuntimeConfig = {},\n): Promise<WextsHandler> {\n const server = await createWextsRuntimeServer({\n ...config,\n // Serverless does not use long-lived logging\n logger: config.logger ?? false,\n });\n\n // Fastify exposes a raw Node handler via server.server (the http.Server)\n // But we need to call .ready() first so all plugins are loaded.\n await server.fastify.ready();\n\n return (req: IncomingMessage, res: ServerResponse) => {\n server.fastify.server.emit('request', req, res);\n };\n}\n"],"mappings":";;;;;;;;AAWA,eAAsBA,kBAAkBC,SAA0BC,SAAiC;AAC/F,QAAMC,aAAa,IAAIC,IAAIF,QAAQG,SAASC,SAASC,IAAI,CAACC,YAAY;IAACA,QAAQC;IAAMD;GAAQ,CAAA;AAE7FP,UAAQS,KAAK,yBAAyB,OAAOC,SAGzCC,UAAAA;AACA,UAAMJ,UAAUL,WAAWU,IAAIF,QAAQG,OAAON,OAAO;AACrD,QAAI,CAACA,SAAS;AACVI,YAAM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ACJ;AACA,QAAMC,UAAUP,KAAK;IACjBJ,KAAK5E,OAAO4E,OAAOzE,QAAQuC,IAAI8C,aAAa;IAC5CC,KAAU5B,gBAAW7D,OAAOoC,OAAO,IAAKpC,OAAOoC,UAAe0B,UAAK7D,SAASD,OAAOoC,OAAO;EAC9F,CAAA;AACA,QAAMmD,QAAQG,QAAO;AACrB,QAAMC,UAAUJ,QAAQK,kBAAiB;AAEzCvF,UAAQiE,IAAI,MAAM,OAAO1C,SAASiE,UAAAA;AAC9B,UAAMF,QAAQ/D,QAAQkE,KAAKD,MAAMC,GAAG;AACpCD,UAAME,OAAM;EAChB,CAAA;AACJ;AAtBe1D;AAwBf,eAAemC,aAAavE,SAAiB+F,YAAkB;AAC3D,QAAMpC,eAAoBC,gBAAWmC,UAAAA,IAAcA,aAAkBlC,UAAK7D,SAAS+F,UAAAA;AACnF,SAAO,OAAOC,cAAcrC,YAAAA;AAChC;AAHeY;AAKf,SAASyB,cAAcvC,UAAgB;AACnC,SAAO,UAAUA,QAAAA;AACrB;AAFSuC;AAIT,SAASnD,iBAAiBD,OAA0B;AAChD,QAAM8C,UAAU,mCAAA;AACZ,UAAM9C,MAAAA;AACN1C,YAAQ+F,KAAK,CAAA;EACjB,GAHgB;AAKhB/F,UAAQgG,KAAK,UAAUR,OAAAA;AACvBxF,UAAQgG,KAAK,WAAWR,OAAAA;AAC5B;AARS7C;;;AChJT,eAAsBsD,mBAClBC,SAA6B,CAAC,GAAC;AAE/B,QAAMC,SAAS,MAAMC,yBAAyB;IAC1C,GAAGF;;IAEHG,QAAQH,OAAOG,UAAU;EAC7B,CAAA;AAIA,QAAMF,OAAOG,QAAQC,MAAK;AAE1B,SAAO,CAACC,KAAsBC,QAAAA;AAC1BN,WAAOG,QAAQH,OAAOO,KAAK,WAAWF,KAAKC,GAAAA;EAC/C;AACJ;AAhBsBR;","names":["registerRpcRoutes","fastify","options","serviceMap","Map","manifest","services","map","service","name","post","request","reply","get","params","status","error","method","methods","find","candidate","requireAuth","authorized","authorize","instance","handler","handlerName","args","Array","isArray","body","data","apply","fs","path","Fastify","registerWextsShield","createWextsRuntimeServer","config","rootDir","resolve","process","cwd","fastify","Fastify","logger","bodyLimit","security","bodyLimitBytes","requestTimeout","requestTimeoutMs","manifest","rpcManifest","loadJson","rpcManifestPath","routePolicies","rpcPoliciesFromManifest","registerWextsShield","get","ok","runtime","scope","rpcServices","registerRpcRoutes","services","authorize","request","Boolean","headers","authorization","cookie","nestAppModule","nestAppModulePath","mountNest","nextDir","mountNext","start","listen","port","Number","env","PORT","host","close","registerShutdown","startWextsRuntime","server","flatMap","service","methods","map","method","path","name","mode","requireAuth","filePath","undefined","absolutePath","isAbsolute","join","existsSync","JSON","parse","readFileSync","NestFactory","FastifyAdapter","Promise","all","AppModule","importModule","moduleValue","nestApp","create","dev","setGlobalPrefix","init","nextModule","next","default","WextsRuntimeError","code","message","suggestedFix","docsSlug","nextApp","NODE_ENV","dir","prepare","handler","getRequestHandler","reply","raw","hijack","modulePath","pathToFileUrl","exit","once","createWextsHandler","config","server","createWextsRuntimeServer","logger","fastify","ready","req","res","emit"]}
|
package/dist/types/index.d.mts
DELETED
package/dist/types/index.d.ts
DELETED
package/dist/types/index.js
DELETED
package/dist/types/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/Volumes/Projects/wexts/packages/dist/types/index.js"],"names":[],"mappings":"AAAA,6CAA6B","file":"/Volumes/Projects/wexts/packages/dist/types/index.js"}
|
package/dist/types/index.mjs
DELETED
package/dist/types/index.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
type RpcAuthPolicy = 'public' | 'required';
|
|
2
|
-
interface RpcParameterManifest {
|
|
3
|
-
name: string;
|
|
4
|
-
type: string;
|
|
5
|
-
optional: boolean;
|
|
6
|
-
}
|
|
7
|
-
interface RpcMethodManifest {
|
|
8
|
-
name: string;
|
|
9
|
-
handlerName: string;
|
|
10
|
-
requireAuth: boolean;
|
|
11
|
-
parameters: RpcParameterManifest[];
|
|
12
|
-
returnType: string;
|
|
13
|
-
}
|
|
14
|
-
interface RpcServiceManifest {
|
|
15
|
-
name: string;
|
|
16
|
-
className: string;
|
|
17
|
-
importPath: string;
|
|
18
|
-
requireAuth: boolean;
|
|
19
|
-
methods: RpcMethodManifest[];
|
|
20
|
-
}
|
|
21
|
-
interface RpcManifest {
|
|
22
|
-
schemaVersion: 1;
|
|
23
|
-
services: RpcServiceManifest[];
|
|
24
|
-
}
|
|
25
|
-
interface RpcInvocationRequest {
|
|
26
|
-
args: unknown[];
|
|
27
|
-
}
|
|
28
|
-
interface RpcInvocationResponse<T = unknown> {
|
|
29
|
-
data: T;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export type { RpcAuthPolicy as R, RpcInvocationRequest as a, RpcInvocationResponse as b, RpcManifest as c, RpcMethodManifest as d, RpcParameterManifest as e, RpcServiceManifest as f };
|
package/dist/types-7d_fC-C3.d.ts
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
type RpcAuthPolicy = 'public' | 'required';
|
|
2
|
-
interface RpcParameterManifest {
|
|
3
|
-
name: string;
|
|
4
|
-
type: string;
|
|
5
|
-
optional: boolean;
|
|
6
|
-
}
|
|
7
|
-
interface RpcMethodManifest {
|
|
8
|
-
name: string;
|
|
9
|
-
handlerName: string;
|
|
10
|
-
requireAuth: boolean;
|
|
11
|
-
parameters: RpcParameterManifest[];
|
|
12
|
-
returnType: string;
|
|
13
|
-
}
|
|
14
|
-
interface RpcServiceManifest {
|
|
15
|
-
name: string;
|
|
16
|
-
className: string;
|
|
17
|
-
importPath: string;
|
|
18
|
-
requireAuth: boolean;
|
|
19
|
-
methods: RpcMethodManifest[];
|
|
20
|
-
}
|
|
21
|
-
interface RpcManifest {
|
|
22
|
-
schemaVersion: 1;
|
|
23
|
-
services: RpcServiceManifest[];
|
|
24
|
-
}
|
|
25
|
-
interface RpcInvocationRequest {
|
|
26
|
-
args: unknown[];
|
|
27
|
-
}
|
|
28
|
-
interface RpcInvocationResponse<T = unknown> {
|
|
29
|
-
data: T;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export type { RpcAuthPolicy as R, RpcInvocationRequest as a, RpcInvocationResponse as b, RpcManifest as c, RpcMethodManifest as d, RpcParameterManifest as e, RpcServiceManifest as f };
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Wexts Vercel Build Output API builder.
|
|
3
|
-
*
|
|
4
|
-
* Produces the `.vercel/output` tree (Build Output API v3) that Vercel
|
|
5
|
-
* uses for deployment. This module is invoked by `wexts vercel-build`.
|
|
6
|
-
*
|
|
7
|
-
* Layout produced:
|
|
8
|
-
* .vercel/output/
|
|
9
|
-
* config.json – { version: 3 }
|
|
10
|
-
* static/ – public / static assets copied here
|
|
11
|
-
* functions/
|
|
12
|
-
* index.func/
|
|
13
|
-
* index.js – serverless entry point
|
|
14
|
-
* package.json – { type: "module" } or cjs
|
|
15
|
-
* .vc-config.json – Vercel function config
|
|
16
|
-
* ...copied runtime files
|
|
17
|
-
*/
|
|
18
|
-
interface VercelBuildOptions {
|
|
19
|
-
/** Project root (cwd). Defaults to process.cwd(). */
|
|
20
|
-
rootDir?: string;
|
|
21
|
-
/** Path to NestJS/API project for codegen. */
|
|
22
|
-
apiProjectPath?: string;
|
|
23
|
-
/** Output directory for generated RPC client. */
|
|
24
|
-
rpcOutputPath?: string;
|
|
25
|
-
/** Path to wexts.runtime.js config. */
|
|
26
|
-
runtimeConfigPath?: string;
|
|
27
|
-
/** Node.js runtime version for the Vercel function. */
|
|
28
|
-
nodeVersion?: string;
|
|
29
|
-
/** Max duration in seconds for the serverless function. */
|
|
30
|
-
maxDuration?: number;
|
|
31
|
-
/** Memory size in MB for the serverless function. */
|
|
32
|
-
memory?: number;
|
|
33
|
-
/** Regions to deploy to. */
|
|
34
|
-
regions?: string[];
|
|
35
|
-
/** Skip the RPC codegen step. */
|
|
36
|
-
skipCodegen?: boolean;
|
|
37
|
-
/** Skip the Next.js / project build step. */
|
|
38
|
-
skipBuild?: boolean;
|
|
39
|
-
}
|
|
40
|
-
interface VercelBuildResult {
|
|
41
|
-
outputDir: string;
|
|
42
|
-
configPath: string;
|
|
43
|
-
functionDir: string;
|
|
44
|
-
staticDir: string;
|
|
45
|
-
errors: string[];
|
|
46
|
-
warnings: string[];
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Build the `.vercel/output` directory from a Wexts project.
|
|
50
|
-
*/
|
|
51
|
-
declare function buildVercelOutput(options?: VercelBuildOptions): Promise<VercelBuildResult>;
|
|
52
|
-
interface ValidationResult {
|
|
53
|
-
errors: string[];
|
|
54
|
-
warnings: string[];
|
|
55
|
-
}
|
|
56
|
-
declare function validateOutput(outputDir: string): ValidationResult;
|
|
57
|
-
|
|
58
|
-
export { type ValidationResult, type VercelBuildOptions, type VercelBuildResult, buildVercelOutput, validateOutput };
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Wexts Vercel Build Output API builder.
|
|
3
|
-
*
|
|
4
|
-
* Produces the `.vercel/output` tree (Build Output API v3) that Vercel
|
|
5
|
-
* uses for deployment. This module is invoked by `wexts vercel-build`.
|
|
6
|
-
*
|
|
7
|
-
* Layout produced:
|
|
8
|
-
* .vercel/output/
|
|
9
|
-
* config.json – { version: 3 }
|
|
10
|
-
* static/ – public / static assets copied here
|
|
11
|
-
* functions/
|
|
12
|
-
* index.func/
|
|
13
|
-
* index.js – serverless entry point
|
|
14
|
-
* package.json – { type: "module" } or cjs
|
|
15
|
-
* .vc-config.json – Vercel function config
|
|
16
|
-
* ...copied runtime files
|
|
17
|
-
*/
|
|
18
|
-
interface VercelBuildOptions {
|
|
19
|
-
/** Project root (cwd). Defaults to process.cwd(). */
|
|
20
|
-
rootDir?: string;
|
|
21
|
-
/** Path to NestJS/API project for codegen. */
|
|
22
|
-
apiProjectPath?: string;
|
|
23
|
-
/** Output directory for generated RPC client. */
|
|
24
|
-
rpcOutputPath?: string;
|
|
25
|
-
/** Path to wexts.runtime.js config. */
|
|
26
|
-
runtimeConfigPath?: string;
|
|
27
|
-
/** Node.js runtime version for the Vercel function. */
|
|
28
|
-
nodeVersion?: string;
|
|
29
|
-
/** Max duration in seconds for the serverless function. */
|
|
30
|
-
maxDuration?: number;
|
|
31
|
-
/** Memory size in MB for the serverless function. */
|
|
32
|
-
memory?: number;
|
|
33
|
-
/** Regions to deploy to. */
|
|
34
|
-
regions?: string[];
|
|
35
|
-
/** Skip the RPC codegen step. */
|
|
36
|
-
skipCodegen?: boolean;
|
|
37
|
-
/** Skip the Next.js / project build step. */
|
|
38
|
-
skipBuild?: boolean;
|
|
39
|
-
}
|
|
40
|
-
interface VercelBuildResult {
|
|
41
|
-
outputDir: string;
|
|
42
|
-
configPath: string;
|
|
43
|
-
functionDir: string;
|
|
44
|
-
staticDir: string;
|
|
45
|
-
errors: string[];
|
|
46
|
-
warnings: string[];
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Build the `.vercel/output` directory from a Wexts project.
|
|
50
|
-
*/
|
|
51
|
-
declare function buildVercelOutput(options?: VercelBuildOptions): Promise<VercelBuildResult>;
|
|
52
|
-
interface ValidationResult {
|
|
53
|
-
errors: string[];
|
|
54
|
-
warnings: string[];
|
|
55
|
-
}
|
|
56
|
-
declare function validateOutput(outputDir: string): ValidationResult;
|
|
57
|
-
|
|
58
|
-
export { type ValidationResult, type VercelBuildOptions, type VercelBuildResult, buildVercelOutput, validateOutput };
|