vector-framework 0.9.2 → 0.9.4

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/cli/index.js CHANGED
@@ -4,7 +4,7 @@ import { parseArgs } from "node:util";
4
4
  import { getVectorInstance } from "../core/vector";
5
5
  import { ConfigLoader } from "../core/config-loader";
6
6
  // Compatibility layer for both Node and Bun
7
- const args = typeof Bun !== 'undefined' ? Bun.argv.slice(2) : process.argv.slice(2);
7
+ const args = typeof Bun !== "undefined" ? Bun.argv.slice(2) : process.argv.slice(2);
8
8
  const { values, positionals } = parseArgs({
9
9
  args,
10
10
  options: {
@@ -49,9 +49,10 @@ async function runDev() {
49
49
  const config = await configLoader.load();
50
50
  const configSource = configLoader.getConfigSource();
51
51
  // Merge CLI options with loaded config
52
- config.port = config.port || Number.parseInt(values.port);
53
- config.hostname = config.hostname || values.host;
54
- config.routesDir = config.routesDir || values.routes;
52
+ // Only use CLI values if config doesn't have them
53
+ config.port = config.port ?? Number.parseInt(values.port);
54
+ config.hostname = config.hostname ?? values.host;
55
+ config.routesDir = config.routesDir ?? values.routes;
55
56
  config.development = isDev;
56
57
  config.autoDiscover = true;
57
58
  // Apply CLI CORS option if not set in config
@@ -83,7 +84,7 @@ async function runDev() {
83
84
  const reset = "\x1b[0m";
84
85
  const cyan = "\x1b[36m";
85
86
  const green = "\x1b[32m";
86
- console.log(` ${gray}Config${reset} ${configSource === 'user' ? 'User config loaded' : 'Using defaults'}`);
87
+ console.log(` ${gray}Config${reset} ${configSource === "user" ? "User config loaded" : "Using defaults"}`);
87
88
  console.log(` ${gray}Routes${reset} ${config.routesDir}`);
88
89
  if (isDev && values.watch) {
89
90
  console.log(` ${gray}Watching${reset} All project files`);
@@ -106,25 +107,45 @@ async function runDev() {
106
107
  if (isDev && values.watch) {
107
108
  try {
108
109
  let reloadTimeout = null;
110
+ let isReloading = false;
111
+ const changedFiles = new Set();
112
+ let lastReloadTime = 0;
109
113
  // Watch entire project directory for changes
110
114
  watch(process.cwd(), { recursive: true }, async (_, filename) => {
115
+ // Skip if already reloading or if it's too soon after last reload
116
+ const now = Date.now();
117
+ if (isReloading || now - lastReloadTime < 1000)
118
+ return;
111
119
  if (filename &&
112
120
  (filename.endsWith(".ts") ||
113
121
  filename.endsWith(".js") ||
114
122
  filename.endsWith(".json")) &&
115
123
  !filename.includes("node_modules") &&
116
- !filename.includes(".git")) {
124
+ !filename.includes(".git") &&
125
+ !filename.includes(".vector") && // Ignore generated files
126
+ !filename.includes("dist") && // Ignore dist folder
127
+ !filename.includes("bun.lockb") && // Ignore lock files
128
+ !filename.endsWith(".generated.ts") // Ignore generated files
129
+ ) {
130
+ // Track changed files
131
+ changedFiles.add(filename);
117
132
  // Debounce reload to avoid multiple restarts
118
133
  if (reloadTimeout) {
119
134
  clearTimeout(reloadTimeout);
120
135
  }
121
136
  reloadTimeout = setTimeout(async () => {
122
- console.log(`\n 🔄 File changed: ${filename}`);
123
- console.log(" 🔄 Reloading server...\n");
137
+ if (isReloading || changedFiles.size === 0)
138
+ return;
139
+ isReloading = true;
140
+ lastReloadTime = Date.now();
141
+ // Clear changed files
142
+ changedFiles.clear();
124
143
  // Stop the current server
125
144
  if (vector) {
126
145
  vector.stop();
127
146
  }
147
+ // Small delay to ensure file system operations complete
148
+ await new Promise((resolve) => setTimeout(resolve, 100));
128
149
  // Clear module cache to ensure fresh imports
129
150
  for (const key in require.cache) {
130
151
  if (!key.includes("node_modules")) {
@@ -135,11 +156,18 @@ async function runDev() {
135
156
  try {
136
157
  const result = await startServer();
137
158
  server = result.server;
159
+ vector = result.vector;
138
160
  }
139
161
  catch (error) {
140
162
  console.error(" ❌ Failed to reload server:", error);
141
163
  }
142
- }, 100); // 100ms debounce
164
+ finally {
165
+ // Reset flag after a delay
166
+ setTimeout(() => {
167
+ isReloading = false;
168
+ }, 2000); // 2 second cooldown
169
+ }
170
+ }, 500); // Increased debounce to 500ms
143
171
  }
144
172
  });
145
173
  }
@@ -164,7 +192,7 @@ async function runBuild() {
164
192
  await generator.generate(routes);
165
193
  console.log(` Generated ${routes.length} routes`);
166
194
  // Use spawn based on runtime
167
- if (typeof Bun !== 'undefined') {
195
+ if (typeof Bun !== "undefined") {
168
196
  const buildProcess = Bun.spawn([
169
197
  "bun",
170
198
  "build",
@@ -177,10 +205,10 @@ async function runBuild() {
177
205
  }
178
206
  else {
179
207
  // For Node.js, use child_process
180
- const { spawnSync } = await import('child_process');
181
- spawnSync('bun', ['build', 'src/index.ts', '--outdir', 'dist', '--minify'], {
182
- stdio: 'inherit',
183
- shell: true
208
+ const { spawnSync } = await import("child_process");
209
+ spawnSync("bun", ["build", "src/index.ts", "--outdir", "dist", "--minify"], {
210
+ stdio: "inherit",
211
+ shell: true,
184
212
  });
185
213
  }
186
214
  console.log("\n ✓ Build complete\n");
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAErD,4CAA4C;AAC5C,MAAM,IAAI,GAAG,OAAO,GAAG,KAAK,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AAEpF,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG,SAAS,CAAC;IACxC,IAAI;IACJ,OAAO,EAAE;QACP,IAAI,EAAE;YACJ,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,GAAG;YACV,OAAO,EAAE,MAAM;SAChB;QACD,IAAI,EAAE;YACJ,IAAI,EAAE,QAAQ;YACd,KAA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,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
@@ -905,9 +905,7 @@ class Vector {
905
905
  }
906
906
  async discoverRoutes() {
907
907
  const routesDir = this.config.routesDir || "./routes";
908
- if (!this.routeScanner) {
909
- this.routeScanner = new RouteScanner(routesDir);
910
- }
908
+ this.routeScanner = new RouteScanner(routesDir);
911
909
  if (!this.routeGenerator) {
912
910
  this.routeGenerator = new RouteGenerator;
913
911
  }
@@ -1062,6 +1060,9 @@ class ConfigLoader {
1062
1060
  if (this.config?.routes) {
1063
1061
  config.routesDir = this.config.routes.dir || "./routes";
1064
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;
1065
1066
  } else {
1066
1067
  config.routesDir = "./routes";
1067
1068
  config.autoDiscover = true;
@@ -1081,20 +1082,14 @@ class ConfigLoader {
1081
1082
  }
1082
1083
  }
1083
1084
  if (this.config?.before) {
1084
- console.log("Using direct before middleware functions:", this.config.before.length);
1085
1085
  config.before = this.config.before;
1086
1086
  } else if (this.config?.middleware?.before) {
1087
- console.log("Loading before middleware from file paths:", this.config.middleware.before);
1088
1087
  config.before = await this.loadMiddleware(this.config.middleware.before);
1089
- console.log("Loaded before middleware:", config.before?.length);
1090
1088
  }
1091
1089
  if (this.config?.after) {
1092
- console.log("Using direct after middleware functions:", this.config.after.length);
1093
1090
  config.finally = this.config.after;
1094
1091
  } else if (this.config?.middleware?.after) {
1095
- console.log("Loading after middleware from file paths:", this.config.middleware.after);
1096
1092
  config.finally = await this.loadMiddleware(this.config.middleware.after);
1097
- console.log("Loaded after middleware:", config.finally?.length);
1098
1093
  }
1099
1094
  return config;
1100
1095
  }
@@ -1119,7 +1114,6 @@ class ConfigLoader {
1119
1114
  }
1120
1115
  async loadAuthHandler() {
1121
1116
  if (this.config?.auth) {
1122
- console.log("Using direct auth handler function");
1123
1117
  return this.config.auth;
1124
1118
  }
1125
1119
  if (!this.config?.handlers?.auth) {
@@ -1143,7 +1137,6 @@ class ConfigLoader {
1143
1137
  }
1144
1138
  async loadCacheHandler() {
1145
1139
  if (this.config?.cache) {
1146
- console.log("Using direct cache handler function");
1147
1140
  return this.config.cache;
1148
1141
  }
1149
1142
  if (!this.config?.handlers?.cache) {
@@ -1216,9 +1209,9 @@ async function runDev() {
1216
1209
  const configLoader = new ConfigLoader;
1217
1210
  const config = await configLoader.load();
1218
1211
  const configSource = configLoader.getConfigSource();
1219
- config.port = config.port || Number.parseInt(values.port);
1220
- config.hostname = config.hostname || values.host;
1221
- config.routesDir = config.routesDir || values.routes;
1212
+ config.port = config.port ?? Number.parseInt(values.port);
1213
+ config.hostname = config.hostname ?? values.host;
1214
+ config.routesDir = config.routesDir ?? values.routes;
1222
1215
  config.development = isDev;
1223
1216
  config.autoDiscover = true;
1224
1217
  if (!config.cors && values.cors) {
@@ -1267,19 +1260,28 @@ async function runDev() {
1267
1260
  if (isDev && values.watch) {
1268
1261
  try {
1269
1262
  let reloadTimeout = null;
1263
+ let isReloading = false;
1264
+ const changedFiles = new Set;
1265
+ let lastReloadTime = 0;
1270
1266
  watch(process.cwd(), { recursive: true }, async (_, filename) => {
1271
- if (filename && (filename.endsWith(".ts") || filename.endsWith(".js") || filename.endsWith(".json")) && !filename.includes("node_modules") && !filename.includes(".git")) {
1267
+ const now = Date.now();
1268
+ if (isReloading || now - lastReloadTime < 1000)
1269
+ return;
1270
+ if (filename && (filename.endsWith(".ts") || filename.endsWith(".js") || filename.endsWith(".json")) && !filename.includes("node_modules") && !filename.includes(".git") && !filename.includes(".vector") && !filename.includes("dist") && !filename.includes("bun.lockb") && !filename.endsWith(".generated.ts")) {
1271
+ changedFiles.add(filename);
1272
1272
  if (reloadTimeout) {
1273
1273
  clearTimeout(reloadTimeout);
1274
1274
  }
1275
1275
  reloadTimeout = setTimeout(async () => {
1276
- console.log(`
1277
- \uD83D\uDD04 File changed: ${filename}`);
1278
- console.log(` \uD83D\uDD04 Reloading server...
1279
- `);
1276
+ if (isReloading || changedFiles.size === 0)
1277
+ return;
1278
+ isReloading = true;
1279
+ lastReloadTime = Date.now();
1280
+ changedFiles.clear();
1280
1281
  if (vector) {
1281
1282
  vector.stop();
1282
1283
  }
1284
+ await new Promise((resolve3) => setTimeout(resolve3, 100));
1283
1285
  for (const key in __require.cache) {
1284
1286
  if (!key.includes("node_modules")) {
1285
1287
  delete __require.cache[key];
@@ -1288,10 +1290,15 @@ async function runDev() {
1288
1290
  try {
1289
1291
  const result2 = await startServer();
1290
1292
  server = result2.server;
1293
+ vector = result2.vector;
1291
1294
  } catch (error) {
1292
1295
  console.error(" \u274C Failed to reload server:", error);
1296
+ } finally {
1297
+ setTimeout(() => {
1298
+ isReloading = false;
1299
+ }, 2000);
1293
1300
  }
1294
- }, 100);
1301
+ }, 500);
1295
1302
  }
1296
1303
  });
1297
1304
  } catch (err) {
@@ -1 +1 @@
1
- {"version":3,"file":"config-loader.d.ts","sourceRoot":"","sources":["../../src/core/config-loader.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAGV,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;IA6B3C,eAAe,IAAI,MAAM,GAAG,SAAS;YAIvB,iBAAiB;YAoEjB,cAAc;IAuBtB,eAAe,IAAI,OAAO,CAAC,gBAAgB,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC;IA8B3D,gBAAgB,IAAI,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC;IA8BtD,SAAS,IAAI,kBAAkB,CAAC,MAAM,CAAC,GAAG,IAAI;CAG/C"}
1
+ {"version":3,"file":"config-loader.d.ts","sourceRoot":"","sources":["../../src/core/config-loader.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAGV,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;IA6B3C,eAAe,IAAI,MAAM,GAAG,SAAS;YAIvB,iBAAiB;YAmEjB,cAAc;IAuBtB,eAAe,IAAI,OAAO,CAAC,gBAAgB,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC;IA6B3D,gBAAgB,IAAI,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC;IA6BtD,SAAS,IAAI,kBAAkB,CAAC,MAAM,CAAC,GAAG,IAAI;CAG/C"}
@@ -48,11 +48,17 @@ export class ConfigLoader {
48
48
  config.reusePort = this.config.server.reusePort;
49
49
  config.development = this.config.server.development;
50
50
  }
51
- // Routes configuration
51
+ // Routes configuration - support both new and legacy formats
52
52
  if (this.config?.routes) {
53
+ // New format: { routes: { dir: string } }
53
54
  config.routesDir = this.config.routes.dir || './routes';
54
55
  config.autoDiscover = this.config.routes.autoDiscover !== false;
55
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
+ }
56
62
  else {
57
63
  config.routesDir = './routes';
58
64
  config.autoDiscover = true;
@@ -78,25 +84,19 @@ export class ConfigLoader {
78
84
  // Load middleware - support both direct functions and file paths
79
85
  if (this.config?.before) {
80
86
  // Direct functions provided
81
- console.log('Using direct before middleware functions:', this.config.before.length);
82
87
  config.before = this.config.before;
83
88
  }
84
89
  else if (this.config?.middleware?.before) {
85
90
  // File paths provided (legacy)
86
- console.log('Loading before middleware from file paths:', this.config.middleware.before);
87
91
  config.before = await this.loadMiddleware(this.config.middleware.before);
88
- console.log('Loaded before middleware:', config.before?.length);
89
92
  }
90
93
  if (this.config?.after) {
91
94
  // Direct functions provided
92
- console.log('Using direct after middleware functions:', this.config.after.length);
93
95
  config.finally = this.config.after;
94
96
  }
95
97
  else if (this.config?.middleware?.after) {
96
98
  // File paths provided (legacy)
97
- console.log('Loading after middleware from file paths:', this.config.middleware.after);
98
99
  config.finally = await this.loadMiddleware(this.config.middleware.after);
99
- console.log('Loaded after middleware:', config.finally?.length);
100
100
  }
101
101
  return config;
102
102
  }
@@ -124,7 +124,6 @@ export class ConfigLoader {
124
124
  async loadAuthHandler() {
125
125
  // Direct function provided
126
126
  if (this.config?.auth) {
127
- console.log('Using direct auth handler function');
128
127
  return this.config.auth;
129
128
  }
130
129
  // File path provided (legacy)
@@ -152,7 +151,6 @@ export class ConfigLoader {
152
151
  async loadCacheHandler() {
153
152
  // Direct function provided
154
153
  if (this.config?.cache) {
155
- console.log('Using direct cache handler function');
156
154
  return this.config.cache;
157
155
  }
158
156
  // File path provided (legacy)
@@ -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;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAa1C,MAAM,OAAO,YAAY;IACf,UAAU,CAAS;IACnB,MAAM,GAAsC,IAAI,CAAC;IACjD,YAAY,GAAuB,SAAS,CAAC;IAErD,YAAY,UAAU,GAAG,kBAAkB;QACzC,qEAAqE;QACrE,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,UAAU,CAAC,CAAC;IACvD,CAAC;IAED,KAAK,CAAC,IAAI;QACR,wDAAwD;QACxD,IAAI,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC;YAChC,IAAI,CAAC;gBACH,OAAO,CAAC,GAAG,CAAC,0BAA0B,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC;gBAEzD,wDAAwD;gBACxD,MAAM,cAAc,GAAG,SAAS,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;gBAClD,MAAM,UAAU,GAAG,MAAM,MAAM,CAAC,cAAc,CAAC,CAAC;gBAChD,IAAI,CAAC,MAAM,GAAG,UAAU,CAAC,OAAO,IAAI,UAAU,CAAC;gBAC/C,IAAI,CAAC,YAAY,GAAG,MAAM,CAAC;gB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C;YAClC,OAAO,IAAI,CAAC;QACd,CAAC;QAED,IAAI,CAAC;YACH,MAAM,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;YACtE,MAAM,UAAU,GAAG,SAAS,CAAC,UAAU,CAAC,CAAC;YACzC,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,UAAU,CAAC,CAAC;YACxC,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,IAAI,MAAM,CAAC;YAEzC,IAAI,OAAO,OAAO,KAAK,UAAU,EAAE,CAAC;gBAClC,OAAO,OAAuB,CAAC;YACjC,CAAC;iBAAM,CAAC;gBACN,OAAO,CAAC,IAAI,CAAC,oBAAoB,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,6BAA6B,CAAC,CAAC;gBAC1F,OAAO,IAAI,CAAC;YACd,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,qCAAqC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,GAAG,EAAE,KAAK,CAAC,CAAC;YACzF,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;IAED,SAAS;QACP,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;CACF"}
@@ -72,9 +72,9 @@ export class Vector {
72
72
  }
73
73
  async discoverRoutes() {
74
74
  const routesDir = this.config.routesDir || './routes';
75
- if (!this.routeScanner) {
76
- this.routeScanner = new RouteScanner(routesDir);
77
- }
75
+ // Always create a new RouteScanner with the current config's routesDir
76
+ // to ensure we're using the correct path from the user's config
77
+ this.routeScanner = new RouteScanner(routesDir);
78
78
  if (!this.routeGenerator) {
79
79
  this.routeGenerator = new RouteGenerator();
80
80
  }
@@ -1 +1 @@
1
- {"version":3,"file":"vector.js","sourceRoot":"","sources":["../../src/core/vector.ts"],"names":[],"mappings":"AAEA,OAA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AA4C;QAC5C,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC;IAC5B,CAAC;IAED,SAAS;QACP,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED,SAAS;QACP,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED,eAAe;QACb,OAAO,IAAI,CAAC,YAAY,CAAC;IAC3B,CAAC;IAED,cAAc;QACZ,OAAO,IAAI,CAAC,WAAW,CAAC;IAC1B,CAAC;IAED,2CAA2C;IAC3C,MAAM,CAAC,aAAa;QAClB,MAAM,CAAC,QAAQ,GAAG,IAAW,CAAC;IAChC,CAAC;CACF;AAED,+BAA+B;AAC/B,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC,WAAW,CAAC"}
package/dist/index.js CHANGED
@@ -18,4 +18,4 @@ export default routes;
18
18
  ${f.join(`,
19
19
  `)}
20
20
  ]);
21
- };`}}var v;var p=U(()=>{v=(()=>({}));Z()});class k{routesDir;constructor(i="./routes"){this.routesDir=x(process.cwd(),i)}async scan(){let i=[];if(!F.existsSync(this.routesDir))return console.log(` → Routes directory not found: ${this.routesDir}`),console.log(" → No routes will be auto-discovered"),[];try{if(console.log(` → Scanning routes from: ${this.routesDir}`),await this.scanDirectory(this.routesDir,i),i.length>0)console.log(` ✓ Found ${i.length} route${i.length===1?"":"s"}`)}catch(f){if(f.code==="ENOENT")return console.warn(` ✗ Routes directory not accessible: ${this.routesDir}`),[];throw f}return i}async scanDirectory(i,f,l=""){let a=await F.promises.readdir(i);for(let A of a){let E=z(i,A);if((await F.promises.stat(E)).isDirectory()){let _=l?`${l}/${A}`:A;await this.scanDirectory(E,f,_)}else if(A.endsWith(".ts")||A.endsWith(".js")){let _=G(this.routesDir,E).replace(/\.(ts|js)$/,"").split(K).join("/");try{let w=await import(process.platform==="win32"?`file:///${E.replace(/\\/g,"/")}`:E);if(w.default&&typeof w.default==="function")f.push({name:"default",path:E,method:"GET",options:{method:"GET",path:`/${_}`,expose:!0}});for(let[O,I]of Object.entries(w)){if(O==="default")continue;if(I&&typeof I==="object"&&"entry"in I&&"options"in I&&"handler"in I){let L=I;f.push({name:O,path:E,method:L.options.method,options:L.options})}else if(Array.isArray(I)&&I.length>=4){let[L,,,P]=I;f.push({name:O,path:E,method:L,options:{method:L,path:P,expose:!0}})}}}catch(N){console.error(`Failed to load route from ${E}:`,N)}}}}enableWatch(i){if(typeof Bun!=="undefined"&&Bun.env.NODE_ENV==="development")console.log(`Watching for route changes in ${this.routesDir}`),setInterval(async()=>{await i()},1000)}}var F;var e=U(()=>{F=(()=>({}));Z()});class B{beforeHandlers=[];finallyHandlers=[];addBefore(...i){this.beforeHandlers.push(...i)}addFinally(...i){this.finallyHandlers.push(...i)}async executeBefore(i){let f=i;for(let l of this.beforeHandlers){let a=await l(f);if(a instanceof Response)return a;f=a}return f}async executeFinally(i,f){let l=i;for(let a of this.finallyHandlers)l=await a(l,f);return l}clone(){let i=new B;return i.beforeHandlers=[...this.beforeHandlers],i.finallyHandlers=[...this.finallyHandlers],i}clear(){this.beforeHandlers=[],this.finallyHandlers=[]}}function ii(i){return process.platform==="win32"?`file:///${i.replace(/\\/g,"/")}`:i}class m{middlewareManager;authManager;cacheManager;routes=[];constructor(i,f,l){this.middlewareManager=i,this.authManager=f,this.cacheManager=l}getRouteSpecificity(i){let E=0,d=i.split("/").filter(Boolean);for(let _ of d)if(this.isStaticSegment(_))E+=1000;else if(this.isParamSegment(_))E+=10;else if(this.isWildcardSegment(_))E+=1;if(E+=i.length,this.isExactPath(i))E+=1e4;return E}isStaticSegment(i){return!i.startsWith(":")&&!i.includes("*")}isParamSegment(i){return i.startsWith(":")}isWildcardSegment(i){return i.includes("*")}isExactPath(i){return!i.includes(":")&&!i.includes("*")}sortRoutes(){this.routes.sort((i,f)=>{let l=this.extractPath(i),a=this.extractPath(f),A=this.getRouteSpecificity(l);return this.getRouteSpecificity(a)-A})}extractPath(i){return i[3]||""}route(i,f){let l=this.wrapHandler(i,f),a=[i.method.toUpperCase(),this.createRouteRegex(i.path),[l],i.path];return this.routes.push(a),this.sortRoutes(),a}createRouteRegex(i){return RegExp(`^${i.replace(/\/+(\/|$)/g,"$1").replace(/(\/?\.?):(\w+)\+/g,"($1(?<$2>*))").replace(/(\/?\.?):(\w+)/g,"($1(?<$2>[^$1/]+?))").replace(/\./g,"\\.").replace(/(\/?)\*/g,"($1.*)?")}/*$`)}wrapHandler(i,f){return async(l)=>{let a=l;if(!a.context)a.context={};if(!a.query&&a.url){let A=new URL(a.url),E={};for(let[d,_]of A.searchParams)E[d]=E[d]?[].concat(E[d],_):_;a.query=E}if(i.metadata)a.metadata=i.metadata;l=a;try{if(i.expose===!1)return R.forbidden("Forbidden");let A=await this.middlewareManager.executeBefore(l);if(A instanceof Response)return A;if(l=A,i.auth)try{await this.authManager.authenticate(l)}catch(N){return R.unauthorized(N instanceof Error?N.message:"Authentication failed",i.responseContentType)}if(!i.rawRequest&&l.method!=="GET"&&l.method!=="HEAD")try{let N=l.headers.get("content-type");if(N?.includes("application/json"))l.content=await l.json();else if(N?.includes("application/x-www-form-urlencoded"))l.content=Object.fromEntries(await l.formData());else if(N?.includes("multipart/form-data"))l.content=await l.formData();else l.content=await l.text()}catch{l.content=null}let E,d=i.cache;if(d&&typeof d==="number"&&d>0){let N=this.cacheManager.generateKey(l,{authUser:l.authUser});E=await this.cacheManager.get(N,()=>f(l),d)}else if(d&&typeof d==="object"&&d.ttl){let N=d.key||this.cacheManager.generateKey(l,{authUser:l.authUser});E=await this.cacheManager.get(N,()=>f(l),d.ttl)}else E=await f(l);let _;if(i.rawResponse||E instanceof Response)_=E instanceof Response?E:new Response(E);else _=H(200,E,i.responseContentType);return _=await this.middlewareManager.executeFinally(_,l),_}catch(A){if(A instanceof Response)return A;return console.error("Route handler error:",A),R.internalServerError(A instanceof Error?A.message:String(A),i.responseContentType)}}}addRoute(i){this.routes.push(i),this.sortRoutes()}getRoutes(){return this.routes}async handle(i){let l=new URL(i.url).pathname;for(let[a,A,E]of this.routes)if(i.method==="OPTIONS"||i.method===a){let d=l.match(A);if(d){let _=i;if(!_.context)_.context={};_.params=d.groups||{};for(let N of E){let w=await N(_);if(w)return w}}}return R.notFound("Route not found")}clearRoutes(){this.routes=[]}}var fi=U(()=>{Y()});class u{server=null;router;config;corsHandler;constructor(i,f){if(this.router=i,this.config=f,f.cors){let{preflight:l,corsify:a}=j(this.normalizeCorsOptions(f.cors));this.corsHandler={preflight:l,corsify:a}}}normalizeCorsOptions(i){return{origin:i.origin||"*",credentials:i.credentials!==!1,allowHeaders:Array.isArray(i.allowHeaders)?i.allowHeaders.join(", "):i.allowHeaders||"Content-Type, Authorization",allowMethods:Array.isArray(i.allowMethods)?i.allowMethods.join(", "):i.allowMethods||"GET, POST, PUT, PATCH, DELETE, OPTIONS",exposeHeaders:Array.isArray(i.exposeHeaders)?i.exposeHeaders.join(", "):i.exposeHeaders||"Authorization",maxAge:i.maxAge||86400}}async start(){let i=this.config.port||3000,f=this.config.hostname||"localhost",l=async(a)=>{try{if(this.corsHandler&&a.method==="OPTIONS")return this.corsHandler.preflight(a);let A=await this.router.handle(a);if(this.corsHandler)A=this.corsHandler.corsify(A,a);return A}catch(A){return console.error("Server error:",A),new Response("Internal Server Error",{status:500})}};return this.server=Bun.serve({port:i,hostname:f,reusePort:this.config.reusePort!==!1,fetch:l,error:(a)=>{return console.error("[ERROR] Server error:",a),new Response("Internal Server Error",{status:500})}}),console.log(`→ Vector server running at http://${f}:${i}`),this.server}stop(){if(this.server)this.server.stop(),this.server=null,console.log("Server stopped")}getServer(){return this.server}getPort(){return this.server?.port||this.config.port||3000}getHostname(){return this.server?.hostname||this.config.hostname||"localhost"}getUrl(){let i=this.getPort();return`http://${this.getHostname()}:${i}`}}var li=U(()=>{V()});var ai={};r(ai,{getVectorInstance:()=>Pi,Vector:()=>h});class h{static instance;router;server=null;middlewareManager;authManager;cacheManager;config={};routeScanner=null;routeGenerator=null;_protectedHandler=null;_cacheHandler=null;constructor(){this.middlewareManager=new B,this.authManager=new J,this.cacheManager=new W,this.router=new m(this.middlewareManager,this.authManager,this.cacheManager)}static getInstance(){if(!h.instance)h.instance=new h;return h.instance}setProtectedHandler(i){this._protectedHandler=i,this.authManager.setProtectedHandler(i)}getProtectedHandler(){return this._protectedHandler}setCacheHandler(i){this._cacheHandler=i,this.cacheManager.setCacheHandler(i)}getCacheHandler(){return this._cacheHandler}addRoute(i,f){return this.router.route(i,f)}async startServer(i){if(this.config={...this.config,...i},this.middlewareManager.clear(),i?.before)this.middlewareManager.addBefore(...i.before);if(i?.finally)this.middlewareManager.addFinally(...i.finally);if(this.config.autoDiscover!==!1)await this.discoverRoutes();return this.server=new u(this.router,this.config),await this.server.start()}async discoverRoutes(){let i=this.config.routesDir||"./routes";if(!this.routeScanner)this.routeScanner=new k(i);if(!this.routeGenerator)this.routeGenerator=new g;try{let f=await this.routeScanner.scan();if(f.length>0){if(this.config.development)await this.routeGenerator.generate(f);for(let l of f)try{let A=await import(ii(l.path)),E=l.name==="default"?A.default:A[l.name];if(E){if(this.isRouteDefinition(E)){let d=E;this.router.route(d.options,d.handler),this.logRouteLoaded(d.options)}else if(this.isRouteEntry(E))this.router.addRoute(E),this.logRouteLoaded(E);else if(typeof E==="function")this.router.route(l.options,E),this.logRouteLoaded(l.options)}}catch(a){console.error(`Failed to load route ${l.name} from ${l.path}:`,a)}this.router.sortRoutes(),console.log(`✅ Loaded ${f.length} routes from ${i}`)}}catch(f){if(f.code!=="ENOENT"&&f.code!=="ENOTDIR")console.error("Failed to discover routes:",f)}}async loadRoute(i){if(typeof i==="function"){let f=i();if(Array.isArray(f))this.router.addRoute(f)}else if(i&&typeof i==="object"){for(let[,f]of Object.entries(i))if(typeof f==="function"){let l=f();if(Array.isArray(l))this.router.addRoute(l)}}}isRouteEntry(i){return Array.isArray(i)&&i.length>=3}isRouteDefinition(i){return i&&typeof i==="object"&&"entry"in i&&"options"in i&&"handler"in i}logRouteLoaded(i){if(Array.isArray(i))console.log(` ✓ Loaded route: ${i[0]} ${i[3]||i[1]}`);else console.log(` ✓ Loaded route: ${i.method} ${i.path}`)}stop(){if(this.server)this.server.stop(),this.server=null;this.router.clearRoutes()}getServer(){return this.server}getRouter(){return this.router}getCacheManager(){return this.cacheManager}getAuthManager(){return this.authManager}static resetInstance(){h.instance=null}}var Pi;var Ei=U(()=>{q();p();e();fi();li();Pi=h.getInstance});function Ai(i,f){let l=Si(i,f);return{entry:[i.method.toUpperCase(),RegExp(`^${i.path.replace(/\/+(\/|$)/g,"$1").replace(/(\/?\.?):(\w+)\+/g,"($1(?<$2>*))").replace(/(\/?\.?):(\w+)/g,"($1(?<$2>[^$1/]+?))").replace(/\./g,"\\.").replace(/(\/?)\*/g,"($1.*)?")}/*$`),[l],i.path],options:i,handler:f}}function hi(i){return JSON.stringify(i??null,(f,l)=>typeof l==="bigint"?l.toString():l)}function D(i,f,l){let a={error:!0,message:f,statusCode:i,timestamp:new Date().toISOString()};return H(i,a,l)}function H(i,f,l=M.JSON){let a=l===M.JSON?hi(f):f;return new Response(a,{status:i,headers:{"content-type":l}})}function Si(i,f){let{auth:l=!1,expose:a=!1,rawRequest:A=!1,rawResponse:E=!1,responseContentType:d=M.JSON}=i;return async(_)=>{if(!a)return R.forbidden("Forbidden");try{if(l)await bi(_,d);if(!A)await s(_);y(_);let N=await f(_);return E?N:Hi.success(N,d)}catch(N){if(N instanceof Response)return N;return R.internalServerError(String(N),d)}}}var Af,_f,Hi,R,bi=async(i,f)=>{let{getVectorInstance:l}=await Promise.resolve().then(() => (Ei(),ai)),A=l().getProtectedHandler();if(!A)throw R.unauthorized("Authentication not configured",f);try{let E=await A(i);i.authUser=E}catch(E){throw R.unauthorized(E instanceof Error?E.message:"Authentication failed",f)}};var Y=U(()=>{V();X();({preflight:Af,corsify:_f}=j({origin:"*",credentials:!0,allowHeaders:"Content-Type, Authorization",allowMethods:"GET, POST, PUT, PATCH, DELETE, OPTIONS",exposeHeaders:"Authorization",maxAge:86400}));Hi={success:(i,f)=>H($.OK,i,f),created:(i,f)=>H($.CREATED,i,f)};R={badRequest:(i="Bad Request",f)=>D($.BAD_REQUEST,i,f),unauthorized:(i="Unauthorized",f)=>D($.UNAUTHORIZED,i,f),paymentRequired:(i="Payment Required",f)=>D(402,i,f),forbidden:(i="Forbidden",f)=>D($.FORBIDDEN,i,f),notFound:(i="Not Found",f)=>D($.NOT_FOUND,i,f),methodNotAllowed:(i="Method Not Allowed",f)=>D(405,i,f),notAcceptable:(i="Not Acceptable",f)=>D(406,i,f),requestTimeout:(i="Request Timeout",f)=>D(408,i,f),conflict:(i="Conflict",f)=>D($.CONFLICT,i,f),gone:(i="Gone",f)=>D(410,i,f),lengthRequired:(i="Length Required",f)=>D(411,i,f),preconditionFailed:(i="Precondition Failed",f)=>D(412,i,f),payloadTooLarge:(i="Payload Too Large",f)=>D(413,i,f),uriTooLong:(i="URI Too Long",f)=>D(414,i,f),unsupportedMediaType:(i="Unsupported Media Type",f)=>D(415,i,f),rangeNotSatisfiable:(i="Range Not Satisfiable",f)=>D(416,i,f),expectationFailed:(i="Expectation Failed",f)=>D(417,i,f),imATeapot:(i="I'm a teapot",f)=>D(418,i,f),misdirectedRequest:(i="Misdirected Request",f)=>D(421,i,f),unprocessableEntity:(i="Unprocessable Entity",f)=>D($.UNPROCESSABLE_ENTITY,i,f),locked:(i="Locked",f)=>D(423,i,f),failedDependency:(i="Failed Dependency",f)=>D(424,i,f),tooEarly:(i="Too Early",f)=>D(425,i,f),upgradeRequired:(i="Upgrade Required",f)=>D(426,i,f),preconditionRequired:(i="Precondition Required",f)=>D(428,i,f),tooManyRequests:(i="Too Many Requests",f)=>D(429,i,f),requestHeaderFieldsTooLarge:(i="Request Header Fields Too Large",f)=>D(431,i,f),unavailableForLegalReasons:(i="Unavailable For Legal Reasons",f)=>D(451,i,f),internalServerError:(i="Internal Server Error",f)=>D($.INTERNAL_SERVER_ERROR,i,f),notImplemented:(i="Not Implemented",f)=>D(501,i,f),badGateway:(i="Bad Gateway",f)=>D(502,i,f),serviceUnavailable:(i="Service Unavailable",f)=>D(503,i,f),gatewayTimeout:(i="Gateway Timeout",f)=>D(504,i,f),httpVersionNotSupported:(i="HTTP Version Not Supported",f)=>D(505,i,f),variantAlsoNegotiates:(i="Variant Also Negotiates",f)=>D(506,i,f),insufficientStorage:(i="Insufficient Storage",f)=>D(507,i,f),loopDetected:(i="Loop Detected",f)=>D(508,i,f),notExtended:(i="Not Extended",f)=>D(510,i,f),networkAuthenticationRequired:(i="Network Authentication Required",f)=>D(511,i,f),invalidArgument:(i="Invalid Argument",f)=>D($.UNPROCESSABLE_ENTITY,i,f),rateLimitExceeded:(i="Rate Limit Exceeded",f)=>D(429,i,f),maintenance:(i="Service Under Maintenance",f)=>D(503,i,f),custom:(i,f,l)=>D(i,f,l)}});var xi={};r(xi,{route:()=>Ai,createResponse:()=>H,APIError:()=>R});module.exports=Ni(xi);Y();Y();
21
+ };`}}var v;var p=U(()=>{v=(()=>({}));Z()});class k{routesDir;constructor(i="./routes"){this.routesDir=x(process.cwd(),i)}async scan(){let i=[];if(!F.existsSync(this.routesDir))return console.log(` → Routes directory not found: ${this.routesDir}`),console.log(" → No routes will be auto-discovered"),[];try{if(console.log(` → Scanning routes from: ${this.routesDir}`),await this.scanDirectory(this.routesDir,i),i.length>0)console.log(` ✓ Found ${i.length} route${i.length===1?"":"s"}`)}catch(f){if(f.code==="ENOENT")return console.warn(` ✗ Routes directory not accessible: ${this.routesDir}`),[];throw f}return i}async scanDirectory(i,f,l=""){let a=await F.promises.readdir(i);for(let A of a){let E=z(i,A);if((await F.promises.stat(E)).isDirectory()){let _=l?`${l}/${A}`:A;await this.scanDirectory(E,f,_)}else if(A.endsWith(".ts")||A.endsWith(".js")){let _=G(this.routesDir,E).replace(/\.(ts|js)$/,"").split(K).join("/");try{let w=await import(process.platform==="win32"?`file:///${E.replace(/\\/g,"/")}`:E);if(w.default&&typeof w.default==="function")f.push({name:"default",path:E,method:"GET",options:{method:"GET",path:`/${_}`,expose:!0}});for(let[O,I]of Object.entries(w)){if(O==="default")continue;if(I&&typeof I==="object"&&"entry"in I&&"options"in I&&"handler"in I){let L=I;f.push({name:O,path:E,method:L.options.method,options:L.options})}else if(Array.isArray(I)&&I.length>=4){let[L,,,P]=I;f.push({name:O,path:E,method:L,options:{method:L,path:P,expose:!0}})}}}catch(N){console.error(`Failed to load route from ${E}:`,N)}}}}enableWatch(i){if(typeof Bun!=="undefined"&&Bun.env.NODE_ENV==="development")console.log(`Watching for route changes in ${this.routesDir}`),setInterval(async()=>{await i()},1000)}}var F;var e=U(()=>{F=(()=>({}));Z()});class B{beforeHandlers=[];finallyHandlers=[];addBefore(...i){this.beforeHandlers.push(...i)}addFinally(...i){this.finallyHandlers.push(...i)}async executeBefore(i){let f=i;for(let l of this.beforeHandlers){let a=await l(f);if(a instanceof Response)return a;f=a}return f}async executeFinally(i,f){let l=i;for(let a of this.finallyHandlers)l=await a(l,f);return l}clone(){let i=new B;return i.beforeHandlers=[...this.beforeHandlers],i.finallyHandlers=[...this.finallyHandlers],i}clear(){this.beforeHandlers=[],this.finallyHandlers=[]}}function ii(i){return process.platform==="win32"?`file:///${i.replace(/\\/g,"/")}`:i}class m{middlewareManager;authManager;cacheManager;routes=[];constructor(i,f,l){this.middlewareManager=i,this.authManager=f,this.cacheManager=l}getRouteSpecificity(i){let E=0,d=i.split("/").filter(Boolean);for(let _ of d)if(this.isStaticSegment(_))E+=1000;else if(this.isParamSegment(_))E+=10;else if(this.isWildcardSegment(_))E+=1;if(E+=i.length,this.isExactPath(i))E+=1e4;return E}isStaticSegment(i){return!i.startsWith(":")&&!i.includes("*")}isParamSegment(i){return i.startsWith(":")}isWildcardSegment(i){return i.includes("*")}isExactPath(i){return!i.includes(":")&&!i.includes("*")}sortRoutes(){this.routes.sort((i,f)=>{let l=this.extractPath(i),a=this.extractPath(f),A=this.getRouteSpecificity(l);return this.getRouteSpecificity(a)-A})}extractPath(i){return i[3]||""}route(i,f){let l=this.wrapHandler(i,f),a=[i.method.toUpperCase(),this.createRouteRegex(i.path),[l],i.path];return this.routes.push(a),this.sortRoutes(),a}createRouteRegex(i){return RegExp(`^${i.replace(/\/+(\/|$)/g,"$1").replace(/(\/?\.?):(\w+)\+/g,"($1(?<$2>*))").replace(/(\/?\.?):(\w+)/g,"($1(?<$2>[^$1/]+?))").replace(/\./g,"\\.").replace(/(\/?)\*/g,"($1.*)?")}/*$`)}wrapHandler(i,f){return async(l)=>{let a=l;if(!a.context)a.context={};if(!a.query&&a.url){let A=new URL(a.url),E={};for(let[d,_]of A.searchParams)E[d]=E[d]?[].concat(E[d],_):_;a.query=E}if(i.metadata)a.metadata=i.metadata;l=a;try{if(i.expose===!1)return R.forbidden("Forbidden");let A=await this.middlewareManager.executeBefore(l);if(A instanceof Response)return A;if(l=A,i.auth)try{await this.authManager.authenticate(l)}catch(N){return R.unauthorized(N instanceof Error?N.message:"Authentication failed",i.responseContentType)}if(!i.rawRequest&&l.method!=="GET"&&l.method!=="HEAD")try{let N=l.headers.get("content-type");if(N?.includes("application/json"))l.content=await l.json();else if(N?.includes("application/x-www-form-urlencoded"))l.content=Object.fromEntries(await l.formData());else if(N?.includes("multipart/form-data"))l.content=await l.formData();else l.content=await l.text()}catch{l.content=null}let E,d=i.cache;if(d&&typeof d==="number"&&d>0){let N=this.cacheManager.generateKey(l,{authUser:l.authUser});E=await this.cacheManager.get(N,()=>f(l),d)}else if(d&&typeof d==="object"&&d.ttl){let N=d.key||this.cacheManager.generateKey(l,{authUser:l.authUser});E=await this.cacheManager.get(N,()=>f(l),d.ttl)}else E=await f(l);let _;if(i.rawResponse||E instanceof Response)_=E instanceof Response?E:new Response(E);else _=H(200,E,i.responseContentType);return _=await this.middlewareManager.executeFinally(_,l),_}catch(A){if(A instanceof Response)return A;return console.error("Route handler error:",A),R.internalServerError(A instanceof Error?A.message:String(A),i.responseContentType)}}}addRoute(i){this.routes.push(i),this.sortRoutes()}getRoutes(){return this.routes}async handle(i){let l=new URL(i.url).pathname;for(let[a,A,E]of this.routes)if(i.method==="OPTIONS"||i.method===a){let d=l.match(A);if(d){let _=i;if(!_.context)_.context={};_.params=d.groups||{};for(let N of E){let w=await N(_);if(w)return w}}}return R.notFound("Route not found")}clearRoutes(){this.routes=[]}}var fi=U(()=>{Y()});class u{server=null;router;config;corsHandler;constructor(i,f){if(this.router=i,this.config=f,f.cors){let{preflight:l,corsify:a}=j(this.normalizeCorsOptions(f.cors));this.corsHandler={preflight:l,corsify:a}}}normalizeCorsOptions(i){return{origin:i.origin||"*",credentials:i.credentials!==!1,allowHeaders:Array.isArray(i.allowHeaders)?i.allowHeaders.join(", "):i.allowHeaders||"Content-Type, Authorization",allowMethods:Array.isArray(i.allowMethods)?i.allowMethods.join(", "):i.allowMethods||"GET, POST, PUT, PATCH, DELETE, OPTIONS",exposeHeaders:Array.isArray(i.exposeHeaders)?i.exposeHeaders.join(", "):i.exposeHeaders||"Authorization",maxAge:i.maxAge||86400}}async start(){let i=this.config.port||3000,f=this.config.hostname||"localhost",l=async(a)=>{try{if(this.corsHandler&&a.method==="OPTIONS")return this.corsHandler.preflight(a);let A=await this.router.handle(a);if(this.corsHandler)A=this.corsHandler.corsify(A,a);return A}catch(A){return console.error("Server error:",A),new Response("Internal Server Error",{status:500})}};return this.server=Bun.serve({port:i,hostname:f,reusePort:this.config.reusePort!==!1,fetch:l,error:(a)=>{return console.error("[ERROR] Server error:",a),new Response("Internal Server Error",{status:500})}}),console.log(`→ Vector server running at http://${f}:${i}`),this.server}stop(){if(this.server)this.server.stop(),this.server=null,console.log("Server stopped")}getServer(){return this.server}getPort(){return this.server?.port||this.config.port||3000}getHostname(){return this.server?.hostname||this.config.hostname||"localhost"}getUrl(){let i=this.getPort();return`http://${this.getHostname()}:${i}`}}var li=U(()=>{V()});var ai={};r(ai,{getVectorInstance:()=>Pi,Vector:()=>h});class h{static instance;router;server=null;middlewareManager;authManager;cacheManager;config={};routeScanner=null;routeGenerator=null;_protectedHandler=null;_cacheHandler=null;constructor(){this.middlewareManager=new B,this.authManager=new J,this.cacheManager=new W,this.router=new m(this.middlewareManager,this.authManager,this.cacheManager)}static getInstance(){if(!h.instance)h.instance=new h;return h.instance}setProtectedHandler(i){this._protectedHandler=i,this.authManager.setProtectedHandler(i)}getProtectedHandler(){return this._protectedHandler}setCacheHandler(i){this._cacheHandler=i,this.cacheManager.setCacheHandler(i)}getCacheHandler(){return this._cacheHandler}addRoute(i,f){return this.router.route(i,f)}async startServer(i){if(this.config={...this.config,...i},this.middlewareManager.clear(),i?.before)this.middlewareManager.addBefore(...i.before);if(i?.finally)this.middlewareManager.addFinally(...i.finally);if(this.config.autoDiscover!==!1)await this.discoverRoutes();return this.server=new u(this.router,this.config),await this.server.start()}async discoverRoutes(){let i=this.config.routesDir||"./routes";if(this.routeScanner=new k(i),!this.routeGenerator)this.routeGenerator=new g;try{let f=await this.routeScanner.scan();if(f.length>0){if(this.config.development)await this.routeGenerator.generate(f);for(let l of f)try{let A=await import(ii(l.path)),E=l.name==="default"?A.default:A[l.name];if(E){if(this.isRouteDefinition(E)){let d=E;this.router.route(d.options,d.handler),this.logRouteLoaded(d.options)}else if(this.isRouteEntry(E))this.router.addRoute(E),this.logRouteLoaded(E);else if(typeof E==="function")this.router.route(l.options,E),this.logRouteLoaded(l.options)}}catch(a){console.error(`Failed to load route ${l.name} from ${l.path}:`,a)}this.router.sortRoutes(),console.log(`✅ Loaded ${f.length} routes from ${i}`)}}catch(f){if(f.code!=="ENOENT"&&f.code!=="ENOTDIR")console.error("Failed to discover routes:",f)}}async loadRoute(i){if(typeof i==="function"){let f=i();if(Array.isArray(f))this.router.addRoute(f)}else if(i&&typeof i==="object"){for(let[,f]of Object.entries(i))if(typeof f==="function"){let l=f();if(Array.isArray(l))this.router.addRoute(l)}}}isRouteEntry(i){return Array.isArray(i)&&i.length>=3}isRouteDefinition(i){return i&&typeof i==="object"&&"entry"in i&&"options"in i&&"handler"in i}logRouteLoaded(i){if(Array.isArray(i))console.log(` ✓ Loaded route: ${i[0]} ${i[3]||i[1]}`);else console.log(` ✓ Loaded route: ${i.method} ${i.path}`)}stop(){if(this.server)this.server.stop(),this.server=null;this.router.clearRoutes()}getServer(){return this.server}getRouter(){return this.router}getCacheManager(){return this.cacheManager}getAuthManager(){return this.authManager}static resetInstance(){h.instance=null}}var Pi;var Ei=U(()=>{q();p();e();fi();li();Pi=h.getInstance});function Ai(i,f){let l=Si(i,f);return{entry:[i.method.toUpperCase(),RegExp(`^${i.path.replace(/\/+(\/|$)/g,"$1").replace(/(\/?\.?):(\w+)\+/g,"($1(?<$2>*))").replace(/(\/?\.?):(\w+)/g,"($1(?<$2>[^$1/]+?))").replace(/\./g,"\\.").replace(/(\/?)\*/g,"($1.*)?")}/*$`),[l],i.path],options:i,handler:f}}function hi(i){return JSON.stringify(i??null,(f,l)=>typeof l==="bigint"?l.toString():l)}function D(i,f,l){let a={error:!0,message:f,statusCode:i,timestamp:new Date().toISOString()};return H(i,a,l)}function H(i,f,l=M.JSON){let a=l===M.JSON?hi(f):f;return new Response(a,{status:i,headers:{"content-type":l}})}function Si(i,f){let{auth:l=!1,expose:a=!1,rawRequest:A=!1,rawResponse:E=!1,responseContentType:d=M.JSON}=i;return async(_)=>{if(!a)return R.forbidden("Forbidden");try{if(l)await bi(_,d);if(!A)await s(_);y(_);let N=await f(_);return E?N:Hi.success(N,d)}catch(N){if(N instanceof Response)return N;return R.internalServerError(String(N),d)}}}var Af,_f,Hi,R,bi=async(i,f)=>{let{getVectorInstance:l}=await Promise.resolve().then(() => (Ei(),ai)),A=l().getProtectedHandler();if(!A)throw R.unauthorized("Authentication not configured",f);try{let E=await A(i);i.authUser=E}catch(E){throw R.unauthorized(E instanceof Error?E.message:"Authentication failed",f)}};var Y=U(()=>{V();X();({preflight:Af,corsify:_f}=j({origin:"*",credentials:!0,allowHeaders:"Content-Type, Authorization",allowMethods:"GET, POST, PUT, PATCH, DELETE, OPTIONS",exposeHeaders:"Authorization",maxAge:86400}));Hi={success:(i,f)=>H($.OK,i,f),created:(i,f)=>H($.CREATED,i,f)};R={badRequest:(i="Bad Request",f)=>D($.BAD_REQUEST,i,f),unauthorized:(i="Unauthorized",f)=>D($.UNAUTHORIZED,i,f),paymentRequired:(i="Payment Required",f)=>D(402,i,f),forbidden:(i="Forbidden",f)=>D($.FORBIDDEN,i,f),notFound:(i="Not Found",f)=>D($.NOT_FOUND,i,f),methodNotAllowed:(i="Method Not Allowed",f)=>D(405,i,f),notAcceptable:(i="Not Acceptable",f)=>D(406,i,f),requestTimeout:(i="Request Timeout",f)=>D(408,i,f),conflict:(i="Conflict",f)=>D($.CONFLICT,i,f),gone:(i="Gone",f)=>D(410,i,f),lengthRequired:(i="Length Required",f)=>D(411,i,f),preconditionFailed:(i="Precondition Failed",f)=>D(412,i,f),payloadTooLarge:(i="Payload Too Large",f)=>D(413,i,f),uriTooLong:(i="URI Too Long",f)=>D(414,i,f),unsupportedMediaType:(i="Unsupported Media Type",f)=>D(415,i,f),rangeNotSatisfiable:(i="Range Not Satisfiable",f)=>D(416,i,f),expectationFailed:(i="Expectation Failed",f)=>D(417,i,f),imATeapot:(i="I'm a teapot",f)=>D(418,i,f),misdirectedRequest:(i="Misdirected Request",f)=>D(421,i,f),unprocessableEntity:(i="Unprocessable Entity",f)=>D($.UNPROCESSABLE_ENTITY,i,f),locked:(i="Locked",f)=>D(423,i,f),failedDependency:(i="Failed Dependency",f)=>D(424,i,f),tooEarly:(i="Too Early",f)=>D(425,i,f),upgradeRequired:(i="Upgrade Required",f)=>D(426,i,f),preconditionRequired:(i="Precondition Required",f)=>D(428,i,f),tooManyRequests:(i="Too Many Requests",f)=>D(429,i,f),requestHeaderFieldsTooLarge:(i="Request Header Fields Too Large",f)=>D(431,i,f),unavailableForLegalReasons:(i="Unavailable For Legal Reasons",f)=>D(451,i,f),internalServerError:(i="Internal Server Error",f)=>D($.INTERNAL_SERVER_ERROR,i,f),notImplemented:(i="Not Implemented",f)=>D(501,i,f),badGateway:(i="Bad Gateway",f)=>D(502,i,f),serviceUnavailable:(i="Service Unavailable",f)=>D(503,i,f),gatewayTimeout:(i="Gateway Timeout",f)=>D(504,i,f),httpVersionNotSupported:(i="HTTP Version Not Supported",f)=>D(505,i,f),variantAlsoNegotiates:(i="Variant Also Negotiates",f)=>D(506,i,f),insufficientStorage:(i="Insufficient Storage",f)=>D(507,i,f),loopDetected:(i="Loop Detected",f)=>D(508,i,f),notExtended:(i="Not Extended",f)=>D(510,i,f),networkAuthenticationRequired:(i="Network Authentication Required",f)=>D(511,i,f),invalidArgument:(i="Invalid Argument",f)=>D($.UNPROCESSABLE_ENTITY,i,f),rateLimitExceeded:(i="Rate Limit Exceeded",f)=>D(429,i,f),maintenance:(i="Service Under Maintenance",f)=>D(503,i,f),custom:(i,f,l)=>D(i,f,l)}});var xi={};r(xi,{route:()=>Ai,createResponse:()=>H,APIError:()=>R});module.exports=Ni(xi);Y();Y();
package/dist/index.mjs CHANGED
@@ -18,4 +18,4 @@ export default routes;
18
18
  ${f.join(`,
19
19
  `)}
20
20
  ]);
21
- };`}}var y=R(()=>{z()});var{existsSync:Ii,promises:q}=(()=>({}));class Z{routesDir;constructor(i="./routes"){this.routesDir=x(process.cwd(),i)}async scan(){let i=[];if(!Ii(this.routesDir))return console.log(` → Routes directory not found: ${this.routesDir}`),console.log(" → No routes will be auto-discovered"),[];try{if(console.log(` → Scanning routes from: ${this.routesDir}`),await this.scanDirectory(this.routesDir,i),i.length>0)console.log(` ✓ Found ${i.length} route${i.length===1?"":"s"}`)}catch(f){if(f.code==="ENOENT")return console.warn(` ✗ Routes directory not accessible: ${this.routesDir}`),[];throw f}return i}async scanDirectory(i,f,l=""){let E=await q.readdir(i);for(let A of E){let a=J(i,A);if((await q.stat(a)).isDirectory()){let _=l?`${l}/${A}`:A;await this.scanDirectory(a,f,_)}else if(A.endsWith(".ts")||A.endsWith(".js")){let _=G(this.routesDir,a).replace(/\.(ts|js)$/,"").split(W).join("/");try{let w=await import(process.platform==="win32"?`file:///${a.replace(/\\/g,"/")}`:a);if(w.default&&typeof w.default==="function")f.push({name:"default",path:a,method:"GET",options:{method:"GET",path:`/${_}`,expose:!0}});for(let[O,I]of Object.entries(w)){if(O==="default")continue;if(I&&typeof I==="object"&&"entry"in I&&"options"in I&&"handler"in I){let L=I;f.push({name:O,path:a,method:L.options.method,options:L.options})}else if(Array.isArray(I)&&I.length>=4){let[L,,,P]=I;f.push({name:O,path:a,method:L,options:{method:L,path:P,expose:!0}})}}}catch(N){console.error(`Failed to load route from ${a}:`,N)}}}}enableWatch(i){if(typeof Bun!=="undefined"&&Bun.env.NODE_ENV==="development")console.log(`Watching for route changes in ${this.routesDir}`),setInterval(async()=>{await i()},1000)}}var t=R(()=>{z()});class T{beforeHandlers=[];finallyHandlers=[];addBefore(...i){this.beforeHandlers.push(...i)}addFinally(...i){this.finallyHandlers.push(...i)}async executeBefore(i){let f=i;for(let l of this.beforeHandlers){let E=await l(f);if(E instanceof Response)return E;f=E}return f}async executeFinally(i,f){let l=i;for(let E of this.finallyHandlers)l=await E(l,f);return l}clone(){let i=new T;return i.beforeHandlers=[...this.beforeHandlers],i.finallyHandlers=[...this.finallyHandlers],i}clear(){this.beforeHandlers=[],this.finallyHandlers=[]}}function o(i){return process.platform==="win32"?`file:///${i.replace(/\\/g,"/")}`:i}class v{middlewareManager;authManager;cacheManager;routes=[];constructor(i,f,l){this.middlewareManager=i,this.authManager=f,this.cacheManager=l}getRouteSpecificity(i){let a=0,d=i.split("/").filter(Boolean);for(let _ of d)if(this.isStaticSegment(_))a+=1000;else if(this.isParamSegment(_))a+=10;else if(this.isWildcardSegment(_))a+=1;if(a+=i.length,this.isExactPath(i))a+=1e4;return a}isStaticSegment(i){return!i.startsWith(":")&&!i.includes("*")}isParamSegment(i){return i.startsWith(":")}isWildcardSegment(i){return i.includes("*")}isExactPath(i){return!i.includes(":")&&!i.includes("*")}sortRoutes(){this.routes.sort((i,f)=>{let l=this.extractPath(i),E=this.extractPath(f),A=this.getRouteSpecificity(l);return this.getRouteSpecificity(E)-A})}extractPath(i){return i[3]||""}route(i,f){let l=this.wrapHandler(i,f),E=[i.method.toUpperCase(),this.createRouteRegex(i.path),[l],i.path];return this.routes.push(E),this.sortRoutes(),E}createRouteRegex(i){return RegExp(`^${i.replace(/\/+(\/|$)/g,"$1").replace(/(\/?\.?):(\w+)\+/g,"($1(?<$2>*))").replace(/(\/?\.?):(\w+)/g,"($1(?<$2>[^$1/]+?))").replace(/\./g,"\\.").replace(/(\/?)\*/g,"($1.*)?")}/*$`)}wrapHandler(i,f){return async(l)=>{let E=l;if(!E.context)E.context={};if(!E.query&&E.url){let A=new URL(E.url),a={};for(let[d,_]of A.searchParams)a[d]=a[d]?[].concat(a[d],_):_;E.query=a}if(i.metadata)E.metadata=i.metadata;l=E;try{if(i.expose===!1)return C.forbidden("Forbidden");let A=await this.middlewareManager.executeBefore(l);if(A instanceof Response)return A;if(l=A,i.auth)try{await this.authManager.authenticate(l)}catch(N){return C.unauthorized(N instanceof Error?N.message:"Authentication failed",i.responseContentType)}if(!i.rawRequest&&l.method!=="GET"&&l.method!=="HEAD")try{let N=l.headers.get("content-type");if(N?.includes("application/json"))l.content=await l.json();else if(N?.includes("application/x-www-form-urlencoded"))l.content=Object.fromEntries(await l.formData());else if(N?.includes("multipart/form-data"))l.content=await l.formData();else l.content=await l.text()}catch{l.content=null}let a,d=i.cache;if(d&&typeof d==="number"&&d>0){let N=this.cacheManager.generateKey(l,{authUser:l.authUser});a=await this.cacheManager.get(N,()=>f(l),d)}else if(d&&typeof d==="object"&&d.ttl){let N=d.key||this.cacheManager.generateKey(l,{authUser:l.authUser});a=await this.cacheManager.get(N,()=>f(l),d.ttl)}else a=await f(l);let _;if(i.rawResponse||a instanceof Response)_=a instanceof Response?a:new Response(a);else _=b(200,a,i.responseContentType);return _=await this.middlewareManager.executeFinally(_,l),_}catch(A){if(A instanceof Response)return A;return console.error("Route handler error:",A),C.internalServerError(A instanceof Error?A.message:String(A),i.responseContentType)}}}addRoute(i){this.routes.push(i),this.sortRoutes()}getRoutes(){return this.routes}async handle(i){let l=new URL(i.url).pathname;for(let[E,A,a]of this.routes)if(i.method==="OPTIONS"||i.method===E){let d=l.match(A);if(d){let _=i;if(!_.context)_.context={};_.params=d.groups||{};for(let N of a){let w=await N(_);if(w)return w}}}return C.notFound("Route not found")}clearRoutes(){this.routes=[]}}var p=R(()=>{B()});class g{server=null;router;config;corsHandler;constructor(i,f){if(this.router=i,this.config=f,f.cors){let{preflight:l,corsify:E}=F(this.normalizeCorsOptions(f.cors));this.corsHandler={preflight:l,corsify:E}}}normalizeCorsOptions(i){return{origin:i.origin||"*",credentials:i.credentials!==!1,allowHeaders:Array.isArray(i.allowHeaders)?i.allowHeaders.join(", "):i.allowHeaders||"Content-Type, Authorization",allowMethods:Array.isArray(i.allowMethods)?i.allowMethods.join(", "):i.allowMethods||"GET, POST, PUT, PATCH, DELETE, OPTIONS",exposeHeaders:Array.isArray(i.exposeHeaders)?i.exposeHeaders.join(", "):i.exposeHeaders||"Authorization",maxAge:i.maxAge||86400}}async start(){let i=this.config.port||3000,f=this.config.hostname||"localhost",l=async(E)=>{try{if(this.corsHandler&&E.method==="OPTIONS")return this.corsHandler.preflight(E);let A=await this.router.handle(E);if(this.corsHandler)A=this.corsHandler.corsify(A,E);return A}catch(A){return console.error("Server error:",A),new Response("Internal Server Error",{status:500})}};return this.server=Bun.serve({port:i,hostname:f,reusePort:this.config.reusePort!==!1,fetch:l,error:(E)=>{return console.error("[ERROR] Server error:",E),new Response("Internal Server Error",{status:500})}}),console.log(`→ Vector server running at http://${f}:${i}`),this.server}stop(){if(this.server)this.server.stop(),this.server=null,console.log("Server stopped")}getServer(){return this.server}getPort(){return this.server?.port||this.config.port||3000}getHostname(){return this.server?.hostname||this.config.hostname||"localhost"}getUrl(){let i=this.getPort();return`http://${this.getHostname()}:${i}`}}var e=R(()=>{Y()});var ii={};ai(ii,{getVectorInstance:()=>Li,Vector:()=>h});class h{static instance;router;server=null;middlewareManager;authManager;cacheManager;config={};routeScanner=null;routeGenerator=null;_protectedHandler=null;_cacheHandler=null;constructor(){this.middlewareManager=new T,this.authManager=new c,this.cacheManager=new X,this.router=new v(this.middlewareManager,this.authManager,this.cacheManager)}static getInstance(){if(!h.instance)h.instance=new h;return h.instance}setProtectedHandler(i){this._protectedHandler=i,this.authManager.setProtectedHandler(i)}getProtectedHandler(){return this._protectedHandler}setCacheHandler(i){this._cacheHandler=i,this.cacheManager.setCacheHandler(i)}getCacheHandler(){return this._cacheHandler}addRoute(i,f){return this.router.route(i,f)}async startServer(i){if(this.config={...this.config,...i},this.middlewareManager.clear(),i?.before)this.middlewareManager.addBefore(...i.before);if(i?.finally)this.middlewareManager.addFinally(...i.finally);if(this.config.autoDiscover!==!1)await this.discoverRoutes();return this.server=new g(this.router,this.config),await this.server.start()}async discoverRoutes(){let i=this.config.routesDir||"./routes";if(!this.routeScanner)this.routeScanner=new Z(i);if(!this.routeGenerator)this.routeGenerator=new K;try{let f=await this.routeScanner.scan();if(f.length>0){if(this.config.development)await this.routeGenerator.generate(f);for(let l of f)try{let A=await import(o(l.path)),a=l.name==="default"?A.default:A[l.name];if(a){if(this.isRouteDefinition(a)){let d=a;this.router.route(d.options,d.handler),this.logRouteLoaded(d.options)}else if(this.isRouteEntry(a))this.router.addRoute(a),this.logRouteLoaded(a);else if(typeof a==="function")this.router.route(l.options,a),this.logRouteLoaded(l.options)}}catch(E){console.error(`Failed to load route ${l.name} from ${l.path}:`,E)}this.router.sortRoutes(),console.log(`✅ Loaded ${f.length} routes from ${i}`)}}catch(f){if(f.code!=="ENOENT"&&f.code!=="ENOTDIR")console.error("Failed to discover routes:",f)}}async loadRoute(i){if(typeof i==="function"){let f=i();if(Array.isArray(f))this.router.addRoute(f)}else if(i&&typeof i==="object"){for(let[,f]of Object.entries(i))if(typeof f==="function"){let l=f();if(Array.isArray(l))this.router.addRoute(l)}}}isRouteEntry(i){return Array.isArray(i)&&i.length>=3}isRouteDefinition(i){return i&&typeof i==="object"&&"entry"in i&&"options"in i&&"handler"in i}logRouteLoaded(i){if(Array.isArray(i))console.log(` ✓ Loaded route: ${i[0]} ${i[3]||i[1]}`);else console.log(` ✓ Loaded route: ${i.method} ${i.path}`)}stop(){if(this.server)this.server.stop(),this.server=null;this.router.clearRoutes()}getServer(){return this.server}getRouter(){return this.router}getCacheManager(){return this.cacheManager}getAuthManager(){return this.authManager}static resetInstance(){h.instance=null}}var Li;var fi=R(()=>{u();y();t();p();e();Li=h.getInstance});function $i(i,f){let l=Pi(i,f);return{entry:[i.method.toUpperCase(),RegExp(`^${i.path.replace(/\/+(\/|$)/g,"$1").replace(/(\/?\.?):(\w+)\+/g,"($1(?<$2>*))").replace(/(\/?\.?):(\w+)/g,"($1(?<$2>[^$1/]+?))").replace(/\./g,"\\.").replace(/(\/?)\*/g,"($1.*)?")}/*$`),[l],i.path],options:i,handler:f}}function Ri(i){return JSON.stringify(i??null,(f,l)=>typeof l==="bigint"?l.toString():l)}function D(i,f,l){let E={error:!0,message:f,statusCode:i,timestamp:new Date().toISOString()};return b(i,E,l)}function b(i,f,l=j.JSON){let E=l===j.JSON?Ri(f):f;return new Response(E,{status:i,headers:{"content-type":l}})}function Pi(i,f){let{auth:l=!1,expose:E=!1,rawRequest:A=!1,rawResponse:a=!1,responseContentType:d=j.JSON}=i;return async(_)=>{if(!E)return C.forbidden("Forbidden");try{if(l)await Ci(_,d);if(!A)await k(_);m(_);let N=await f(_);return a?N:Ui.success(N,d)}catch(N){if(N instanceof Response)return N;return C.internalServerError(String(N),d)}}}var lf,af,Ui,C,Ci=async(i,f)=>{let{getVectorInstance:l}=await Promise.resolve().then(() => (fi(),ii)),A=l().getProtectedHandler();if(!A)throw C.unauthorized("Authentication not configured",f);try{let a=await A(i);i.authUser=a}catch(a){throw C.unauthorized(a instanceof Error?a.message:"Authentication failed",f)}};var B=R(()=>{Y();V();({preflight:lf,corsify:af}=F({origin:"*",credentials:!0,allowHeaders:"Content-Type, Authorization",allowMethods:"GET, POST, PUT, PATCH, DELETE, OPTIONS",exposeHeaders:"Authorization",maxAge:86400}));Ui={success:(i,f)=>b($.OK,i,f),created:(i,f)=>b($.CREATED,i,f)};C={badRequest:(i="Bad Request",f)=>D($.BAD_REQUEST,i,f),unauthorized:(i="Unauthorized",f)=>D($.UNAUTHORIZED,i,f),paymentRequired:(i="Payment Required",f)=>D(402,i,f),forbidden:(i="Forbidden",f)=>D($.FORBIDDEN,i,f),notFound:(i="Not Found",f)=>D($.NOT_FOUND,i,f),methodNotAllowed:(i="Method Not Allowed",f)=>D(405,i,f),notAcceptable:(i="Not Acceptable",f)=>D(406,i,f),requestTimeout:(i="Request Timeout",f)=>D(408,i,f),conflict:(i="Conflict",f)=>D($.CONFLICT,i,f),gone:(i="Gone",f)=>D(410,i,f),lengthRequired:(i="Length Required",f)=>D(411,i,f),preconditionFailed:(i="Precondition Failed",f)=>D(412,i,f),payloadTooLarge:(i="Payload Too Large",f)=>D(413,i,f),uriTooLong:(i="URI Too Long",f)=>D(414,i,f),unsupportedMediaType:(i="Unsupported Media Type",f)=>D(415,i,f),rangeNotSatisfiable:(i="Range Not Satisfiable",f)=>D(416,i,f),expectationFailed:(i="Expectation Failed",f)=>D(417,i,f),imATeapot:(i="I'm a teapot",f)=>D(418,i,f),misdirectedRequest:(i="Misdirected Request",f)=>D(421,i,f),unprocessableEntity:(i="Unprocessable Entity",f)=>D($.UNPROCESSABLE_ENTITY,i,f),locked:(i="Locked",f)=>D(423,i,f),failedDependency:(i="Failed Dependency",f)=>D(424,i,f),tooEarly:(i="Too Early",f)=>D(425,i,f),upgradeRequired:(i="Upgrade Required",f)=>D(426,i,f),preconditionRequired:(i="Precondition Required",f)=>D(428,i,f),tooManyRequests:(i="Too Many Requests",f)=>D(429,i,f),requestHeaderFieldsTooLarge:(i="Request Header Fields Too Large",f)=>D(431,i,f),unavailableForLegalReasons:(i="Unavailable For Legal Reasons",f)=>D(451,i,f),internalServerError:(i="Internal Server Error",f)=>D($.INTERNAL_SERVER_ERROR,i,f),notImplemented:(i="Not Implemented",f)=>D(501,i,f),badGateway:(i="Bad Gateway",f)=>D(502,i,f),serviceUnavailable:(i="Service Unavailable",f)=>D(503,i,f),gatewayTimeout:(i="Gateway Timeout",f)=>D(504,i,f),httpVersionNotSupported:(i="HTTP Version Not Supported",f)=>D(505,i,f),variantAlsoNegotiates:(i="Variant Also Negotiates",f)=>D(506,i,f),insufficientStorage:(i="Insufficient Storage",f)=>D(507,i,f),loopDetected:(i="Loop Detected",f)=>D(508,i,f),notExtended:(i="Not Extended",f)=>D(510,i,f),networkAuthenticationRequired:(i="Network Authentication Required",f)=>D(511,i,f),invalidArgument:(i="Invalid Argument",f)=>D($.UNPROCESSABLE_ENTITY,i,f),rateLimitExceeded:(i="Rate Limit Exceeded",f)=>D(429,i,f),maintenance:(i="Service Under Maintenance",f)=>D(503,i,f),custom:(i,f,l)=>D(i,f,l)}});B();B();export{$i as route,b as createResponse,C as APIError};
21
+ };`}}var y=R(()=>{z()});var{existsSync:Ii,promises:q}=(()=>({}));class Z{routesDir;constructor(i="./routes"){this.routesDir=x(process.cwd(),i)}async scan(){let i=[];if(!Ii(this.routesDir))return console.log(` → Routes directory not found: ${this.routesDir}`),console.log(" → No routes will be auto-discovered"),[];try{if(console.log(` → Scanning routes from: ${this.routesDir}`),await this.scanDirectory(this.routesDir,i),i.length>0)console.log(` ✓ Found ${i.length} route${i.length===1?"":"s"}`)}catch(f){if(f.code==="ENOENT")return console.warn(` ✗ Routes directory not accessible: ${this.routesDir}`),[];throw f}return i}async scanDirectory(i,f,l=""){let E=await q.readdir(i);for(let A of E){let a=J(i,A);if((await q.stat(a)).isDirectory()){let _=l?`${l}/${A}`:A;await this.scanDirectory(a,f,_)}else if(A.endsWith(".ts")||A.endsWith(".js")){let _=G(this.routesDir,a).replace(/\.(ts|js)$/,"").split(W).join("/");try{let w=await import(process.platform==="win32"?`file:///${a.replace(/\\/g,"/")}`:a);if(w.default&&typeof w.default==="function")f.push({name:"default",path:a,method:"GET",options:{method:"GET",path:`/${_}`,expose:!0}});for(let[O,I]of Object.entries(w)){if(O==="default")continue;if(I&&typeof I==="object"&&"entry"in I&&"options"in I&&"handler"in I){let L=I;f.push({name:O,path:a,method:L.options.method,options:L.options})}else if(Array.isArray(I)&&I.length>=4){let[L,,,P]=I;f.push({name:O,path:a,method:L,options:{method:L,path:P,expose:!0}})}}}catch(N){console.error(`Failed to load route from ${a}:`,N)}}}}enableWatch(i){if(typeof Bun!=="undefined"&&Bun.env.NODE_ENV==="development")console.log(`Watching for route changes in ${this.routesDir}`),setInterval(async()=>{await i()},1000)}}var t=R(()=>{z()});class T{beforeHandlers=[];finallyHandlers=[];addBefore(...i){this.beforeHandlers.push(...i)}addFinally(...i){this.finallyHandlers.push(...i)}async executeBefore(i){let f=i;for(let l of this.beforeHandlers){let E=await l(f);if(E instanceof Response)return E;f=E}return f}async executeFinally(i,f){let l=i;for(let E of this.finallyHandlers)l=await E(l,f);return l}clone(){let i=new T;return i.beforeHandlers=[...this.beforeHandlers],i.finallyHandlers=[...this.finallyHandlers],i}clear(){this.beforeHandlers=[],this.finallyHandlers=[]}}function o(i){return process.platform==="win32"?`file:///${i.replace(/\\/g,"/")}`:i}class v{middlewareManager;authManager;cacheManager;routes=[];constructor(i,f,l){this.middlewareManager=i,this.authManager=f,this.cacheManager=l}getRouteSpecificity(i){let a=0,d=i.split("/").filter(Boolean);for(let _ of d)if(this.isStaticSegment(_))a+=1000;else if(this.isParamSegment(_))a+=10;else if(this.isWildcardSegment(_))a+=1;if(a+=i.length,this.isExactPath(i))a+=1e4;return a}isStaticSegment(i){return!i.startsWith(":")&&!i.includes("*")}isParamSegment(i){return i.startsWith(":")}isWildcardSegment(i){return i.includes("*")}isExactPath(i){return!i.includes(":")&&!i.includes("*")}sortRoutes(){this.routes.sort((i,f)=>{let l=this.extractPath(i),E=this.extractPath(f),A=this.getRouteSpecificity(l);return this.getRouteSpecificity(E)-A})}extractPath(i){return i[3]||""}route(i,f){let l=this.wrapHandler(i,f),E=[i.method.toUpperCase(),this.createRouteRegex(i.path),[l],i.path];return this.routes.push(E),this.sortRoutes(),E}createRouteRegex(i){return RegExp(`^${i.replace(/\/+(\/|$)/g,"$1").replace(/(\/?\.?):(\w+)\+/g,"($1(?<$2>*))").replace(/(\/?\.?):(\w+)/g,"($1(?<$2>[^$1/]+?))").replace(/\./g,"\\.").replace(/(\/?)\*/g,"($1.*)?")}/*$`)}wrapHandler(i,f){return async(l)=>{let E=l;if(!E.context)E.context={};if(!E.query&&E.url){let A=new URL(E.url),a={};for(let[d,_]of A.searchParams)a[d]=a[d]?[].concat(a[d],_):_;E.query=a}if(i.metadata)E.metadata=i.metadata;l=E;try{if(i.expose===!1)return C.forbidden("Forbidden");let A=await this.middlewareManager.executeBefore(l);if(A instanceof Response)return A;if(l=A,i.auth)try{await this.authManager.authenticate(l)}catch(N){return C.unauthorized(N instanceof Error?N.message:"Authentication failed",i.responseContentType)}if(!i.rawRequest&&l.method!=="GET"&&l.method!=="HEAD")try{let N=l.headers.get("content-type");if(N?.includes("application/json"))l.content=await l.json();else if(N?.includes("application/x-www-form-urlencoded"))l.content=Object.fromEntries(await l.formData());else if(N?.includes("multipart/form-data"))l.content=await l.formData();else l.content=await l.text()}catch{l.content=null}let a,d=i.cache;if(d&&typeof d==="number"&&d>0){let N=this.cacheManager.generateKey(l,{authUser:l.authUser});a=await this.cacheManager.get(N,()=>f(l),d)}else if(d&&typeof d==="object"&&d.ttl){let N=d.key||this.cacheManager.generateKey(l,{authUser:l.authUser});a=await this.cacheManager.get(N,()=>f(l),d.ttl)}else a=await f(l);let _;if(i.rawResponse||a instanceof Response)_=a instanceof Response?a:new Response(a);else _=b(200,a,i.responseContentType);return _=await this.middlewareManager.executeFinally(_,l),_}catch(A){if(A instanceof Response)return A;return console.error("Route handler error:",A),C.internalServerError(A instanceof Error?A.message:String(A),i.responseContentType)}}}addRoute(i){this.routes.push(i),this.sortRoutes()}getRoutes(){return this.routes}async handle(i){let l=new URL(i.url).pathname;for(let[E,A,a]of this.routes)if(i.method==="OPTIONS"||i.method===E){let d=l.match(A);if(d){let _=i;if(!_.context)_.context={};_.params=d.groups||{};for(let N of a){let w=await N(_);if(w)return w}}}return C.notFound("Route not found")}clearRoutes(){this.routes=[]}}var p=R(()=>{B()});class g{server=null;router;config;corsHandler;constructor(i,f){if(this.router=i,this.config=f,f.cors){let{preflight:l,corsify:E}=F(this.normalizeCorsOptions(f.cors));this.corsHandler={preflight:l,corsify:E}}}normalizeCorsOptions(i){return{origin:i.origin||"*",credentials:i.credentials!==!1,allowHeaders:Array.isArray(i.allowHeaders)?i.allowHeaders.join(", "):i.allowHeaders||"Content-Type, Authorization",allowMethods:Array.isArray(i.allowMethods)?i.allowMethods.join(", "):i.allowMethods||"GET, POST, PUT, PATCH, DELETE, OPTIONS",exposeHeaders:Array.isArray(i.exposeHeaders)?i.exposeHeaders.join(", "):i.exposeHeaders||"Authorization",maxAge:i.maxAge||86400}}async start(){let i=this.config.port||3000,f=this.config.hostname||"localhost",l=async(E)=>{try{if(this.corsHandler&&E.method==="OPTIONS")return this.corsHandler.preflight(E);let A=await this.router.handle(E);if(this.corsHandler)A=this.corsHandler.corsify(A,E);return A}catch(A){return console.error("Server error:",A),new Response("Internal Server Error",{status:500})}};return this.server=Bun.serve({port:i,hostname:f,reusePort:this.config.reusePort!==!1,fetch:l,error:(E)=>{return console.error("[ERROR] Server error:",E),new Response("Internal Server Error",{status:500})}}),console.log(`→ Vector server running at http://${f}:${i}`),this.server}stop(){if(this.server)this.server.stop(),this.server=null,console.log("Server stopped")}getServer(){return this.server}getPort(){return this.server?.port||this.config.port||3000}getHostname(){return this.server?.hostname||this.config.hostname||"localhost"}getUrl(){let i=this.getPort();return`http://${this.getHostname()}:${i}`}}var e=R(()=>{Y()});var ii={};ai(ii,{getVectorInstance:()=>Li,Vector:()=>h});class h{static instance;router;server=null;middlewareManager;authManager;cacheManager;config={};routeScanner=null;routeGenerator=null;_protectedHandler=null;_cacheHandler=null;constructor(){this.middlewareManager=new T,this.authManager=new c,this.cacheManager=new X,this.router=new v(this.middlewareManager,this.authManager,this.cacheManager)}static getInstance(){if(!h.instance)h.instance=new h;return h.instance}setProtectedHandler(i){this._protectedHandler=i,this.authManager.setProtectedHandler(i)}getProtectedHandler(){return this._protectedHandler}setCacheHandler(i){this._cacheHandler=i,this.cacheManager.setCacheHandler(i)}getCacheHandler(){return this._cacheHandler}addRoute(i,f){return this.router.route(i,f)}async startServer(i){if(this.config={...this.config,...i},this.middlewareManager.clear(),i?.before)this.middlewareManager.addBefore(...i.before);if(i?.finally)this.middlewareManager.addFinally(...i.finally);if(this.config.autoDiscover!==!1)await this.discoverRoutes();return this.server=new g(this.router,this.config),await this.server.start()}async discoverRoutes(){let i=this.config.routesDir||"./routes";if(this.routeScanner=new Z(i),!this.routeGenerator)this.routeGenerator=new K;try{let f=await this.routeScanner.scan();if(f.length>0){if(this.config.development)await this.routeGenerator.generate(f);for(let l of f)try{let A=await import(o(l.path)),a=l.name==="default"?A.default:A[l.name];if(a){if(this.isRouteDefinition(a)){let d=a;this.router.route(d.options,d.handler),this.logRouteLoaded(d.options)}else if(this.isRouteEntry(a))this.router.addRoute(a),this.logRouteLoaded(a);else if(typeof a==="function")this.router.route(l.options,a),this.logRouteLoaded(l.options)}}catch(E){console.error(`Failed to load route ${l.name} from ${l.path}:`,E)}this.router.sortRoutes(),console.log(`✅ Loaded ${f.length} routes from ${i}`)}}catch(f){if(f.code!=="ENOENT"&&f.code!=="ENOTDIR")console.error("Failed to discover routes:",f)}}async loadRoute(i){if(typeof i==="function"){let f=i();if(Array.isArray(f))this.router.addRoute(f)}else if(i&&typeof i==="object"){for(let[,f]of Object.entries(i))if(typeof f==="function"){let l=f();if(Array.isArray(l))this.router.addRoute(l)}}}isRouteEntry(i){return Array.isArray(i)&&i.length>=3}isRouteDefinition(i){return i&&typeof i==="object"&&"entry"in i&&"options"in i&&"handler"in i}logRouteLoaded(i){if(Array.isArray(i))console.log(` ✓ Loaded route: ${i[0]} ${i[3]||i[1]}`);else console.log(` ✓ Loaded route: ${i.method} ${i.path}`)}stop(){if(this.server)this.server.stop(),this.server=null;this.router.clearRoutes()}getServer(){return this.server}getRouter(){return this.router}getCacheManager(){return this.cacheManager}getAuthManager(){return this.authManager}static resetInstance(){h.instance=null}}var Li;var fi=R(()=>{u();y();t();p();e();Li=h.getInstance});function $i(i,f){let l=Pi(i,f);return{entry:[i.method.toUpperCase(),RegExp(`^${i.path.replace(/\/+(\/|$)/g,"$1").replace(/(\/?\.?):(\w+)\+/g,"($1(?<$2>*))").replace(/(\/?\.?):(\w+)/g,"($1(?<$2>[^$1/]+?))").replace(/\./g,"\\.").replace(/(\/?)\*/g,"($1.*)?")}/*$`),[l],i.path],options:i,handler:f}}function Ri(i){return JSON.stringify(i??null,(f,l)=>typeof l==="bigint"?l.toString():l)}function D(i,f,l){let E={error:!0,message:f,statusCode:i,timestamp:new Date().toISOString()};return b(i,E,l)}function b(i,f,l=j.JSON){let E=l===j.JSON?Ri(f):f;return new Response(E,{status:i,headers:{"content-type":l}})}function Pi(i,f){let{auth:l=!1,expose:E=!1,rawRequest:A=!1,rawResponse:a=!1,responseContentType:d=j.JSON}=i;return async(_)=>{if(!E)return C.forbidden("Forbidden");try{if(l)await Ci(_,d);if(!A)await k(_);m(_);let N=await f(_);return a?N:Ui.success(N,d)}catch(N){if(N instanceof Response)return N;return C.internalServerError(String(N),d)}}}var lf,af,Ui,C,Ci=async(i,f)=>{let{getVectorInstance:l}=await Promise.resolve().then(() => (fi(),ii)),A=l().getProtectedHandler();if(!A)throw C.unauthorized("Authentication not configured",f);try{let a=await A(i);i.authUser=a}catch(a){throw C.unauthorized(a instanceof Error?a.message:"Authentication failed",f)}};var B=R(()=>{Y();V();({preflight:lf,corsify:af}=F({origin:"*",credentials:!0,allowHeaders:"Content-Type, Authorization",allowMethods:"GET, POST, PUT, PATCH, DELETE, OPTIONS",exposeHeaders:"Authorization",maxAge:86400}));Ui={success:(i,f)=>b($.OK,i,f),created:(i,f)=>b($.CREATED,i,f)};C={badRequest:(i="Bad Request",f)=>D($.BAD_REQUEST,i,f),unauthorized:(i="Unauthorized",f)=>D($.UNAUTHORIZED,i,f),paymentRequired:(i="Payment Required",f)=>D(402,i,f),forbidden:(i="Forbidden",f)=>D($.FORBIDDEN,i,f),notFound:(i="Not Found",f)=>D($.NOT_FOUND,i,f),methodNotAllowed:(i="Method Not Allowed",f)=>D(405,i,f),notAcceptable:(i="Not Acceptable",f)=>D(406,i,f),requestTimeout:(i="Request Timeout",f)=>D(408,i,f),conflict:(i="Conflict",f)=>D($.CONFLICT,i,f),gone:(i="Gone",f)=>D(410,i,f),lengthRequired:(i="Length Required",f)=>D(411,i,f),preconditionFailed:(i="Precondition Failed",f)=>D(412,i,f),payloadTooLarge:(i="Payload Too Large",f)=>D(413,i,f),uriTooLong:(i="URI Too Long",f)=>D(414,i,f),unsupportedMediaType:(i="Unsupported Media Type",f)=>D(415,i,f),rangeNotSatisfiable:(i="Range Not Satisfiable",f)=>D(416,i,f),expectationFailed:(i="Expectation Failed",f)=>D(417,i,f),imATeapot:(i="I'm a teapot",f)=>D(418,i,f),misdirectedRequest:(i="Misdirected Request",f)=>D(421,i,f),unprocessableEntity:(i="Unprocessable Entity",f)=>D($.UNPROCESSABLE_ENTITY,i,f),locked:(i="Locked",f)=>D(423,i,f),failedDependency:(i="Failed Dependency",f)=>D(424,i,f),tooEarly:(i="Too Early",f)=>D(425,i,f),upgradeRequired:(i="Upgrade Required",f)=>D(426,i,f),preconditionRequired:(i="Precondition Required",f)=>D(428,i,f),tooManyRequests:(i="Too Many Requests",f)=>D(429,i,f),requestHeaderFieldsTooLarge:(i="Request Header Fields Too Large",f)=>D(431,i,f),unavailableForLegalReasons:(i="Unavailable For Legal Reasons",f)=>D(451,i,f),internalServerError:(i="Internal Server Error",f)=>D($.INTERNAL_SERVER_ERROR,i,f),notImplemented:(i="Not Implemented",f)=>D(501,i,f),badGateway:(i="Bad Gateway",f)=>D(502,i,f),serviceUnavailable:(i="Service Unavailable",f)=>D(503,i,f),gatewayTimeout:(i="Gateway Timeout",f)=>D(504,i,f),httpVersionNotSupported:(i="HTTP Version Not Supported",f)=>D(505,i,f),variantAlsoNegotiates:(i="Variant Also Negotiates",f)=>D(506,i,f),insufficientStorage:(i="Insufficient Storage",f)=>D(507,i,f),loopDetected:(i="Loop Detected",f)=>D(508,i,f),notExtended:(i="Not Extended",f)=>D(510,i,f),networkAuthenticationRequired:(i="Network Authentication Required",f)=>D(511,i,f),invalidArgument:(i="Invalid Argument",f)=>D($.UNPROCESSABLE_ENTITY,i,f),rateLimitExceeded:(i="Rate Limit Exceeded",f)=>D(429,i,f),maintenance:(i="Service Under Maintenance",f)=>D(503,i,f),custom:(i,f,l)=>D(i,f,l)}});B();B();export{$i as route,b as createResponse,C as APIError};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vector-framework",
3
- "version": "0.9.2",
3
+ "version": "0.9.4",
4
4
  "author": "",
5
5
  "repository": {
6
6
  "type": "git",
package/src/cli/index.ts CHANGED
@@ -6,7 +6,8 @@ import { getVectorInstance } from "../core/vector";
6
6
  import { ConfigLoader } from "../core/config-loader";
7
7
 
8
8
  // Compatibility layer for both Node and Bun
9
- const args = typeof Bun !== 'undefined' ? Bun.argv.slice(2) : process.argv.slice(2);
9
+ const args =
10
+ typeof Bun !== "undefined" ? Bun.argv.slice(2) : process.argv.slice(2);
10
11
 
11
12
  const { values, positionals } = parseArgs({
12
13
  args,
@@ -59,9 +60,10 @@ async function runDev() {
59
60
  const configSource = configLoader.getConfigSource();
60
61
 
61
62
  // Merge CLI options with loaded config
62
- config.port = config.port || Number.parseInt(values.port as string);
63
- config.hostname = config.hostname || (values.host as string);
64
- config.routesDir = config.routesDir || (values.routes as string);
63
+ // Only use CLI values if config doesn't have them
64
+ config.port = config.port ?? Number.parseInt(values.port as string);
65
+ config.hostname = config.hostname ?? (values.host as string);
66
+ config.routesDir = config.routesDir ?? (values.routes as string);
65
67
  config.development = isDev;
66
68
  config.autoDiscover = true;
67
69
 
@@ -100,7 +102,11 @@ async function runDev() {
100
102
  const cyan = "\x1b[36m";
101
103
  const green = "\x1b[32m";
102
104
 
103
- console.log(` ${gray}Config${reset} ${configSource === 'user' ? 'User config loaded' : 'Using defaults'}`);
105
+ console.log(
106
+ ` ${gray}Config${reset} ${
107
+ configSource === "user" ? "User config loaded" : "Using defaults"
108
+ }`
109
+ );
104
110
  console.log(` ${gray}Routes${reset} ${config.routesDir}`);
105
111
  if (isDev && values.watch) {
106
112
  console.log(` ${gray}Watching${reset} All project files`);
@@ -131,31 +137,53 @@ async function runDev() {
131
137
  if (isDev && values.watch) {
132
138
  try {
133
139
  let reloadTimeout: any = null;
140
+ let isReloading = false;
141
+ const changedFiles = new Set<string>();
142
+ let lastReloadTime = 0;
134
143
 
135
144
  // Watch entire project directory for changes
136
145
  watch(process.cwd(), { recursive: true }, async (_, filename) => {
146
+ // Skip if already reloading or if it's too soon after last reload
147
+ const now = Date.now();
148
+ if (isReloading || now - lastReloadTime < 1000) return;
149
+
137
150
  if (
138
151
  filename &&
139
152
  (filename.endsWith(".ts") ||
140
153
  filename.endsWith(".js") ||
141
154
  filename.endsWith(".json")) &&
142
155
  !filename.includes("node_modules") &&
143
- !filename.includes(".git")
156
+ !filename.includes(".git") &&
157
+ !filename.includes(".vector") && // Ignore generated files
158
+ !filename.includes("dist") && // Ignore dist folder
159
+ !filename.includes("bun.lockb") && // Ignore lock files
160
+ !filename.endsWith(".generated.ts") // Ignore generated files
144
161
  ) {
162
+ // Track changed files
163
+ changedFiles.add(filename);
164
+
145
165
  // Debounce reload to avoid multiple restarts
146
166
  if (reloadTimeout) {
147
167
  clearTimeout(reloadTimeout);
148
168
  }
149
169
 
150
170
  reloadTimeout = setTimeout(async () => {
151
- console.log(`\n 🔄 File changed: ${filename}`);
152
- console.log(" 🔄 Reloading server...\n");
171
+ if (isReloading || changedFiles.size === 0) return;
172
+
173
+ isReloading = true;
174
+ lastReloadTime = Date.now();
175
+
176
+ // Clear changed files
177
+ changedFiles.clear();
153
178
 
154
179
  // Stop the current server
155
180
  if (vector) {
156
181
  vector.stop();
157
182
  }
158
183
 
184
+ // Small delay to ensure file system operations complete
185
+ await new Promise((resolve) => setTimeout(resolve, 100));
186
+
159
187
  // Clear module cache to ensure fresh imports
160
188
  for (const key in require.cache) {
161
189
  if (!key.includes("node_modules")) {
@@ -167,10 +195,16 @@ async function runDev() {
167
195
  try {
168
196
  const result = await startServer();
169
197
  server = result.server;
198
+ vector = result.vector;
170
199
  } catch (error) {
171
200
  console.error(" ❌ Failed to reload server:", error);
201
+ } finally {
202
+ // Reset flag after a delay
203
+ setTimeout(() => {
204
+ isReloading = false;
205
+ }, 2000); // 2 second cooldown
172
206
  }
173
- }, 100); // 100ms debounce
207
+ }, 500); // Increased debounce to 500ms
174
208
  }
175
209
  });
176
210
  } catch (err) {
@@ -199,7 +233,7 @@ async function runBuild() {
199
233
  console.log(` Generated ${routes.length} routes`);
200
234
 
201
235
  // Use spawn based on runtime
202
- if (typeof Bun !== 'undefined') {
236
+ if (typeof Bun !== "undefined") {
203
237
  const buildProcess = Bun.spawn([
204
238
  "bun",
205
239
  "build",
@@ -211,11 +245,15 @@ async function runBuild() {
211
245
  await buildProcess.exited;
212
246
  } else {
213
247
  // For Node.js, use child_process
214
- const { spawnSync } = await import('child_process');
215
- spawnSync('bun', ['build', 'src/index.ts', '--outdir', 'dist', '--minify'], {
216
- stdio: 'inherit',
217
- shell: true
218
- });
248
+ const { spawnSync } = await import("child_process");
249
+ spawnSync(
250
+ "bun",
251
+ ["build", "src/index.ts", "--outdir", "dist", "--minify"],
252
+ {
253
+ stdio: "inherit",
254
+ shell: true,
255
+ }
256
+ );
219
257
  }
220
258
 
221
259
  console.log("\n ✓ Build complete\n");
@@ -67,10 +67,15 @@ export class ConfigLoader<TTypes extends VectorTypes = DefaultVectorTypes> {
67
67
  config.development = this.config.server.development;
68
68
  }
69
69
 
70
- // Routes configuration
70
+ // Routes configuration - support both new and legacy formats
71
71
  if (this.config?.routes) {
72
+ // New format: { routes: { dir: string } }
72
73
  config.routesDir = this.config.routes.dir || './routes';
73
74
  config.autoDiscover = this.config.routes.autoDiscover !== false;
75
+ } else if ((this.config as any)?.routesDir) {
76
+ // Legacy format: { routesDir: string }
77
+ config.routesDir = (this.config as any).routesDir;
78
+ config.autoDiscover = (this.config as any).autoDiscover !== false;
74
79
  } else {
75
80
  config.routesDir = './routes';
76
81
  config.autoDiscover = true;
@@ -97,28 +102,22 @@ export class ConfigLoader<TTypes extends VectorTypes = DefaultVectorTypes> {
97
102
  // Load middleware - support both direct functions and file paths
98
103
  if (this.config?.before) {
99
104
  // Direct functions provided
100
- console.log('Using direct before middleware functions:', this.config.before.length);
101
105
  config.before = this.config.before;
102
106
  } else if (this.config?.middleware?.before) {
103
107
  // File paths provided (legacy)
104
- console.log('Loading before middleware from file paths:', this.config.middleware.before);
105
108
  config.before = await this.loadMiddleware<BeforeMiddlewareHandler<TTypes>>(
106
109
  this.config.middleware.before
107
110
  );
108
- console.log('Loaded before middleware:', config.before?.length);
109
111
  }
110
112
 
111
113
  if (this.config?.after) {
112
114
  // Direct functions provided
113
- console.log('Using direct after middleware functions:', this.config.after.length);
114
115
  config.finally = this.config.after;
115
116
  } else if (this.config?.middleware?.after) {
116
117
  // File paths provided (legacy)
117
- console.log('Loading after middleware from file paths:', this.config.middleware.after);
118
118
  config.finally = await this.loadMiddleware<AfterMiddlewareHandler<TTypes>>(
119
119
  this.config.middleware.after
120
120
  );
121
- console.log('Loaded after middleware:', config.finally?.length);
122
121
  }
123
122
 
124
123
  return config;
@@ -150,7 +149,6 @@ export class ConfigLoader<TTypes extends VectorTypes = DefaultVectorTypes> {
150
149
  async loadAuthHandler(): Promise<ProtectedHandler<TTypes> | null> {
151
150
  // Direct function provided
152
151
  if (this.config?.auth) {
153
- console.log('Using direct auth handler function');
154
152
  return this.config.auth;
155
153
  }
156
154
 
@@ -180,7 +178,6 @@ export class ConfigLoader<TTypes extends VectorTypes = DefaultVectorTypes> {
180
178
  async loadCacheHandler(): Promise<CacheHandler | null> {
181
179
  // Direct function provided
182
180
  if (this.config?.cache) {
183
- console.log('Using direct cache handler function');
184
181
  return this.config.cache;
185
182
  }
186
183
 
@@ -104,9 +104,9 @@ export class Vector<TTypes extends VectorTypes = DefaultVectorTypes> {
104
104
  private async discoverRoutes() {
105
105
  const routesDir = this.config.routesDir || './routes';
106
106
 
107
- if (!this.routeScanner) {
108
- this.routeScanner = new RouteScanner(routesDir);
109
- }
107
+ // Always create a new RouteScanner with the current config's routesDir
108
+ // to ensure we're using the correct path from the user's config
109
+ this.routeScanner = new RouteScanner(routesDir);
110
110
 
111
111
  if (!this.routeGenerator) {
112
112
  this.routeGenerator = new RouteGenerator();