vector-framework 0.9.8 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +33 -2
- package/dist/cli/index.js +86 -88
- package/dist/cli/index.js.map +1 -1
- package/dist/cli.js +192 -161
- package/dist/core/config-loader.d.ts.map +1 -1
- package/dist/core/config-loader.js +3 -6
- package/dist/core/config-loader.js.map +1 -1
- package/dist/core/server.d.ts.map +1 -1
- package/dist/core/server.js +1 -2
- package/dist/core/server.js.map +1 -1
- package/dist/core/vector.d.ts.map +1 -1
- package/dist/core/vector.js +8 -4
- package/dist/core/vector.js.map +1 -1
- package/dist/dev/route-scanner.d.ts +5 -2
- package/dist/dev/route-scanner.d.ts.map +1 -1
- package/dist/dev/route-scanner.js +63 -16
- package/dist/dev/route-scanner.js.map +1 -1
- package/dist/index.js +4 -4
- package/dist/index.mjs +4 -4
- package/dist/middleware/manager.d.ts.map +1 -1
- package/dist/middleware/manager.js +8 -1
- package/dist/middleware/manager.js.map +1 -1
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +3 -2
- package/src/cli/index.ts +98 -109
- package/src/core/config-loader.ts +4 -10
- package/src/core/server.ts +1 -2
- package/src/core/vector.ts +9 -4
- package/src/dev/route-scanner.ts +76 -18
- package/src/middleware/manager.ts +7 -1
- package/src/types/index.ts +2 -0
package/dist/cli.js
CHANGED
|
@@ -117,94 +117,128 @@ __export(exports_route_scanner, {
|
|
|
117
117
|
});
|
|
118
118
|
import { existsSync, promises as fs2 } from "fs";
|
|
119
119
|
import { join, relative as relative2, resolve, sep } from "path";
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
120
|
+
var RouteScanner;
|
|
121
|
+
var init_route_scanner = __esm(() => {
|
|
122
|
+
RouteScanner = class RouteScanner {
|
|
123
|
+
routesDir;
|
|
124
|
+
excludePatterns;
|
|
125
|
+
static DEFAULT_EXCLUDE_PATTERNS = [
|
|
126
|
+
"*.test.ts",
|
|
127
|
+
"*.test.js",
|
|
128
|
+
"*.test.tsx",
|
|
129
|
+
"*.test.jsx",
|
|
130
|
+
"*.spec.ts",
|
|
131
|
+
"*.spec.js",
|
|
132
|
+
"*.spec.tsx",
|
|
133
|
+
"*.spec.jsx",
|
|
134
|
+
"*.tests.ts",
|
|
135
|
+
"*.tests.js",
|
|
136
|
+
"**/__tests__/**",
|
|
137
|
+
"*.interface.ts",
|
|
138
|
+
"*.type.ts",
|
|
139
|
+
"*.d.ts"
|
|
140
|
+
];
|
|
141
|
+
constructor(routesDir = "./routes", excludePatterns) {
|
|
142
|
+
this.routesDir = resolve(process.cwd(), routesDir);
|
|
143
|
+
this.excludePatterns = excludePatterns || RouteScanner.DEFAULT_EXCLUDE_PATTERNS;
|
|
130
144
|
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
if (error.code === "ENOENT") {
|
|
135
|
-
console.warn(` \u2717 Routes directory not accessible: ${this.routesDir}`);
|
|
145
|
+
async scan() {
|
|
146
|
+
const routes = [];
|
|
147
|
+
if (!existsSync(this.routesDir)) {
|
|
136
148
|
return [];
|
|
137
149
|
}
|
|
138
|
-
|
|
150
|
+
try {
|
|
151
|
+
await this.scanDirectory(this.routesDir, routes);
|
|
152
|
+
} catch (error) {
|
|
153
|
+
if (error.code === "ENOENT") {
|
|
154
|
+
console.warn(` \u2717 Routes directory not accessible: ${this.routesDir}`);
|
|
155
|
+
return [];
|
|
156
|
+
}
|
|
157
|
+
throw error;
|
|
158
|
+
}
|
|
159
|
+
return routes;
|
|
139
160
|
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
expose: true
|
|
164
|
-
}
|
|
165
|
-
});
|
|
161
|
+
isExcluded(filePath) {
|
|
162
|
+
const relativePath = relative2(this.routesDir, filePath);
|
|
163
|
+
for (const pattern of this.excludePatterns) {
|
|
164
|
+
const regexPattern = pattern.replace(/\./g, "\\.").replace(/\*/g, "[^/]*").replace(/\*\*/g, ".*").replace(/\?/g, ".");
|
|
165
|
+
const regex = new RegExp(`^${regexPattern}$`);
|
|
166
|
+
const filename = relativePath.split(sep).pop() || "";
|
|
167
|
+
if (regex.test(relativePath) || regex.test(filename)) {
|
|
168
|
+
return true;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
return false;
|
|
172
|
+
}
|
|
173
|
+
async scanDirectory(dir, routes, basePath = "") {
|
|
174
|
+
const entries = await fs2.readdir(dir);
|
|
175
|
+
for (const entry of entries) {
|
|
176
|
+
const fullPath = join(dir, entry);
|
|
177
|
+
const stats = await fs2.stat(fullPath);
|
|
178
|
+
if (stats.isDirectory()) {
|
|
179
|
+
const newBasePath = basePath ? `${basePath}/${entry}` : entry;
|
|
180
|
+
await this.scanDirectory(fullPath, routes, newBasePath);
|
|
181
|
+
} else if (entry.endsWith(".ts") || entry.endsWith(".js")) {
|
|
182
|
+
if (this.isExcluded(fullPath)) {
|
|
183
|
+
continue;
|
|
166
184
|
}
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
routes.push({
|
|
173
|
-
name,
|
|
174
|
-
path: fullPath,
|
|
175
|
-
method: routeDef.options.method,
|
|
176
|
-
options: routeDef.options
|
|
177
|
-
});
|
|
178
|
-
} else if (Array.isArray(value) && value.length >= 4) {
|
|
179
|
-
const [method, , , path] = value;
|
|
185
|
+
const routePath = relative2(this.routesDir, fullPath).replace(/\.(ts|js)$/, "").split(sep).join("/");
|
|
186
|
+
try {
|
|
187
|
+
const importPath = process.platform === "win32" ? `file:///${fullPath.replace(/\\/g, "/")}` : fullPath;
|
|
188
|
+
const module = await import(importPath);
|
|
189
|
+
if (module.default && typeof module.default === "function") {
|
|
180
190
|
routes.push({
|
|
181
|
-
name,
|
|
191
|
+
name: "default",
|
|
182
192
|
path: fullPath,
|
|
183
|
-
method,
|
|
193
|
+
method: "GET",
|
|
184
194
|
options: {
|
|
185
|
-
method,
|
|
186
|
-
path
|
|
195
|
+
method: "GET",
|
|
196
|
+
path: `/${routePath}`,
|
|
187
197
|
expose: true
|
|
188
198
|
}
|
|
189
199
|
});
|
|
190
200
|
}
|
|
201
|
+
for (const [name, value] of Object.entries(module)) {
|
|
202
|
+
if (name === "default")
|
|
203
|
+
continue;
|
|
204
|
+
if (value && typeof value === "object" && "entry" in value && "options" in value && "handler" in value) {
|
|
205
|
+
const routeDef = value;
|
|
206
|
+
routes.push({
|
|
207
|
+
name,
|
|
208
|
+
path: fullPath,
|
|
209
|
+
method: routeDef.options.method,
|
|
210
|
+
options: routeDef.options
|
|
211
|
+
});
|
|
212
|
+
} else if (Array.isArray(value) && value.length >= 4) {
|
|
213
|
+
const [method, , , path] = value;
|
|
214
|
+
routes.push({
|
|
215
|
+
name,
|
|
216
|
+
path: fullPath,
|
|
217
|
+
method,
|
|
218
|
+
options: {
|
|
219
|
+
method,
|
|
220
|
+
path,
|
|
221
|
+
expose: true
|
|
222
|
+
}
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
} catch (error) {
|
|
227
|
+
console.error(`Failed to load route from ${fullPath}:`, error);
|
|
191
228
|
}
|
|
192
|
-
} catch (error) {
|
|
193
|
-
console.error(`Failed to load route from ${fullPath}:`, error);
|
|
194
229
|
}
|
|
195
230
|
}
|
|
196
231
|
}
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
}
|
|
232
|
+
enableWatch(callback) {
|
|
233
|
+
if (typeof Bun !== "undefined" && Bun.env.NODE_ENV === "development") {
|
|
234
|
+
console.log(`Watching for route changes in ${this.routesDir}`);
|
|
235
|
+
setInterval(async () => {
|
|
236
|
+
await callback();
|
|
237
|
+
}, 1000);
|
|
238
|
+
}
|
|
204
239
|
}
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
var init_route_scanner = () => {};
|
|
240
|
+
};
|
|
241
|
+
});
|
|
208
242
|
|
|
209
243
|
// src/cli/index.ts
|
|
210
244
|
import { watch } from "fs";
|
|
@@ -436,7 +470,11 @@ class MiddlewareManager {
|
|
|
436
470
|
async executeFinally(response, request) {
|
|
437
471
|
let currentResponse = response;
|
|
438
472
|
for (const handler of this.finallyHandlers) {
|
|
439
|
-
|
|
473
|
+
try {
|
|
474
|
+
currentResponse = await handler(currentResponse, request);
|
|
475
|
+
} catch (error) {
|
|
476
|
+
console.error("After middleware error:", error);
|
|
477
|
+
}
|
|
440
478
|
}
|
|
441
479
|
return currentResponse;
|
|
442
480
|
}
|
|
@@ -850,7 +888,6 @@ class VectorServer {
|
|
|
850
888
|
if (!this.server || !this.server.port) {
|
|
851
889
|
throw new Error(`Failed to start server on ${hostname}:${port} - server object is invalid`);
|
|
852
890
|
}
|
|
853
|
-
console.log(`\u2192 Vector server running at http://${hostname}:${port}`);
|
|
854
891
|
return this.server;
|
|
855
892
|
} catch (error) {
|
|
856
893
|
if (error.code === "EADDRINUSE" || error.message?.includes("address already in use")) {
|
|
@@ -934,6 +971,9 @@ class Vector {
|
|
|
934
971
|
async startServer(config) {
|
|
935
972
|
this.config = { ...this.config, ...config };
|
|
936
973
|
this.middlewareManager.clear();
|
|
974
|
+
if (this.config.autoDiscover !== false) {
|
|
975
|
+
this.router.clearRoutes();
|
|
976
|
+
}
|
|
937
977
|
if (config?.before) {
|
|
938
978
|
this.middlewareManager.addBefore(...config.before);
|
|
939
979
|
}
|
|
@@ -949,7 +989,8 @@ class Vector {
|
|
|
949
989
|
}
|
|
950
990
|
async discoverRoutes() {
|
|
951
991
|
const routesDir = this.config.routesDir || "./routes";
|
|
952
|
-
|
|
992
|
+
const excludePatterns = this.config.routeExcludePatterns;
|
|
993
|
+
this.routeScanner = new RouteScanner(routesDir, excludePatterns);
|
|
953
994
|
if (!this.routeGenerator) {
|
|
954
995
|
this.routeGenerator = new RouteGenerator;
|
|
955
996
|
}
|
|
@@ -1018,7 +1059,6 @@ class Vector {
|
|
|
1018
1059
|
this.server.stop();
|
|
1019
1060
|
this.server = null;
|
|
1020
1061
|
}
|
|
1021
|
-
this.router.clearRoutes();
|
|
1022
1062
|
}
|
|
1023
1063
|
getServer() {
|
|
1024
1064
|
return this.server;
|
|
@@ -1052,20 +1092,17 @@ class ConfigLoader {
|
|
|
1052
1092
|
async load() {
|
|
1053
1093
|
if (existsSync2(this.configPath)) {
|
|
1054
1094
|
try {
|
|
1055
|
-
console.log(`\u2192 Loading config from: ${this.configPath}`);
|
|
1056
1095
|
const userConfigPath = toFileUrl(this.configPath);
|
|
1057
1096
|
const userConfig = await import(userConfigPath);
|
|
1058
1097
|
this.config = userConfig.default || userConfig;
|
|
1059
1098
|
this.configSource = "user";
|
|
1060
|
-
console.log(" \u2713 User config loaded successfully");
|
|
1061
1099
|
} catch (error) {
|
|
1062
|
-
|
|
1063
|
-
|
|
1100
|
+
const red = "\x1B[31m";
|
|
1101
|
+
const reset = "\x1B[0m";
|
|
1102
|
+
console.error(`${red}Error loading config: ${error.message || error}${reset}`);
|
|
1064
1103
|
this.config = {};
|
|
1065
1104
|
}
|
|
1066
1105
|
} else {
|
|
1067
|
-
console.log(` \u2192 No config file found at: ${this.configPath}`);
|
|
1068
|
-
console.log(" \u2192 Using default configuration");
|
|
1069
1106
|
this.config = {};
|
|
1070
1107
|
}
|
|
1071
1108
|
return await this.buildLegacyConfig();
|
|
@@ -1157,9 +1194,6 @@ var { values, positionals } = parseArgs({
|
|
|
1157
1194
|
var command = positionals[0] || "dev";
|
|
1158
1195
|
async function runDev() {
|
|
1159
1196
|
const isDev = command === "dev";
|
|
1160
|
-
console.log(`
|
|
1161
|
-
\u2192 Starting Vector ${isDev ? "development" : "production"} server
|
|
1162
|
-
`);
|
|
1163
1197
|
let server = null;
|
|
1164
1198
|
let vector = null;
|
|
1165
1199
|
async function startServer() {
|
|
@@ -1169,56 +1203,42 @@ async function runDev() {
|
|
|
1169
1203
|
}, 1e4);
|
|
1170
1204
|
});
|
|
1171
1205
|
const serverStartPromise = (async () => {
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
config.
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
if (cacheHandler) {
|
|
1198
|
-
vector.setCacheHandler(cacheHandler);
|
|
1199
|
-
}
|
|
1200
|
-
server = await vector.startServer(config);
|
|
1201
|
-
if (!server || !server.port) {
|
|
1202
|
-
throw new Error("Server started but is not responding correctly");
|
|
1203
|
-
}
|
|
1204
|
-
const gray = "\x1B[90m";
|
|
1205
|
-
const reset = "\x1B[0m";
|
|
1206
|
-
const cyan = "\x1B[36m";
|
|
1207
|
-
const green = "\x1B[32m";
|
|
1208
|
-
console.log(` ${gray}Config${reset} ${configSource === "user" ? "User config loaded" : "Using defaults"}`);
|
|
1209
|
-
console.log(` ${gray}Routes${reset} ${config.routesDir}`);
|
|
1210
|
-
if (isDev && values.watch) {
|
|
1211
|
-
console.log(` ${gray}Watching${reset} All project files`);
|
|
1212
|
-
}
|
|
1213
|
-
console.log(` ${gray}CORS${reset} ${config.cors ? "Enabled" : "Disabled"}`);
|
|
1214
|
-
console.log(` ${gray}Mode${reset} ${config.development ? "Development" : "Production"}
|
|
1215
|
-
`);
|
|
1216
|
-
console.log(` ${green}Ready${reset} \u2192 ${cyan}http://${config.hostname}:${config.port}${reset}
|
|
1217
|
-
`);
|
|
1218
|
-
return { server, vector, config };
|
|
1219
|
-
} catch (error) {
|
|
1220
|
-
throw error;
|
|
1206
|
+
const configLoader = new ConfigLoader(values.config);
|
|
1207
|
+
const config = await configLoader.load();
|
|
1208
|
+
config.port = config.port ?? Number.parseInt(values.port);
|
|
1209
|
+
config.hostname = config.hostname ?? values.host;
|
|
1210
|
+
config.routesDir = config.routesDir ?? values.routes;
|
|
1211
|
+
config.development = config.development ?? isDev;
|
|
1212
|
+
config.autoDiscover = true;
|
|
1213
|
+
if (config.cors === undefined && values.cors) {
|
|
1214
|
+
config.cors = {
|
|
1215
|
+
origin: "*",
|
|
1216
|
+
credentials: true,
|
|
1217
|
+
allowHeaders: "Content-Type, Authorization",
|
|
1218
|
+
allowMethods: "GET, POST, PUT, PATCH, DELETE, OPTIONS",
|
|
1219
|
+
exposeHeaders: "Authorization",
|
|
1220
|
+
maxAge: 86400
|
|
1221
|
+
};
|
|
1222
|
+
}
|
|
1223
|
+
vector = getVectorInstance();
|
|
1224
|
+
const authHandler = await configLoader.loadAuthHandler();
|
|
1225
|
+
if (authHandler) {
|
|
1226
|
+
vector.setProtectedHandler(authHandler);
|
|
1227
|
+
}
|
|
1228
|
+
const cacheHandler = await configLoader.loadCacheHandler();
|
|
1229
|
+
if (cacheHandler) {
|
|
1230
|
+
vector.setCacheHandler(cacheHandler);
|
|
1221
1231
|
}
|
|
1232
|
+
server = await vector.startServer(config);
|
|
1233
|
+
if (!server || !server.port) {
|
|
1234
|
+
throw new Error("Server started but is not responding correctly");
|
|
1235
|
+
}
|
|
1236
|
+
const cyan = "\x1B[36m";
|
|
1237
|
+
const reset = "\x1B[0m";
|
|
1238
|
+
console.log(`
|
|
1239
|
+
Listening on ${cyan}http://${config.hostname}:${config.port}${reset}
|
|
1240
|
+
`);
|
|
1241
|
+
return { server, vector, config };
|
|
1222
1242
|
})();
|
|
1223
1243
|
return await Promise.race([serverStartPromise, timeoutPromise]);
|
|
1224
1244
|
}
|
|
@@ -1250,9 +1270,11 @@ async function runDev() {
|
|
|
1250
1270
|
vector.stop();
|
|
1251
1271
|
}
|
|
1252
1272
|
await new Promise((resolve3) => setTimeout(resolve3, 100));
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1273
|
+
if (__require.cache) {
|
|
1274
|
+
for (const key in __require.cache) {
|
|
1275
|
+
if (!key.includes("node_modules")) {
|
|
1276
|
+
delete __require.cache[key];
|
|
1277
|
+
}
|
|
1256
1278
|
}
|
|
1257
1279
|
}
|
|
1258
1280
|
try {
|
|
@@ -1263,40 +1285,30 @@ async function runDev() {
|
|
|
1263
1285
|
console.error(`
|
|
1264
1286
|
[Reload Error]`, error.message || error);
|
|
1265
1287
|
} finally {
|
|
1266
|
-
|
|
1267
|
-
isReloading = false;
|
|
1268
|
-
}, 2000);
|
|
1288
|
+
isReloading = false;
|
|
1269
1289
|
}
|
|
1270
1290
|
}, 500);
|
|
1271
1291
|
}
|
|
1272
1292
|
});
|
|
1273
|
-
} catch
|
|
1274
|
-
|
|
1293
|
+
} catch {
|
|
1294
|
+
const yellow = "\x1B[33m";
|
|
1295
|
+
const reset = "\x1B[0m";
|
|
1296
|
+
console.warn(`${yellow}Warning: File watching not available${reset}`);
|
|
1275
1297
|
}
|
|
1276
1298
|
}
|
|
1277
1299
|
} catch (error) {
|
|
1278
1300
|
const red = "\x1B[31m";
|
|
1279
1301
|
const reset = "\x1B[0m";
|
|
1280
1302
|
console.error(`
|
|
1281
|
-
${red}
|
|
1303
|
+
${red}Error: ${error.message || error}${reset}
|
|
1282
1304
|
`);
|
|
1283
|
-
if (error.
|
|
1284
|
-
console.error(`Message: ${error.message}`);
|
|
1285
|
-
}
|
|
1286
|
-
if (error.stack) {
|
|
1287
|
-
console.error(`
|
|
1288
|
-
Stack trace:`);
|
|
1305
|
+
if (error.stack && true) {
|
|
1289
1306
|
console.error(error.stack);
|
|
1290
|
-
} else if (!error.message) {
|
|
1291
|
-
console.error(`Raw error:`, error);
|
|
1292
1307
|
}
|
|
1293
1308
|
process.exit(1);
|
|
1294
1309
|
}
|
|
1295
1310
|
}
|
|
1296
1311
|
async function runBuild() {
|
|
1297
|
-
console.log(`
|
|
1298
|
-
\u2192 Building Vector application
|
|
1299
|
-
`);
|
|
1300
1312
|
try {
|
|
1301
1313
|
const { RouteScanner: RouteScanner2 } = await Promise.resolve().then(() => (init_route_scanner(), exports_route_scanner));
|
|
1302
1314
|
const { RouteGenerator: RouteGenerator2 } = await Promise.resolve().then(() => (init_route_generator(), exports_route_generator));
|
|
@@ -1304,29 +1316,48 @@ async function runBuild() {
|
|
|
1304
1316
|
const generator = new RouteGenerator2;
|
|
1305
1317
|
const routes = await scanner.scan();
|
|
1306
1318
|
await generator.generate(routes);
|
|
1307
|
-
console.log(` Generated ${routes.length} routes`);
|
|
1308
1319
|
if (typeof Bun !== "undefined") {
|
|
1309
1320
|
const buildProcess = Bun.spawn([
|
|
1310
1321
|
"bun",
|
|
1311
1322
|
"build",
|
|
1312
|
-
"src/index.ts",
|
|
1313
|
-
"--
|
|
1314
|
-
"
|
|
1323
|
+
"src/cli/index.ts",
|
|
1324
|
+
"--target",
|
|
1325
|
+
"bun",
|
|
1326
|
+
"--outfile",
|
|
1327
|
+
"dist/server.js",
|
|
1315
1328
|
"--minify"
|
|
1316
1329
|
]);
|
|
1317
|
-
await buildProcess.exited;
|
|
1330
|
+
const exitCode = await buildProcess.exited;
|
|
1331
|
+
if (exitCode !== 0) {
|
|
1332
|
+
throw new Error(`Build failed with exit code ${exitCode}`);
|
|
1333
|
+
}
|
|
1318
1334
|
} else {
|
|
1319
1335
|
const { spawnSync } = await import("child_process");
|
|
1320
|
-
spawnSync("bun", [
|
|
1336
|
+
const result = spawnSync("bun", [
|
|
1337
|
+
"build",
|
|
1338
|
+
"src/cli/index.ts",
|
|
1339
|
+
"--target",
|
|
1340
|
+
"bun",
|
|
1341
|
+
"--outfile",
|
|
1342
|
+
"dist/server.js",
|
|
1343
|
+
"--minify"
|
|
1344
|
+
], {
|
|
1321
1345
|
stdio: "inherit",
|
|
1322
1346
|
shell: true
|
|
1323
1347
|
});
|
|
1348
|
+
if (result.status !== 0) {
|
|
1349
|
+
throw new Error(`Build failed with exit code ${result.status}`);
|
|
1350
|
+
}
|
|
1324
1351
|
}
|
|
1325
1352
|
console.log(`
|
|
1326
|
-
|
|
1353
|
+
Build complete: dist/server.js
|
|
1327
1354
|
`);
|
|
1328
1355
|
} catch (error) {
|
|
1329
|
-
|
|
1356
|
+
const red = "\x1B[31m";
|
|
1357
|
+
const reset = "\x1B[0m";
|
|
1358
|
+
console.error(`
|
|
1359
|
+
${red}Error: ${error.message || error}${reset}
|
|
1360
|
+
`);
|
|
1330
1361
|
process.exit(1);
|
|
1331
1362
|
}
|
|
1332
1363
|
}
|
|
@@ -1 +1 @@
|
|
|
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,CAAC,EAAE,MAAM;IAUzB,IAAI,IAAI,OAAO,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;
|
|
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,CAAC,EAAE,MAAM;IAUzB,IAAI,IAAI,OAAO,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;IA0B3C,eAAe,IAAI,MAAM,GAAG,SAAS;YAIvB,iBAAiB;IA8CzB,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"}
|
|
@@ -17,24 +17,21 @@ export class ConfigLoader {
|
|
|
17
17
|
// Check if config file exists before attempting to load
|
|
18
18
|
if (existsSync(this.configPath)) {
|
|
19
19
|
try {
|
|
20
|
-
console.log(`→ Loading config from: ${this.configPath}`);
|
|
21
20
|
// Use explicit file:// URL to ensure correct resolution
|
|
22
21
|
const userConfigPath = toFileUrl(this.configPath);
|
|
23
22
|
const userConfig = await import(userConfigPath);
|
|
24
23
|
this.config = userConfig.default || userConfig;
|
|
25
24
|
this.configSource = "user";
|
|
26
|
-
console.log(" ✓ User config loaded successfully");
|
|
27
25
|
}
|
|
28
26
|
catch (error) {
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
const red = "\x1b[31m";
|
|
28
|
+
const reset = "\x1b[0m";
|
|
29
|
+
console.error(`${red}Error loading config: ${error.message || error}${reset}`);
|
|
31
30
|
this.config = {};
|
|
32
31
|
}
|
|
33
32
|
}
|
|
34
33
|
else {
|
|
35
34
|
// Config file doesn't exist, use defaults
|
|
36
|
-
console.log(` → No config file found at: ${this.configPath}`);
|
|
37
|
-
console.log(" → Using default configuration");
|
|
38
35
|
this.config = {};
|
|
39
36
|
}
|
|
40
37
|
// Convert new config schema to legacy VectorConfig format
|
|
@@ -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,UAAU,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAW1C,MAAM,OAAO,YAAY;IACf,UAAU,CAAS;IACnB,MAAM,GAAsC,IAAI,CAAC;IACjD,YAAY,GAAuB,SAAS,CAAC;IAErD,YAAY,UAAmB;QAC7B,0DAA0D;QAC1D,MAAM,IAAI,GAAG,UAAU,IAAI,kBAAkB,CAAC;QAE9C,oCAAoC;QACpC,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC,IAAI,CAAC;YAChC,CAAC,CAAC,IAAI;YACN,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,IAAI,CAAC,CAAC;IACnC,CAAC;IAED,KAAK,CAAC,IAAI;QACR,wDAAwD;QACxD,IAAI,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC;YAChC,IAAI,CAAC;gBACH,
|
|
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,UAAU,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAW1C,MAAM,OAAO,YAAY;IACf,UAAU,CAAS;IACnB,MAAM,GAAsC,IAAI,CAAC;IACjD,YAAY,GAAuB,SAAS,CAAC;IAErD,YAAY,UAAmB;QAC7B,0DA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AM,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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/core/server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,KAAK,CAAC;AAElC,OAAO,KAAK,EAEV,kBAAkB,EAClB,YAAY,EACZ,WAAW,EACZ,MAAM,UAAU,CAAC;AAClB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAE7C,qBAAa,YAAY,CAAC,MAAM,SAAS,WAAW,GAAG,kBAAkB;IACvE,OAAO,CAAC,MAAM,CAAuB;IACrC,OAAO,CAAC,MAAM,CAAuB;IACrC,OAAO,CAAC,MAAM,CAAuB;IACrC,OAAO,CAAC,WAAW,CAAM;gBAEb,MAAM,EAAE,YAAY,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,YAAY,CAAC,MAAM,CAAC;IAYtE,OAAO,CAAC,oBAAoB;IAiBtB,KAAK,IAAI,OAAO,CAAC,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/core/server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,KAAK,CAAC;AAElC,OAAO,KAAK,EAEV,kBAAkB,EAClB,YAAY,EACZ,WAAW,EACZ,MAAM,UAAU,CAAC;AAClB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAE7C,qBAAa,YAAY,CAAC,MAAM,SAAS,WAAW,GAAG,kBAAkB;IACvE,OAAO,CAAC,MAAM,CAAuB;IACrC,OAAO,CAAC,MAAM,CAAuB;IACrC,OAAO,CAAC,MAAM,CAAuB;IACrC,OAAO,CAAC,WAAW,CAAM;gBAEb,MAAM,EAAE,YAAY,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,YAAY,CAAC,MAAM,CAAC;IAYtE,OAAO,CAAC,oBAAoB;IAiBtB,KAAK,IAAI,OAAO,CAAC,MAAM,CAAC;IAgE9B,IAAI;IAQJ,SAAS,IAAI,MAAM,GAAG,IAAI;IAI1B,OAAO,IAAI,MAAM;IAIjB,WAAW,IAAI,MAAM;IAIrB,MAAM,IAAI,MAAM;CAKjB"}
|
package/dist/core/server.js
CHANGED
|
@@ -66,8 +66,7 @@ export class VectorServer {
|
|
|
66
66
|
if (!this.server || !this.server.port) {
|
|
67
67
|
throw new Error(`Failed to start server on ${hostname}:${port} - server object is invalid`);
|
|
68
68
|
}
|
|
69
|
-
// Server logs are handled by CLI
|
|
70
|
-
console.log(`→ Vector server running at http://${hostname}:${port}`);
|
|
69
|
+
// Server logs are handled by CLI
|
|
71
70
|
return this.server;
|
|
72
71
|
}
|
|
73
72
|
catch (error) {
|
package/dist/core/server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/core/server.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AASnC,MAAM,OAAO,YAAY;IACf,MAAM,GAAkB,IAAI,CAAC;IAC7B,MAAM,CAAuB;IAC7B,MAAM,CAAuB;IAC7B,WAAW,CAAM;IAEzB,YAAY,MAA4B,EAAE,MAA4B;QACpE,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QAErB,IAAI,MAAM,CAAC,I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C5B,UAAU;IAKP,WAAW,CAAC,MAAM,CAAC,EAAE,YAAY,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC;YA6BnD,cAAc;IAgEtB,SAAS,CAAC,WAAW,EAAE,GAAG;IAkBhC,OAAO,CAAC,YAAY;IAIpB,OAAO,CAAC,iBAAiB;IAUzB,OAAO,CAAC,cAAc;IAItB,IAAI,IAAI,IAAI;IASZ,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
|
@@ -57,6 +57,10 @@ export class Vector {
|
|
|
57
57
|
this.config = { ...this.config, ...config };
|
|
58
58
|
// Clear previous middleware to avoid accumulation across multiple starts
|
|
59
59
|
this.middlewareManager.clear();
|
|
60
|
+
// Only clear routes if we're doing auto-discovery
|
|
61
|
+
if (this.config.autoDiscover !== false) {
|
|
62
|
+
this.router.clearRoutes();
|
|
63
|
+
}
|
|
60
64
|
if (config?.before) {
|
|
61
65
|
this.middlewareManager.addBefore(...config.before);
|
|
62
66
|
}
|
|
@@ -72,9 +76,10 @@ export class Vector {
|
|
|
72
76
|
}
|
|
73
77
|
async discoverRoutes() {
|
|
74
78
|
const routesDir = this.config.routesDir || "./routes";
|
|
79
|
+
const excludePatterns = this.config.routeExcludePatterns;
|
|
75
80
|
// Always create a new RouteScanner with the current config's routesDir
|
|
76
81
|
// to ensure we're using the correct path from the user's config
|
|
77
|
-
this.routeScanner = new RouteScanner(routesDir);
|
|
82
|
+
this.routeScanner = new RouteScanner(routesDir, excludePatterns);
|
|
78
83
|
if (!this.routeGenerator) {
|
|
79
84
|
this.routeGenerator = new RouteGenerator();
|
|
80
85
|
}
|
|
@@ -158,9 +163,8 @@ export class Vector {
|
|
|
158
163
|
this.server.stop();
|
|
159
164
|
this.server = null;
|
|
160
165
|
}
|
|
161
|
-
// Don't reset managers - they
|
|
162
|
-
//
|
|
163
|
-
this.router.clearRoutes();
|
|
166
|
+
// Don't reset managers or routes - they persist for the singleton
|
|
167
|
+
// Routes will be cleared on next startServer() call
|
|
164
168
|
}
|
|
165
169
|
getServer() {
|
|
166
170
|
return this.server;
|