vector-framework 0.9.4 → 0.9.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 +9 -5
- package/dist/cli/index.js +4 -4
- package/dist/cli/index.js.map +1 -1
- package/dist/cli.js +13 -98
- package/dist/core/config-loader.d.ts +2 -3
- package/dist/core/config-loader.d.ts.map +1 -1
- package/dist/core/config-loader.js +27 -118
- package/dist/core/config-loader.js.map +1 -1
- package/dist/core/vector.d.ts +7 -7
- package/dist/core/vector.d.ts.map +1 -1
- package/dist/core/vector.js +25 -26
- package/dist/core/vector.js.map +1 -1
- package/dist/dev/route-generator.d.ts.map +1 -1
- package/dist/dev/route-generator.js +0 -1
- package/dist/dev/route-generator.js.map +1 -1
- package/dist/dev/route-scanner.d.ts.map +1 -1
- package/dist/dev/route-scanner.js +0 -6
- package/dist/dev/route-scanner.js.map +1 -1
- package/dist/index.js +3 -3
- package/dist/index.mjs +3 -3
- package/dist/types/index.d.ts +5 -18
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/cli/index.ts +4 -4
- package/src/core/config-loader.ts +36 -130
- package/src/core/vector.ts +40 -29
- package/src/dev/route-generator.ts +0 -1
- package/src/dev/route-scanner.ts +0 -6
- package/src/types/index.ts +8 -27
package/README.md
CHANGED
|
@@ -16,15 +16,17 @@ bun add vector-framework
|
|
|
16
16
|
|
|
17
17
|
Create a `vector.config.ts` file in your project root:
|
|
18
18
|
|
|
19
|
-
```
|
|
20
|
-
// vector.config.
|
|
21
|
-
|
|
19
|
+
```typescript
|
|
20
|
+
// vector.config.ts
|
|
21
|
+
import type { VectorConfigSchema } from "vector-framework";
|
|
22
|
+
|
|
23
|
+
const config: VectorConfigSchema = {
|
|
24
|
+
// Server configuration
|
|
22
25
|
port: 3000, // Server port (default: 3000)
|
|
23
26
|
hostname: "localhost", // Server hostname (default: localhost)
|
|
24
27
|
routesDir: "./routes", // Routes directory (default: ./routes)
|
|
25
|
-
development:
|
|
28
|
+
development: process.env.NODE_ENV !== "production", // Development mode
|
|
26
29
|
reusePort: true, // Reuse port (default: true)
|
|
27
|
-
autoDiscover: true, // Auto-discover routes (default: true)
|
|
28
30
|
|
|
29
31
|
// CORS configuration
|
|
30
32
|
cors: {
|
|
@@ -36,6 +38,8 @@ export default {
|
|
|
36
38
|
maxAge: 86400, // Preflight cache duration in seconds
|
|
37
39
|
},
|
|
38
40
|
};
|
|
41
|
+
|
|
42
|
+
export default config;
|
|
39
43
|
```
|
|
40
44
|
|
|
41
45
|
### Your First API (Encore-style)
|
package/dist/cli/index.js
CHANGED
|
@@ -53,8 +53,8 @@ async function runDev() {
|
|
|
53
53
|
config.port = config.port ?? Number.parseInt(values.port);
|
|
54
54
|
config.hostname = config.hostname ?? values.host;
|
|
55
55
|
config.routesDir = config.routesDir ?? values.routes;
|
|
56
|
-
config.development = isDev;
|
|
57
|
-
config.autoDiscover = true;
|
|
56
|
+
config.development = config.development ?? isDev;
|
|
57
|
+
config.autoDiscover = true; // Always auto-discover routes
|
|
58
58
|
// Apply CLI CORS option if not set in config
|
|
59
59
|
if (!config.cors && values.cors) {
|
|
60
60
|
config.cors = {
|
|
@@ -89,8 +89,8 @@ async function runDev() {
|
|
|
89
89
|
if (isDev && values.watch) {
|
|
90
90
|
console.log(` ${gray}Watching${reset} All project files`);
|
|
91
91
|
}
|
|
92
|
-
console.log(` ${gray}CORS${reset} ${
|
|
93
|
-
console.log(` ${gray}Mode${reset} ${
|
|
92
|
+
console.log(` ${gray}CORS${reset} ${config.cors ? "Enabled" : "Disabled"}`);
|
|
93
|
+
console.log(` ${gray}Mode${reset} ${config.development ? "Development" : "Production"}\n`);
|
|
94
94
|
console.log(` ${green}Ready${reset} → ${cyan}http://${config.hostname}:${config.port}${reset}\n`);
|
|
95
95
|
return { server, vector, config };
|
|
96
96
|
}
|
package/dist/cli/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"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KAAK,EAAE,IAAI;aACZ,CACF,CAAC;QACJ,CAAC;QAED,OAAO,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAC;IACxC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,uBAAuB,EAAE,KAAK,CAAC,CAAC;QAC9C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC;AAED,QAAQ,OAAO,EAAE,CAAC;IAChB,KAAK,KAAK;QACR,MAAM,MAAM,EAAE,CAAC;QACf,MAAM;IACR,KAAK,OAAO;QACV,MAAM,QAAQ,EAAE,CAAC;QACjB,MAAM;IACR,KAAK,OAAO;QACV,OAAO,CAAC,GAAG,CAAC,QAAQ,GAAG,YAAY,CAAC;QACpC,MAAM,MAAM,EAAE,CAAC;QACf,MAAM;IACR;QACE,OAAO,CAAC,KAAK,CAAC,oBAAoB,OAAO,EAAE,CAAC,CAAC;QAC7C,OAAO,CAAC,GAAG,CAAC;;;;;;;;;;;;;;CAcf,CAAC,CAAC;QACC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACpB,CAAC"}
|
package/dist/cli.js
CHANGED
|
@@ -290,7 +290,6 @@ ${routeEntries.join(`
|
|
|
290
290
|
export default routes;
|
|
291
291
|
`;
|
|
292
292
|
await fs.writeFile(this.outputPath, content, "utf-8");
|
|
293
|
-
console.log(`Generated routes file: ${this.outputPath}`);
|
|
294
293
|
}
|
|
295
294
|
async generateDynamic(routes) {
|
|
296
295
|
const routeEntries = [];
|
|
@@ -331,16 +330,10 @@ class RouteScanner {
|
|
|
331
330
|
async scan() {
|
|
332
331
|
const routes = [];
|
|
333
332
|
if (!existsSync(this.routesDir)) {
|
|
334
|
-
console.log(` \u2192 Routes directory not found: ${this.routesDir}`);
|
|
335
|
-
console.log(" \u2192 No routes will be auto-discovered");
|
|
336
333
|
return [];
|
|
337
334
|
}
|
|
338
335
|
try {
|
|
339
|
-
console.log(` \u2192 Scanning routes from: ${this.routesDir}`);
|
|
340
336
|
await this.scanDirectory(this.routesDir, routes);
|
|
341
|
-
if (routes.length > 0) {
|
|
342
|
-
console.log(` \u2713 Found ${routes.length} route${routes.length === 1 ? "" : "s"}`);
|
|
343
|
-
}
|
|
344
337
|
} catch (error) {
|
|
345
338
|
if (error.code === "ENOENT") {
|
|
346
339
|
console.warn(` \u2717 Routes directory not accessible: ${this.routesDir}`);
|
|
@@ -938,7 +931,6 @@ class Vector {
|
|
|
938
931
|
}
|
|
939
932
|
}
|
|
940
933
|
this.router.sortRoutes();
|
|
941
|
-
console.log(`\u2705 Loaded ${routes.length} routes from ${routesDir}`);
|
|
942
934
|
}
|
|
943
935
|
} catch (error) {
|
|
944
936
|
if (error.code !== "ENOENT" && error.code !== "ENOTDIR") {
|
|
@@ -969,13 +961,7 @@ class Vector {
|
|
|
969
961
|
isRouteDefinition(value) {
|
|
970
962
|
return value && typeof value === "object" && "entry" in value && "options" in value && "handler" in value;
|
|
971
963
|
}
|
|
972
|
-
logRouteLoaded(
|
|
973
|
-
if (Array.isArray(route)) {
|
|
974
|
-
console.log(` \u2713 Loaded route: ${route[0]} ${route[3] || route[1]}`);
|
|
975
|
-
} else {
|
|
976
|
-
console.log(` \u2713 Loaded route: ${route.method} ${route.path}`);
|
|
977
|
-
}
|
|
978
|
-
}
|
|
964
|
+
logRouteLoaded(_) {}
|
|
979
965
|
stop() {
|
|
980
966
|
if (this.server) {
|
|
981
967
|
this.server.stop();
|
|
@@ -1051,22 +1037,14 @@ class ConfigLoader {
|
|
|
1051
1037
|
}
|
|
1052
1038
|
async buildLegacyConfig() {
|
|
1053
1039
|
const config = {};
|
|
1054
|
-
if (this.config
|
|
1055
|
-
config.port = this.config.
|
|
1056
|
-
config.hostname = this.config.
|
|
1057
|
-
config.reusePort = this.config.
|
|
1058
|
-
config.development = this.config.
|
|
1059
|
-
|
|
1060
|
-
if (this.config?.routes) {
|
|
1061
|
-
config.routesDir = this.config.routes.dir || "./routes";
|
|
1062
|
-
config.autoDiscover = this.config.routes.autoDiscover !== false;
|
|
1063
|
-
} else if (this.config?.routesDir) {
|
|
1064
|
-
config.routesDir = this.config.routesDir;
|
|
1065
|
-
config.autoDiscover = this.config.autoDiscover !== false;
|
|
1066
|
-
} else {
|
|
1067
|
-
config.routesDir = "./routes";
|
|
1068
|
-
config.autoDiscover = true;
|
|
1040
|
+
if (this.config) {
|
|
1041
|
+
config.port = this.config.port;
|
|
1042
|
+
config.hostname = this.config.hostname;
|
|
1043
|
+
config.reusePort = this.config.reusePort;
|
|
1044
|
+
config.development = this.config.development;
|
|
1045
|
+
config.routesDir = this.config.routesDir || "./routes";
|
|
1069
1046
|
}
|
|
1047
|
+
config.autoDiscover = true;
|
|
1070
1048
|
if (this.config?.cors) {
|
|
1071
1049
|
if (typeof this.config.cors === "boolean") {
|
|
1072
1050
|
config.cors = this.config.cors ? {
|
|
@@ -1083,80 +1061,17 @@ class ConfigLoader {
|
|
|
1083
1061
|
}
|
|
1084
1062
|
if (this.config?.before) {
|
|
1085
1063
|
config.before = this.config.before;
|
|
1086
|
-
} else if (this.config?.middleware?.before) {
|
|
1087
|
-
config.before = await this.loadMiddleware(this.config.middleware.before);
|
|
1088
1064
|
}
|
|
1089
1065
|
if (this.config?.after) {
|
|
1090
1066
|
config.finally = this.config.after;
|
|
1091
|
-
} else if (this.config?.middleware?.after) {
|
|
1092
|
-
config.finally = await this.loadMiddleware(this.config.middleware.after);
|
|
1093
1067
|
}
|
|
1094
1068
|
return config;
|
|
1095
1069
|
}
|
|
1096
|
-
async loadMiddleware(paths) {
|
|
1097
|
-
const middleware = [];
|
|
1098
|
-
for (const path of paths) {
|
|
1099
|
-
try {
|
|
1100
|
-
const modulePath = resolve2(process.cwd(), path);
|
|
1101
|
-
const importPath = toFileUrl(modulePath);
|
|
1102
|
-
const module = await import(importPath);
|
|
1103
|
-
const handler = module.default || module;
|
|
1104
|
-
if (typeof handler === "function") {
|
|
1105
|
-
middleware.push(handler);
|
|
1106
|
-
} else {
|
|
1107
|
-
console.warn(`Middleware at ${path} does not export a function`);
|
|
1108
|
-
}
|
|
1109
|
-
} catch (error) {
|
|
1110
|
-
console.error(`Failed to load middleware from ${path}:`, error);
|
|
1111
|
-
}
|
|
1112
|
-
}
|
|
1113
|
-
return middleware;
|
|
1114
|
-
}
|
|
1115
1070
|
async loadAuthHandler() {
|
|
1116
|
-
|
|
1117
|
-
return this.config.auth;
|
|
1118
|
-
}
|
|
1119
|
-
if (!this.config?.handlers?.auth) {
|
|
1120
|
-
return null;
|
|
1121
|
-
}
|
|
1122
|
-
try {
|
|
1123
|
-
const modulePath = resolve2(process.cwd(), this.config.handlers.auth);
|
|
1124
|
-
const importPath = toFileUrl(modulePath);
|
|
1125
|
-
const module = await import(importPath);
|
|
1126
|
-
const handler = module.default || module;
|
|
1127
|
-
if (typeof handler === "function") {
|
|
1128
|
-
return handler;
|
|
1129
|
-
} else {
|
|
1130
|
-
console.warn(`Auth handler at ${this.config.handlers.auth} does not export a function`);
|
|
1131
|
-
return null;
|
|
1132
|
-
}
|
|
1133
|
-
} catch (error) {
|
|
1134
|
-
console.error(`Failed to load auth handler from ${this.config.handlers.auth}:`, error);
|
|
1135
|
-
return null;
|
|
1136
|
-
}
|
|
1071
|
+
return this.config?.auth || null;
|
|
1137
1072
|
}
|
|
1138
1073
|
async loadCacheHandler() {
|
|
1139
|
-
|
|
1140
|
-
return this.config.cache;
|
|
1141
|
-
}
|
|
1142
|
-
if (!this.config?.handlers?.cache) {
|
|
1143
|
-
return null;
|
|
1144
|
-
}
|
|
1145
|
-
try {
|
|
1146
|
-
const modulePath = resolve2(process.cwd(), this.config.handlers.cache);
|
|
1147
|
-
const importPath = toFileUrl(modulePath);
|
|
1148
|
-
const module = await import(importPath);
|
|
1149
|
-
const handler = module.default || module;
|
|
1150
|
-
if (typeof handler === "function") {
|
|
1151
|
-
return handler;
|
|
1152
|
-
} else {
|
|
1153
|
-
console.warn(`Cache handler at ${this.config.handlers.cache} does not export a function`);
|
|
1154
|
-
return null;
|
|
1155
|
-
}
|
|
1156
|
-
} catch (error) {
|
|
1157
|
-
console.error(`Failed to load cache handler from ${this.config.handlers.cache}:`, error);
|
|
1158
|
-
return null;
|
|
1159
|
-
}
|
|
1074
|
+
return this.config?.cache || null;
|
|
1160
1075
|
}
|
|
1161
1076
|
getConfig() {
|
|
1162
1077
|
return this.config;
|
|
@@ -1212,7 +1127,7 @@ async function runDev() {
|
|
|
1212
1127
|
config.port = config.port ?? Number.parseInt(values.port);
|
|
1213
1128
|
config.hostname = config.hostname ?? values.host;
|
|
1214
1129
|
config.routesDir = config.routesDir ?? values.routes;
|
|
1215
|
-
config.development = isDev;
|
|
1130
|
+
config.development = config.development ?? isDev;
|
|
1216
1131
|
config.autoDiscover = true;
|
|
1217
1132
|
if (!config.cors && values.cors) {
|
|
1218
1133
|
config.cors = {
|
|
@@ -1243,8 +1158,8 @@ async function runDev() {
|
|
|
1243
1158
|
if (isDev && values.watch) {
|
|
1244
1159
|
console.log(` ${gray}Watching${reset} All project files`);
|
|
1245
1160
|
}
|
|
1246
|
-
console.log(` ${gray}CORS${reset} ${
|
|
1247
|
-
console.log(` ${gray}Mode${reset} ${
|
|
1161
|
+
console.log(` ${gray}CORS${reset} ${config.cors ? "Enabled" : "Disabled"}`);
|
|
1162
|
+
console.log(` ${gray}Mode${reset} ${config.development ? "Development" : "Production"}
|
|
1248
1163
|
`);
|
|
1249
1164
|
console.log(` ${green}Ready${reset} \u2192 ${cyan}http://${config.hostname}:${config.port}${reset}
|
|
1250
1165
|
`);
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import type { CacheHandler, DefaultVectorTypes, ProtectedHandler, VectorConfig, VectorConfigSchema, VectorTypes } from
|
|
1
|
+
import type { CacheHandler, DefaultVectorTypes, ProtectedHandler, VectorConfig, VectorConfigSchema, VectorTypes } from "../types";
|
|
2
2
|
export declare class ConfigLoader<TTypes extends VectorTypes = DefaultVectorTypes> {
|
|
3
3
|
private configPath;
|
|
4
4
|
private config;
|
|
5
5
|
private configSource;
|
|
6
6
|
constructor(configPath?: string);
|
|
7
7
|
load(): Promise<VectorConfig<TTypes>>;
|
|
8
|
-
getConfigSource():
|
|
8
|
+
getConfigSource(): "user" | "default";
|
|
9
9
|
private buildLegacyConfig;
|
|
10
|
-
private loadMiddleware;
|
|
11
10
|
loadAuthHandler(): Promise<ProtectedHandler<TTypes> | null>;
|
|
12
11
|
loadCacheHandler(): Promise<CacheHandler | null>;
|
|
13
12
|
getConfig(): VectorConfigSchema<TTypes> | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-loader.d.ts","sourceRoot":"","sources":["../../src/core/config-loader.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"config-loader.d.ts","sourceRoot":"","sources":["../../src/core/config-loader.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,YAAY,EAEZ,kBAAkB,EAClB,gBAAgB,EAChB,YAAY,EACZ,kBAAkB,EAClB,WAAW,EACZ,MAAM,UAAU,CAAC;AAElB,qBAAa,YAAY,CAAC,MAAM,SAAS,WAAW,GAAG,kBAAkB;IACvE,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,MAAM,CAA2C;IACzD,OAAO,CAAC,YAAY,CAAiC;gBAEzC,UAAU,SAAqB;IAKrC,IAAI,IAAI,OAAO,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;IAgC3C,eAAe,IAAI,MAAM,GAAG,SAAS;YAIvB,iBAAiB;IA6CzB,eAAe,IAAI,OAAO,CAAC,gBAAgB,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC;IAI3D,gBAAgB,IAAI,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC;IAItD,SAAS,IAAI,kBAAkB,CAAC,MAAM,CAAC,GAAG,IAAI;CAG/C"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { existsSync } from
|
|
2
|
-
import { resolve } from
|
|
3
|
-
import { toFileUrl } from
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
2
|
+
import { resolve } from "node:path";
|
|
3
|
+
import { toFileUrl } from "../utils/path";
|
|
4
4
|
export class ConfigLoader {
|
|
5
5
|
configPath;
|
|
6
6
|
config = null;
|
|
7
|
-
configSource =
|
|
8
|
-
constructor(configPath =
|
|
7
|
+
configSource = "default";
|
|
8
|
+
constructor(configPath = "vector.config.ts") {
|
|
9
9
|
// Always resolve from the current working directory (user's project)
|
|
10
10
|
this.configPath = resolve(process.cwd(), configPath);
|
|
11
11
|
}
|
|
@@ -18,19 +18,19 @@ export class ConfigLoader {
|
|
|
18
18
|
const userConfigPath = toFileUrl(this.configPath);
|
|
19
19
|
const userConfig = await import(userConfigPath);
|
|
20
20
|
this.config = userConfig.default || userConfig;
|
|
21
|
-
this.configSource =
|
|
22
|
-
console.log(
|
|
21
|
+
this.configSource = "user";
|
|
22
|
+
console.log(" ✓ User config loaded successfully");
|
|
23
23
|
}
|
|
24
24
|
catch (error) {
|
|
25
25
|
console.error(` ✗ Failed to load config from ${this.configPath}:`, error);
|
|
26
|
-
console.log(
|
|
26
|
+
console.log(" → Using default configuration");
|
|
27
27
|
this.config = {};
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
else {
|
|
31
31
|
// Config file doesn't exist, use defaults
|
|
32
32
|
console.log(` → No config file found at: ${this.configPath}`);
|
|
33
|
-
console.log(
|
|
33
|
+
console.log(" → Using default configuration");
|
|
34
34
|
this.config = {};
|
|
35
35
|
}
|
|
36
36
|
// Convert new config schema to legacy VectorConfig format
|
|
@@ -41,38 +41,26 @@ export class ConfigLoader {
|
|
|
41
41
|
}
|
|
42
42
|
async buildLegacyConfig() {
|
|
43
43
|
const config = {};
|
|
44
|
-
//
|
|
45
|
-
if (this.config
|
|
46
|
-
config.port = this.config.
|
|
47
|
-
config.hostname = this.config.
|
|
48
|
-
config.reusePort = this.config.
|
|
49
|
-
config.development = this.config.
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
config.routesDir = this.config.routes.dir || './routes';
|
|
55
|
-
config.autoDiscover = this.config.routes.autoDiscover !== false;
|
|
56
|
-
}
|
|
57
|
-
else if (this.config?.routesDir) {
|
|
58
|
-
// Legacy format: { routesDir: string }
|
|
59
|
-
config.routesDir = this.config.routesDir;
|
|
60
|
-
config.autoDiscover = this.config.autoDiscover !== false;
|
|
61
|
-
}
|
|
62
|
-
else {
|
|
63
|
-
config.routesDir = './routes';
|
|
64
|
-
config.autoDiscover = true;
|
|
65
|
-
}
|
|
44
|
+
// Direct mapping - schemas are now the same (flat)
|
|
45
|
+
if (this.config) {
|
|
46
|
+
config.port = this.config.port;
|
|
47
|
+
config.hostname = this.config.hostname;
|
|
48
|
+
config.reusePort = this.config.reusePort;
|
|
49
|
+
config.development = this.config.development;
|
|
50
|
+
config.routesDir = this.config.routesDir || "./routes";
|
|
51
|
+
}
|
|
52
|
+
// Always auto-discover routes
|
|
53
|
+
config.autoDiscover = true;
|
|
66
54
|
// CORS configuration
|
|
67
55
|
if (this.config?.cors) {
|
|
68
|
-
if (typeof this.config.cors ===
|
|
56
|
+
if (typeof this.config.cors === "boolean") {
|
|
69
57
|
config.cors = this.config.cors
|
|
70
58
|
? {
|
|
71
|
-
origin:
|
|
59
|
+
origin: "*",
|
|
72
60
|
credentials: true,
|
|
73
|
-
allowHeaders:
|
|
74
|
-
allowMethods:
|
|
75
|
-
exposeHeaders:
|
|
61
|
+
allowHeaders: "Content-Type, Authorization",
|
|
62
|
+
allowMethods: "GET, POST, PUT, PATCH, DELETE, OPTIONS",
|
|
63
|
+
exposeHeaders: "Authorization",
|
|
76
64
|
maxAge: 86400,
|
|
77
65
|
}
|
|
78
66
|
: undefined;
|
|
@@ -81,99 +69,20 @@ export class ConfigLoader {
|
|
|
81
69
|
config.cors = this.config.cors;
|
|
82
70
|
}
|
|
83
71
|
}
|
|
84
|
-
//
|
|
72
|
+
// Middleware mapping (VectorConfig uses 'finally' instead of 'after')
|
|
85
73
|
if (this.config?.before) {
|
|
86
|
-
// Direct functions provided
|
|
87
74
|
config.before = this.config.before;
|
|
88
75
|
}
|
|
89
|
-
else if (this.config?.middleware?.before) {
|
|
90
|
-
// File paths provided (legacy)
|
|
91
|
-
config.before = await this.loadMiddleware(this.config.middleware.before);
|
|
92
|
-
}
|
|
93
76
|
if (this.config?.after) {
|
|
94
|
-
// Direct functions provided
|
|
95
77
|
config.finally = this.config.after;
|
|
96
78
|
}
|
|
97
|
-
else if (this.config?.middleware?.after) {
|
|
98
|
-
// File paths provided (legacy)
|
|
99
|
-
config.finally = await this.loadMiddleware(this.config.middleware.after);
|
|
100
|
-
}
|
|
101
79
|
return config;
|
|
102
80
|
}
|
|
103
|
-
async loadMiddleware(paths) {
|
|
104
|
-
const middleware = [];
|
|
105
|
-
for (const path of paths) {
|
|
106
|
-
try {
|
|
107
|
-
const modulePath = resolve(process.cwd(), path);
|
|
108
|
-
const importPath = toFileUrl(modulePath);
|
|
109
|
-
const module = await import(importPath);
|
|
110
|
-
const handler = module.default || module;
|
|
111
|
-
if (typeof handler === 'function') {
|
|
112
|
-
middleware.push(handler);
|
|
113
|
-
}
|
|
114
|
-
else {
|
|
115
|
-
console.warn(`Middleware at ${path} does not export a function`);
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
catch (error) {
|
|
119
|
-
console.error(`Failed to load middleware from ${path}:`, error);
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
return middleware;
|
|
123
|
-
}
|
|
124
81
|
async loadAuthHandler() {
|
|
125
|
-
|
|
126
|
-
if (this.config?.auth) {
|
|
127
|
-
return this.config.auth;
|
|
128
|
-
}
|
|
129
|
-
// File path provided (legacy)
|
|
130
|
-
if (!this.config?.handlers?.auth) {
|
|
131
|
-
return null;
|
|
132
|
-
}
|
|
133
|
-
try {
|
|
134
|
-
const modulePath = resolve(process.cwd(), this.config.handlers.auth);
|
|
135
|
-
const importPath = toFileUrl(modulePath);
|
|
136
|
-
const module = await import(importPath);
|
|
137
|
-
const handler = module.default || module;
|
|
138
|
-
if (typeof handler === 'function') {
|
|
139
|
-
return handler;
|
|
140
|
-
}
|
|
141
|
-
else {
|
|
142
|
-
console.warn(`Auth handler at ${this.config.handlers.auth} does not export a function`);
|
|
143
|
-
return null;
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
catch (error) {
|
|
147
|
-
console.error(`Failed to load auth handler from ${this.config.handlers.auth}:`, error);
|
|
148
|
-
return null;
|
|
149
|
-
}
|
|
82
|
+
return this.config?.auth || null;
|
|
150
83
|
}
|
|
151
84
|
async loadCacheHandler() {
|
|
152
|
-
|
|
153
|
-
if (this.config?.cache) {
|
|
154
|
-
return this.config.cache;
|
|
155
|
-
}
|
|
156
|
-
// File path provided (legacy)
|
|
157
|
-
if (!this.config?.handlers?.cache) {
|
|
158
|
-
return null;
|
|
159
|
-
}
|
|
160
|
-
try {
|
|
161
|
-
const modulePath = resolve(process.cwd(), this.config.handlers.cache);
|
|
162
|
-
const importPath = toFileUrl(modulePath);
|
|
163
|
-
const module = await import(importPath);
|
|
164
|
-
const handler = module.default || module;
|
|
165
|
-
if (typeof handler === 'function') {
|
|
166
|
-
return handler;
|
|
167
|
-
}
|
|
168
|
-
else {
|
|
169
|
-
console.warn(`Cache handler at ${this.config.handlers.cache} does not export a function`);
|
|
170
|
-
return null;
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
catch (error) {
|
|
174
|
-
console.error(`Failed to load cache handler from ${this.config.handlers.cache}:`, error);
|
|
175
|
-
return null;
|
|
176
|
-
}
|
|
85
|
+
return this.config?.cache || null;
|
|
177
86
|
}
|
|
178
87
|
getConfig() {
|
|
179
88
|
return this.config;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-loader.js","sourceRoot":"","sources":["../../src/core/config-loader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC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,IAAI;wBACjB,YAAY,EAAE,6BAA6B;wBAC3C,YAAY,EAAE,wCAAwC;wBACtD,aAAa,EAAE,eAAe;wBAC9B,MAAM,EAAE,KAAK;qBACd;oBACH,CAAC,CAAC,SAAS,CAAC;YAChB,CAAC;iBAAM,CAAC;gBACN,MAAM,CAAC,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,IAAmB,CAAC;YAChD,CAAC;QACH,CAAC;QAED,sEAAsE;QACtE,IAAI,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC;YACxB,MAAM,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC;QACrC,CAAC;QAED,IAAI,IAAI,CAAC,MAAM,EAAE,KAAK,EAAE,CAAC;YACvB,MAAM,CAAC,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC;QACrC,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,KAAK,CAAC,eAAe;QACnB,OAAO,IAAI,CAAC,MAAM,EAAE,IAAI,IAAI,IAAI,CAAC;IACnC,CAAC;IAED,KAAK,CAAC,gBAAgB;QACpB,OAAO,IAAI,CAAC,MAAM,EAAE,KAAK,IAAI,IAAI,CAAC;IACpC,CAAC;IAED,SAAS;QACP,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;CACF"}
|
package/dist/core/vector.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type { Server } from
|
|
2
|
-
import type { RouteEntry } from
|
|
3
|
-
import { AuthManager } from
|
|
4
|
-
import { CacheManager } from
|
|
5
|
-
import type { CacheHandler, DefaultVectorTypes, ProtectedHandler, RouteHandler, RouteOptions, VectorConfig, VectorTypes } from
|
|
6
|
-
import { VectorRouter } from
|
|
7
|
-
import { VectorServer } from
|
|
1
|
+
import type { Server } from "bun";
|
|
2
|
+
import type { RouteEntry } from "itty-router";
|
|
3
|
+
import { AuthManager } from "../auth/protected";
|
|
4
|
+
import { CacheManager } from "../cache/manager";
|
|
5
|
+
import type { CacheHandler, DefaultVectorTypes, ProtectedHandler, RouteHandler, RouteOptions, VectorConfig, VectorTypes } from "../types";
|
|
6
|
+
import { VectorRouter } from "./router";
|
|
7
|
+
import { VectorServer } from "./server";
|
|
8
8
|
export declare class Vector<TTypes extends VectorTypes = DefaultVectorTypes> {
|
|
9
9
|
private static instance;
|
|
10
10
|
private router;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vector.d.ts","sourceRoot":"","sources":["../../src/core/vector.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,KAAK,CAAC;AAClC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAKhD,OAAO,KAAK,EACV,YAAY,EACZ,kBAAkB,EAClB,gBAAgB,EAChB,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,WAAW,EACZ,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAGxC,qBAAa,MAAM,CAAC,MAAM,SAAS,WAAW,GAAG,kBAAkB;IACjE,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAc;IACrC,OAAO,CAAC,MAAM,CAAuB;IACrC,OAAO,CAAC,MAAM,CAAqC;IACnD,OAAO,CAAC,iBAAiB,CAA4B;IACrD,OAAO,CAAC,WAAW,CAAsB;IACzC,OAAO,CAAC,YAAY,CAAuB;IAC3C,OAAO,CAAC,MAAM,CAA4B;IAC1C,OAAO,CAAC,YAAY,CAA6B;IACjD,OAAO,CAAC,cAAc,CAA+B;IACrD,OAAO,CAAC,iBAAiB,CAAyC;IAClE,OAAO,CAAC,aAAa,CAA6B;IAElD,OAAO;IAYP,MAA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;IAElD,OAAO;IAYP,MAAM,CAAC,WAAW,CAAC,CAAC,SAAS,WAAW,GAAG,kBAAkB,KAAK,MAAM,CAAC,CAAC,CAAC;IAQ3E,mBAAmB,CAAC,OAAO,EAAE,gBAAgB,CAAC,MAAM,CAAC;IAKrD,mBAAmB,IAAI,gBAAgB,CAAC,MAAM,CAAC,GAAG,IAAI;IAKtD,eAAe,CAAC,OAAO,EAAE,YAAY;IAKrC,eAAe,IAAI,YAAY,GAAG,IAAI;IAKtC,QAAQ,CACN,OAAO,EAAE,YAAY,CAAC,MAAM,CAAC,EAC7B,OAAO,EAAE,YAAY,CAAC,MAAM,CAAC,GAC5B,UAAU;IAKP,WAAW,CAAC,MAAM,CAAC,EAAE,YAAY,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC;YAwBnD,cAAc;IA+DtB,SAAS,CAAC,WAAW,EAAE,GAAG;IAkBhC,OAAO,CAAC,YAAY;IAIpB,OAAO,CAAC,iBAAiB;IAUzB,OAAO,CAAC,cAAc;IAItB,IAAI,IAAI,IAAI;IAUZ,SAAS,IAAI,YAAY,CAAC,MAAM,CAAC,GAAG,IAAI;IAIxC,SAAS,IAAI,YAAY,CAAC,MAAM,CAAC;IAIjC,eAAe,IAAI,YAAY,CAAC,MAAM,CAAC;IAIvC,cAAc,IAAI,WAAW,CAAC,MAAM,CAAC;IAKrC,MAAM,CAAC,aAAa,IAAI,IAAI;CAG7B;AAGD,eAAO,MAAM,iBAAiB,2BAAqB,CAAC"}
|
package/dist/core/vector.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { AuthManager } from
|
|
2
|
-
import { CacheManager } from
|
|
3
|
-
import { RouteGenerator } from
|
|
4
|
-
import { RouteScanner } from
|
|
5
|
-
import { MiddlewareManager } from
|
|
6
|
-
import { toFileUrl } from
|
|
7
|
-
import { VectorRouter } from
|
|
8
|
-
import { VectorServer } from
|
|
1
|
+
import { AuthManager } from "../auth/protected";
|
|
2
|
+
import { CacheManager } from "../cache/manager";
|
|
3
|
+
import { RouteGenerator } from "../dev/route-generator";
|
|
4
|
+
import { RouteScanner } from "../dev/route-scanner";
|
|
5
|
+
import { MiddlewareManager } from "../middleware/manager";
|
|
6
|
+
import { toFileUrl } from "../utils/path";
|
|
7
|
+
import { VectorRouter } from "./router";
|
|
8
|
+
import { VectorServer } from "./server";
|
|
9
9
|
// Internal-only class - not exposed to users
|
|
10
10
|
export class Vector {
|
|
11
11
|
static instance;
|
|
@@ -71,7 +71,7 @@ export class Vector {
|
|
|
71
71
|
return bunServer;
|
|
72
72
|
}
|
|
73
73
|
async discoverRoutes() {
|
|
74
|
-
const routesDir = this.config.routesDir ||
|
|
74
|
+
const routesDir = this.config.routesDir || "./routes";
|
|
75
75
|
// Always create a new RouteScanner with the current config's routesDir
|
|
76
76
|
// to ensure we're using the correct path from the user's config
|
|
77
77
|
this.routeScanner = new RouteScanner(routesDir);
|
|
@@ -88,7 +88,7 @@ export class Vector {
|
|
|
88
88
|
try {
|
|
89
89
|
const importPath = toFileUrl(route.path);
|
|
90
90
|
const module = await import(importPath);
|
|
91
|
-
const exported = route.name ===
|
|
91
|
+
const exported = route.name === "default" ? module.default : module[route.name];
|
|
92
92
|
if (exported) {
|
|
93
93
|
if (this.isRouteDefinition(exported)) {
|
|
94
94
|
// Use router.route() to ensure middleware is applied
|
|
@@ -101,7 +101,7 @@ export class Vector {
|
|
|
101
101
|
this.router.addRoute(exported);
|
|
102
102
|
this.logRouteLoaded(exported);
|
|
103
103
|
}
|
|
104
|
-
else if (typeof exported ===
|
|
104
|
+
else if (typeof exported === "function") {
|
|
105
105
|
this.router.route(route.options, exported);
|
|
106
106
|
this.logRouteLoaded(route.options);
|
|
107
107
|
}
|
|
@@ -113,25 +113,25 @@ export class Vector {
|
|
|
113
113
|
}
|
|
114
114
|
// Ensure routes are properly sorted after loading all
|
|
115
115
|
this.router.sortRoutes();
|
|
116
|
-
console.log(`✅ Loaded ${routes.length} routes from ${routesDir}`);
|
|
117
116
|
}
|
|
118
117
|
}
|
|
119
118
|
catch (error) {
|
|
120
|
-
if (error.code !==
|
|
121
|
-
|
|
119
|
+
if (error.code !== "ENOENT" &&
|
|
120
|
+
error.code !== "ENOTDIR") {
|
|
121
|
+
console.error("Failed to discover routes:", error);
|
|
122
122
|
}
|
|
123
123
|
}
|
|
124
124
|
}
|
|
125
125
|
async loadRoute(routeModule) {
|
|
126
|
-
if (typeof routeModule ===
|
|
126
|
+
if (typeof routeModule === "function") {
|
|
127
127
|
const routeEntry = routeModule();
|
|
128
128
|
if (Array.isArray(routeEntry)) {
|
|
129
129
|
this.router.addRoute(routeEntry);
|
|
130
130
|
}
|
|
131
131
|
}
|
|
132
|
-
else if (routeModule && typeof routeModule ===
|
|
132
|
+
else if (routeModule && typeof routeModule === "object") {
|
|
133
133
|
for (const [, value] of Object.entries(routeModule)) {
|
|
134
|
-
if (typeof value ===
|
|
134
|
+
if (typeof value === "function") {
|
|
135
135
|
const routeEntry = value();
|
|
136
136
|
if (Array.isArray(routeEntry)) {
|
|
137
137
|
this.router.addRoute(routeEntry);
|
|
@@ -144,15 +144,14 @@ export class Vector {
|
|
|
144
144
|
return Array.isArray(value) && value.length >= 3;
|
|
145
145
|
}
|
|
146
146
|
isRouteDefinition(value) {
|
|
147
|
-
return value &&
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
}
|
|
147
|
+
return (value &&
|
|
148
|
+
typeof value === "object" &&
|
|
149
|
+
"entry" in value &&
|
|
150
|
+
"options" in value &&
|
|
151
|
+
"handler" in value);
|
|
152
|
+
}
|
|
153
|
+
logRouteLoaded(_) {
|
|
154
|
+
// Silent - no logging
|
|
156
155
|
}
|
|
157
156
|
stop() {
|
|
158
157
|
if (this.server) {
|