vector-framework 0.8.1 ā 0.9.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 +78 -56
- package/dist/cache/manager.d.ts +1 -1
- package/dist/cache/manager.d.ts.map +1 -1
- package/dist/cache/manager.js +8 -3
- package/dist/cache/manager.js.map +1 -1
- package/dist/cli/index.js +134 -68
- package/dist/cli/index.js.map +1 -1
- package/dist/core/config-loader.d.ts +13 -0
- package/dist/core/config-loader.d.ts.map +1 -0
- package/dist/core/config-loader.js +166 -0
- package/dist/core/config-loader.js.map +1 -0
- package/dist/core/router.d.ts +1 -0
- package/dist/core/router.d.ts.map +1 -1
- package/dist/core/router.js +5 -1
- package/dist/core/router.js.map +1 -1
- package/dist/core/vector.d.ts +10 -12
- package/dist/core/vector.d.ts.map +1 -1
- package/dist/core/vector.js +37 -31
- package/dist/core/vector.js.map +1 -1
- package/dist/dev/route-generator.js +3 -3
- package/dist/dev/route-generator.js.map +1 -1
- package/dist/dev/route-scanner.d.ts.map +1 -1
- package/dist/dev/route-scanner.js +15 -4
- package/dist/dev/route-scanner.js.map +1 -1
- package/dist/http.d.ts +6 -1
- package/dist/http.d.ts.map +1 -1
- package/dist/http.js +13 -4
- package/dist/http.js.map +1 -1
- package/dist/index.d.ts +4 -12
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +5 -5
- package/dist/middleware/manager.d.ts +2 -1
- package/dist/middleware/manager.d.ts.map +1 -1
- package/dist/middleware/manager.js +4 -0
- package/dist/middleware/manager.js.map +1 -1
- package/dist/types/index.d.ts +26 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/utils/path.d.ts +3 -0
- package/dist/utils/path.d.ts.map +1 -0
- package/dist/utils/path.js +9 -0
- package/dist/utils/path.js.map +1 -0
- package/package.json +2 -2
- package/src/cache/manager.ts +15 -5
- package/src/cli/index.ts +156 -71
- package/src/core/config-loader.ts +193 -0
- package/src/core/router.ts +6 -1
- package/src/core/vector.ts +39 -39
- package/src/dev/route-generator.ts +3 -3
- package/src/dev/route-scanner.ts +15 -4
- package/src/http.ts +21 -5
- package/src/index.ts +11 -16
- package/src/middleware/manager.ts +16 -4
- package/src/types/index.ts +45 -1
- package/src/utils/path.ts +9 -0
package/README.md
CHANGED
|
@@ -4,41 +4,51 @@
|
|
|
4
4
|
|
|
5
5
|
Vector brings the blazing performance of Bun to developers who appreciate the simplicity and elegance of frameworks like Encore. Build production-ready APIs with a familiar, declarative syntax while leveraging Bun's incredible speed.
|
|
6
6
|
|
|
7
|
-
## Why Vector?
|
|
8
|
-
|
|
9
|
-
If you've been looking for Encore-like developer experience with Bun's performance, Vector is your answer. Define your routes declaratively, enjoy automatic type safety, and ship faster than ever.
|
|
10
|
-
|
|
11
|
-
## Features
|
|
12
|
-
|
|
13
|
-
- **Fast & Lightweight** - Built on Bun and itty-router for maximum performance
|
|
14
|
-
- **Type-Safe** - Full TypeScript support with excellent type inference
|
|
15
|
-
- **Auto Route Discovery** - Automatically discovers and loads routes from your filesystem
|
|
16
|
-
- **Middleware System** - Flexible pre/post request middleware pipeline
|
|
17
|
-
- **Built-in Authentication** - Simple but powerful authentication system
|
|
18
|
-
- **Response Caching** - Automatic response caching with configurable TTL
|
|
19
|
-
- **CORS Support** - Configurable CORS with sensible defaults
|
|
20
|
-
- **Developer Experience** - Auto route discovery and CLI tools
|
|
21
|
-
|
|
22
7
|
## Quick Start
|
|
23
8
|
|
|
24
9
|
### Installation
|
|
25
10
|
|
|
26
11
|
```bash
|
|
27
|
-
bun add vector
|
|
12
|
+
bun add vector-framework
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
### Configuration
|
|
16
|
+
|
|
17
|
+
Create a `vector.config.ts` file in your project root:
|
|
18
|
+
|
|
19
|
+
```javascript
|
|
20
|
+
// vector.config.js
|
|
21
|
+
export default {
|
|
22
|
+
port: 3000, // Server port (default: 3000)
|
|
23
|
+
hostname: "localhost", // Server hostname (default: localhost)
|
|
24
|
+
routesDir: "./routes", // Routes directory (default: ./routes)
|
|
25
|
+
development: true, // Development mode
|
|
26
|
+
reusePort: true, // Reuse port (default: true)
|
|
27
|
+
autoDiscover: true, // Auto-discover routes (default: true)
|
|
28
|
+
|
|
29
|
+
// CORS configuration
|
|
30
|
+
cors: {
|
|
31
|
+
origin: "*", // String, array, or function
|
|
32
|
+
credentials: true, // Allow credentials
|
|
33
|
+
allowHeaders: ["Content-Type", "Authorization"],
|
|
34
|
+
allowMethods: ["GET", "POST", "PUT", "DELETE", "OPTIONS"],
|
|
35
|
+
exposeHeaders: ["X-Total-Count"],
|
|
36
|
+
maxAge: 86400, // Preflight cache duration in seconds
|
|
37
|
+
},
|
|
38
|
+
};
|
|
28
39
|
```
|
|
29
40
|
|
|
30
41
|
### Your First API (Encore-style)
|
|
31
42
|
|
|
32
43
|
```typescript
|
|
33
44
|
// routes/hello.ts
|
|
34
|
-
import { route } from "vector";
|
|
45
|
+
import { route } from "vector-framework";
|
|
35
46
|
|
|
36
47
|
// Public endpoint - clean and declarative
|
|
37
48
|
export const hello = route(
|
|
38
49
|
{
|
|
39
50
|
method: "GET",
|
|
40
51
|
path: "/hello/:name",
|
|
41
|
-
expose: true,
|
|
42
52
|
},
|
|
43
53
|
async (req) => {
|
|
44
54
|
const { name } = req.params!;
|
|
@@ -51,7 +61,6 @@ export const getProfile = route(
|
|
|
51
61
|
{
|
|
52
62
|
method: "GET",
|
|
53
63
|
path: "/profile",
|
|
54
|
-
expose: true,
|
|
55
64
|
auth: true, // That's it! Auth handled.
|
|
56
65
|
},
|
|
57
66
|
async (req) => {
|
|
@@ -67,7 +76,7 @@ export const getProfile = route(
|
|
|
67
76
|
|
|
68
77
|
```typescript
|
|
69
78
|
// server.ts
|
|
70
|
-
import vector from "vector";
|
|
79
|
+
import vector from "vector-framework";
|
|
71
80
|
|
|
72
81
|
// Set up auth (once, globally)
|
|
73
82
|
vector.protected = async (request) => {
|
|
@@ -83,13 +92,44 @@ vector.protected = async (request) => {
|
|
|
83
92
|
vector.serve({ port: 3000 });
|
|
84
93
|
```
|
|
85
94
|
|
|
95
|
+
### CLI Commands
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
# Run development server
|
|
99
|
+
bun vector dev
|
|
100
|
+
|
|
101
|
+
# Run production server
|
|
102
|
+
bun vector start
|
|
103
|
+
|
|
104
|
+
# Build for production
|
|
105
|
+
bun vector build
|
|
106
|
+
|
|
107
|
+
# Run with custom options
|
|
108
|
+
bun vector dev --port 3000 --routes ./api
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
## Why Vector?
|
|
112
|
+
|
|
113
|
+
If you've been looking for Encore-like developer experience with Bun's performance, Vector is your answer. Define your routes declaratively, enjoy automatic type safety, and ship faster than ever.
|
|
114
|
+
|
|
115
|
+
## Features
|
|
116
|
+
|
|
117
|
+
- **Fast & Lightweight** - Built on Bun and itty-router for maximum performance
|
|
118
|
+
- **Type-Safe** - Full TypeScript support with excellent type inference
|
|
119
|
+
- **Auto Route Discovery** - Automatically discovers and loads routes from your filesystem
|
|
120
|
+
- **Middleware System** - Flexible pre/post request middleware pipeline
|
|
121
|
+
- **Built-in Authentication** - Simple but powerful authentication system
|
|
122
|
+
- **Response Caching** - Automatic response caching with configurable TTL
|
|
123
|
+
- **CORS Support** - Configurable CORS with sensible defaults
|
|
124
|
+
- **Developer Experience** - Auto route discovery and CLI tools
|
|
125
|
+
|
|
86
126
|
## Familiar Patterns, Modern Performance
|
|
87
127
|
|
|
88
128
|
### Real-World Example: User Service
|
|
89
129
|
|
|
90
130
|
```typescript
|
|
91
131
|
// routes/users.ts
|
|
92
|
-
import { route } from "vector";
|
|
132
|
+
import { route } from "vector-framework";
|
|
93
133
|
import { db } from "../db";
|
|
94
134
|
|
|
95
135
|
// Public endpoint with caching
|
|
@@ -97,7 +137,6 @@ export const listUsers = route(
|
|
|
97
137
|
{
|
|
98
138
|
method: "GET",
|
|
99
139
|
path: "/users",
|
|
100
|
-
expose: true,
|
|
101
140
|
cache: 300, // Cache for 5 minutes
|
|
102
141
|
},
|
|
103
142
|
async () => {
|
|
@@ -111,7 +150,6 @@ export const createUser = route(
|
|
|
111
150
|
{
|
|
112
151
|
method: "POST",
|
|
113
152
|
path: "/users",
|
|
114
|
-
expose: true,
|
|
115
153
|
auth: true, // Auth required
|
|
116
154
|
},
|
|
117
155
|
async (req) => {
|
|
@@ -130,7 +168,6 @@ export const getUser = route(
|
|
|
130
168
|
{
|
|
131
169
|
method: "GET",
|
|
132
170
|
path: "/users/:id",
|
|
133
|
-
expose: true,
|
|
134
171
|
},
|
|
135
172
|
async (req) => {
|
|
136
173
|
const { id } = req.params!;
|
|
@@ -196,41 +233,13 @@ Switching from Encore? You'll feel right at home. Vector provides the same decla
|
|
|
196
233
|
|
|
197
234
|
**The key difference:** Vector runs on Bun, giving you significantly better performance and lower resource usage while maintaining the developer experience you love.
|
|
198
235
|
|
|
199
|
-
## CLI Commands
|
|
200
|
-
|
|
201
|
-
Vector includes a built-in CLI for development and production:
|
|
202
|
-
|
|
203
|
-
```bash
|
|
204
|
-
# Development server
|
|
205
|
-
bun run dev
|
|
206
|
-
|
|
207
|
-
# Production server
|
|
208
|
-
bun run start
|
|
209
|
-
|
|
210
|
-
# Run with custom options
|
|
211
|
-
bun run src/cli/index.ts dev --port 3000 --routes ./api
|
|
212
|
-
```
|
|
213
|
-
|
|
214
|
-
Or use npm scripts:
|
|
215
|
-
|
|
216
|
-
```bash
|
|
217
|
-
# Start development server
|
|
218
|
-
bun run dev
|
|
219
|
-
|
|
220
|
-
# Start production server
|
|
221
|
-
bun run start
|
|
222
|
-
|
|
223
|
-
# Build for production
|
|
224
|
-
bun run build
|
|
225
|
-
```
|
|
226
|
-
|
|
227
236
|
## Route Options
|
|
228
237
|
|
|
229
238
|
```typescript
|
|
230
239
|
interface RouteOptions {
|
|
231
240
|
method: string; // HTTP method (GET, POST, etc.)
|
|
232
241
|
path: string; // Route path with params (/users/:id)
|
|
233
|
-
expose?: boolean; // Make route accessible (default:
|
|
242
|
+
expose?: boolean; // Make route accessible (default: true)
|
|
234
243
|
auth?: boolean; // Require authentication (default: false)
|
|
235
244
|
cache?:
|
|
236
245
|
| number
|
|
@@ -324,6 +333,19 @@ interface VectorConfig {
|
|
|
324
333
|
reusePort?: boolean; // Reuse port (default: true)
|
|
325
334
|
development?: boolean; // Development mode
|
|
326
335
|
routesDir?: string; // Routes directory (default: ./routes)
|
|
336
|
+
autoDiscover?: boolean; // Auto-discover routes (default: true)
|
|
337
|
+
cors?: CorsOptions; // CORS configuration
|
|
338
|
+
before?: BeforeMiddlewareHandler[]; // Pre-request middleware
|
|
339
|
+
finally?: AfterMiddlewareHandler[]; // Post-response middleware
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
interface CorsOptions {
|
|
343
|
+
origin?: string | string[] | ((origin: string) => boolean);
|
|
344
|
+
credentials?: boolean;
|
|
345
|
+
allowHeaders?: string | string[];
|
|
346
|
+
allowMethods?: string | string[];
|
|
347
|
+
exposeHeaders?: string | string[];
|
|
348
|
+
maxAge?: number;
|
|
327
349
|
}
|
|
328
350
|
```
|
|
329
351
|
|
|
@@ -363,8 +385,8 @@ my-app/
|
|
|
363
385
|
Vector is written in TypeScript and provides full type safety with customizable types:
|
|
364
386
|
|
|
365
387
|
```typescript
|
|
366
|
-
import { createVector, route, APIError } from "vector";
|
|
367
|
-
import type { VectorRequest, VectorTypes } from "vector";
|
|
388
|
+
import { createVector, route, APIError } from "vector-framework";
|
|
389
|
+
import type { VectorRequest, VectorTypes } from "vector-framework";
|
|
368
390
|
|
|
369
391
|
// Define your custom user type
|
|
370
392
|
interface MyUser {
|
|
@@ -413,7 +435,7 @@ Vector provides comprehensive built-in error responses for all HTTP status codes
|
|
|
413
435
|
### Common Client Errors (4xx)
|
|
414
436
|
|
|
415
437
|
```typescript
|
|
416
|
-
import { APIError } from "vector";
|
|
438
|
+
import { APIError } from "vector-framework";
|
|
417
439
|
|
|
418
440
|
// Basic errors
|
|
419
441
|
APIError.badRequest("Invalid input"); // 400
|
package/dist/cache/manager.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CacheHandler, DefaultVectorTypes, GetCacheType, VectorTypes } from
|
|
1
|
+
import type { CacheHandler, DefaultVectorTypes, GetCacheType, VectorTypes } from "../types";
|
|
2
2
|
export declare class CacheManager<TTypes extends VectorTypes = DefaultVectorTypes> {
|
|
3
3
|
private cacheHandler;
|
|
4
4
|
private memoryCache;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manager.d.ts","sourceRoot":"","sources":["../../src/cache/manager.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"manager.d.ts","sourceRoot":"","sources":["../../src/cache/manager.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,YAAY,EACZ,kBAAkB,EAClB,YAAY,EACZ,WAAW,EACZ,MAAM,UAAU,CAAC;AAOlB,qBAAa,YAAY,CAAC,MAAM,SAAS,WAAW,GAAG,kBAAkB;IACvE,OAAO,CAAC,YAAY,CAA6B;IACjD,OAAO,CAAC,WAAW,CAAsC;IACzD,OAAO,CAAC,eAAe,CAAsB;IAE7C,eAAe,CAAC,OAAO,EAAE,YAAY;IAI/B,GAAG,CAAC,CAAC,GAAG,YAAY,CAAC,MAAM,CAAC,EAChC,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EACzB,GAAG,GAAE,MAAiC,GACrC,OAAO,CAAC,CAAC,CAAC;YAYC,kBAAkB;IAkBhC,OAAO,CAAC,YAAY;IAIpB,OAAO,CAAC,gBAAgB;IAOxB,OAAO,CAAC,eAAe;IAQvB,OAAO,CAAC,cAAc;IActB,KAAK,IAAI,IAAI;IAQP,GAAG,CAAC,CAAC,GAAG,YAAY,CAAC,MAAM,CAAC,EAChC,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,CAAC,EACR,GAAG,GAAE,MAAiC,GACrC,OAAO,CAAC,IAAI,CAAC;IAchB,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAI5B,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAYzB,WAAW,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE;QAAE,QAAQ,CAAC,EAAE,GAAG,CAAA;KAAE,GAAG,MAAM;CAWpE"}
|
package/dist/cache/manager.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DEFAULT_CONFIG } from
|
|
1
|
+
import { DEFAULT_CONFIG } from "../constants";
|
|
2
2
|
export class CacheManager {
|
|
3
3
|
cacheHandler = null;
|
|
4
4
|
memoryCache = new Map();
|
|
@@ -85,8 +85,13 @@ export class CacheManager {
|
|
|
85
85
|
}
|
|
86
86
|
generateKey(request, options) {
|
|
87
87
|
const url = new URL(request.url);
|
|
88
|
-
const parts = [
|
|
89
|
-
|
|
88
|
+
const parts = [
|
|
89
|
+
request.method,
|
|
90
|
+
url.pathname,
|
|
91
|
+
url.search,
|
|
92
|
+
options?.authUser?.id || "anonymous",
|
|
93
|
+
];
|
|
94
|
+
return parts.join(":");
|
|
90
95
|
}
|
|
91
96
|
}
|
|
92
97
|
//# sourceMappingURL=manager.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manager.js","sourceRoot":"","sources":["../../src/cache/manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"manager.js","sourceRoot":"","sources":["../../src/cache/manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAa9C,MAAM,OAAO,YAAY;IACf,YAAY,GAAwB,IAAI,CAAC;IACzC,WAAW,GAA4B,IAAI,GAAG,EAAE,CAAC;IACjD,eAAe,GAAiB,IAAI,CAAC;IAE7C,eAAe,CAAC,OAAq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CAAC,YAAY,CAAC,GAAG,EAAE,KAAK,IAAI,EAAE,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;YACrD,OAAO;QACT,CAAC;QAED,IAAI,CAAC,gBAAgB,CAAC,GAAG,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC;IACzC,CAAC;IAED,MAAM,CAAC,GAAW;QAChB,OAAO,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IACtC,CAAC;IAED,GAAG,CAAC,GAAW;QACb,MAAM,KAAK,GAAG,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACxC,IAAI,CAAC,KAAK;YAAE,OAAO,KAAK,CAAC;QAEzB,IAAI,KAAK,CAAC,OAAO,IAAI,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC;YAChC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YAC7B,OAAO,KAAK,CAAC;QACf,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;IAED,WAAW,CAAC,OAAgB,EAAE,OAA4B;QACxD,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QACjC,MAAM,KAAK,GAAG;YACZ,OAAO,CAAC,MAAM;YACd,GAAG,CAAC,QAAQ;YACZ,GAAG,CAAC,MAAM;YACV,OAAO,EAAE,QAAQ,EAAE,EAAE,IAAI,WAAW;SACrC,CAAC;QAEF,OAAO,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACzB,CAAC;CACF"}
|
package/dist/cli/index.js
CHANGED
|
@@ -1,123 +1,189 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
|
-
import {
|
|
3
|
-
import { parseArgs } from
|
|
4
|
-
import
|
|
2
|
+
import { watch } from "node:fs";
|
|
3
|
+
import { parseArgs } from "node:util";
|
|
4
|
+
import { getVectorInstance } from "../core/vector";
|
|
5
|
+
import { ConfigLoader } from "../core/config-loader";
|
|
5
6
|
const { values, positionals } = parseArgs({
|
|
6
7
|
args: Bun.argv.slice(2),
|
|
7
8
|
options: {
|
|
8
9
|
port: {
|
|
9
|
-
type:
|
|
10
|
-
short:
|
|
11
|
-
default:
|
|
10
|
+
type: "string",
|
|
11
|
+
short: "p",
|
|
12
|
+
default: "3000",
|
|
12
13
|
},
|
|
13
14
|
host: {
|
|
14
|
-
type:
|
|
15
|
-
short:
|
|
16
|
-
default:
|
|
15
|
+
type: "string",
|
|
16
|
+
short: "h",
|
|
17
|
+
default: "localhost",
|
|
17
18
|
},
|
|
18
19
|
routes: {
|
|
19
|
-
type:
|
|
20
|
-
short:
|
|
21
|
-
default:
|
|
20
|
+
type: "string",
|
|
21
|
+
short: "r",
|
|
22
|
+
default: "./routes",
|
|
22
23
|
},
|
|
23
24
|
watch: {
|
|
24
|
-
type:
|
|
25
|
-
short:
|
|
25
|
+
type: "boolean",
|
|
26
|
+
short: "w",
|
|
26
27
|
default: true,
|
|
27
28
|
},
|
|
28
29
|
cors: {
|
|
29
|
-
type:
|
|
30
|
+
type: "boolean",
|
|
30
31
|
default: true,
|
|
31
32
|
},
|
|
32
33
|
},
|
|
33
34
|
strict: true,
|
|
34
35
|
allowPositionals: true,
|
|
35
36
|
});
|
|
36
|
-
const command = positionals[0] ||
|
|
37
|
+
const command = positionals[0] || "dev";
|
|
37
38
|
async function runDev() {
|
|
38
|
-
const isDev = command ===
|
|
39
|
-
console.log(`\nā Starting Vector ${isDev ?
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
routesDir: values.routes,
|
|
44
|
-
development: isDev,
|
|
45
|
-
autoDiscover: true,
|
|
46
|
-
cors: values.cors
|
|
47
|
-
? {
|
|
48
|
-
origin: '*',
|
|
49
|
-
credentials: true,
|
|
50
|
-
allowHeaders: 'Content-Type, Authorization',
|
|
51
|
-
allowMethods: 'GET, POST, PUT, PATCH, DELETE, OPTIONS',
|
|
52
|
-
exposeHeaders: 'Authorization',
|
|
53
|
-
maxAge: 86400,
|
|
54
|
-
}
|
|
55
|
-
: undefined,
|
|
56
|
-
};
|
|
57
|
-
try {
|
|
58
|
-
const userConfigPath = join(process.cwd(), 'vector.config.ts');
|
|
39
|
+
const isDev = command === "dev";
|
|
40
|
+
console.log(`\nā Starting Vector ${isDev ? "development" : "production"} server\n`);
|
|
41
|
+
let server = null;
|
|
42
|
+
let vector = null;
|
|
43
|
+
async function startServer() {
|
|
59
44
|
try {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
45
|
+
// Load configuration using ConfigLoader
|
|
46
|
+
const configLoader = new ConfigLoader();
|
|
47
|
+
const config = await configLoader.load();
|
|
48
|
+
// Merge CLI options with loaded config
|
|
49
|
+
config.port = config.port || Number.parseInt(values.port);
|
|
50
|
+
config.hostname = config.hostname || values.host;
|
|
51
|
+
config.routesDir = config.routesDir || values.routes;
|
|
52
|
+
config.development = isDev;
|
|
53
|
+
config.autoDiscover = true;
|
|
54
|
+
// Apply CLI CORS option if not set in config
|
|
55
|
+
if (!config.cors && values.cors) {
|
|
56
|
+
config.cors = {
|
|
57
|
+
origin: "*",
|
|
58
|
+
credentials: true,
|
|
59
|
+
allowHeaders: "Content-Type, Authorization",
|
|
60
|
+
allowMethods: "GET, POST, PUT, PATCH, DELETE, OPTIONS",
|
|
61
|
+
exposeHeaders: "Authorization",
|
|
62
|
+
maxAge: 86400,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
// Get Vector instance and configure handlers
|
|
66
|
+
vector = getVectorInstance();
|
|
67
|
+
// Load and set auth handler if configured
|
|
68
|
+
const authHandler = await configLoader.loadAuthHandler();
|
|
69
|
+
if (authHandler) {
|
|
70
|
+
vector.setProtectedHandler(authHandler);
|
|
71
|
+
}
|
|
72
|
+
// Load and set cache handler if configured
|
|
73
|
+
const cacheHandler = await configLoader.loadCacheHandler();
|
|
74
|
+
if (cacheHandler) {
|
|
75
|
+
vector.setCacheHandler(cacheHandler);
|
|
76
|
+
}
|
|
77
|
+
// Start the server
|
|
78
|
+
server = await vector.startServer(config);
|
|
79
|
+
const gray = "\x1b[90m";
|
|
80
|
+
const reset = "\x1b[0m";
|
|
81
|
+
const cyan = "\x1b[36m";
|
|
82
|
+
const green = "\x1b[32m";
|
|
83
|
+
console.log(` ${gray}Routes${reset} ${config.routesDir}`);
|
|
84
|
+
if (isDev && values.watch) {
|
|
85
|
+
console.log(` ${gray}Watching${reset} All project files`);
|
|
63
86
|
}
|
|
87
|
+
console.log(` ${gray}CORS${reset} ${values.cors ? "Enabled" : "Disabled"}`);
|
|
88
|
+
console.log(` ${gray}Mode${reset} ${isDev ? "Development" : "Production"}\n`);
|
|
89
|
+
console.log(` ${green}Ready${reset} ā ${cyan}http://${config.hostname}:${config.port}${reset}\n`);
|
|
90
|
+
return { server, vector, config };
|
|
64
91
|
}
|
|
65
|
-
catch {
|
|
66
|
-
|
|
92
|
+
catch (error) {
|
|
93
|
+
console.error("[ERROR] Failed to start server:", error);
|
|
94
|
+
throw error;
|
|
67
95
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
const
|
|
72
|
-
|
|
73
|
-
|
|
96
|
+
}
|
|
97
|
+
try {
|
|
98
|
+
// Start the server initially
|
|
99
|
+
const result = await startServer();
|
|
100
|
+
server = result.server;
|
|
101
|
+
// Setup file watching for hot reload
|
|
74
102
|
if (isDev && values.watch) {
|
|
75
|
-
|
|
103
|
+
try {
|
|
104
|
+
let reloadTimeout = null;
|
|
105
|
+
// Watch entire project directory for changes
|
|
106
|
+
watch(process.cwd(), { recursive: true }, async (_, filename) => {
|
|
107
|
+
if (filename &&
|
|
108
|
+
(filename.endsWith(".ts") ||
|
|
109
|
+
filename.endsWith(".js") ||
|
|
110
|
+
filename.endsWith(".json")) &&
|
|
111
|
+
!filename.includes("node_modules") &&
|
|
112
|
+
!filename.includes(".git")) {
|
|
113
|
+
// Debounce reload to avoid multiple restarts
|
|
114
|
+
if (reloadTimeout) {
|
|
115
|
+
clearTimeout(reloadTimeout);
|
|
116
|
+
}
|
|
117
|
+
reloadTimeout = setTimeout(async () => {
|
|
118
|
+
console.log(`\n š File changed: ${filename}`);
|
|
119
|
+
console.log(" š Reloading server...\n");
|
|
120
|
+
// Stop the current server
|
|
121
|
+
if (vector) {
|
|
122
|
+
vector.stop();
|
|
123
|
+
}
|
|
124
|
+
// Clear module cache to ensure fresh imports
|
|
125
|
+
for (const key in require.cache) {
|
|
126
|
+
if (!key.includes("node_modules")) {
|
|
127
|
+
delete require.cache[key];
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
// Restart the server
|
|
131
|
+
try {
|
|
132
|
+
const result = await startServer();
|
|
133
|
+
server = result.server;
|
|
134
|
+
}
|
|
135
|
+
catch (error) {
|
|
136
|
+
console.error(" ā Failed to reload server:", error);
|
|
137
|
+
}
|
|
138
|
+
}, 100); // 100ms debounce
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
catch (err) {
|
|
143
|
+
console.warn(" ā ļø File watching not available");
|
|
144
|
+
}
|
|
76
145
|
}
|
|
77
|
-
console.log(` ${gray}CORS${reset} ${values.cors ? 'Enabled' : 'Disabled'}`);
|
|
78
|
-
console.log(` ${gray}Mode${reset} ${isDev ? 'Development' : 'Production'}\n`);
|
|
79
|
-
console.log(` ${green}Ready${reset} ā ${cyan}http://${config.hostname}:${config.port}${reset}\n`);
|
|
80
146
|
}
|
|
81
147
|
catch (error) {
|
|
82
|
-
console.error(
|
|
148
|
+
console.error("[ERROR] Failed to start server:", error);
|
|
83
149
|
process.exit(1);
|
|
84
150
|
}
|
|
85
151
|
}
|
|
86
152
|
async function runBuild() {
|
|
87
|
-
console.log(
|
|
153
|
+
console.log("\nā Building Vector application\n");
|
|
88
154
|
try {
|
|
89
|
-
const { RouteScanner } = await import(
|
|
90
|
-
const { RouteGenerator } = await import(
|
|
155
|
+
const { RouteScanner } = await import("../dev/route-scanner");
|
|
156
|
+
const { RouteGenerator } = await import("../dev/route-generator");
|
|
91
157
|
const scanner = new RouteScanner(values.routes);
|
|
92
158
|
const generator = new RouteGenerator();
|
|
93
159
|
const routes = await scanner.scan();
|
|
94
160
|
await generator.generate(routes);
|
|
95
161
|
console.log(` Generated ${routes.length} routes`);
|
|
96
162
|
const buildProcess = Bun.spawn([
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
163
|
+
"bun",
|
|
164
|
+
"build",
|
|
165
|
+
"src/index.ts",
|
|
166
|
+
"--outdir",
|
|
167
|
+
"dist",
|
|
168
|
+
"--minify",
|
|
103
169
|
]);
|
|
104
170
|
await buildProcess.exited;
|
|
105
|
-
console.log(
|
|
171
|
+
console.log("\n ā Build complete\n");
|
|
106
172
|
}
|
|
107
173
|
catch (error) {
|
|
108
|
-
console.error(
|
|
174
|
+
console.error("[ERROR] Build failed:", error);
|
|
109
175
|
process.exit(1);
|
|
110
176
|
}
|
|
111
177
|
}
|
|
112
178
|
switch (command) {
|
|
113
|
-
case
|
|
179
|
+
case "dev":
|
|
114
180
|
await runDev();
|
|
115
181
|
break;
|
|
116
|
-
case
|
|
182
|
+
case "build":
|
|
117
183
|
await runBuild();
|
|
118
184
|
break;
|
|
119
|
-
case
|
|
120
|
-
process.env.NODE_ENV =
|
|
185
|
+
case "start":
|
|
186
|
+
process.env.NODE_ENV = "production";
|
|
121
187
|
await runDev();
|
|
122
188
|
break;
|
|
123
189
|
default:
|
package/dist/cli/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,
|
|
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,OA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,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"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { CacheHandler, DefaultVectorTypes, ProtectedHandler, VectorConfig, VectorConfigSchema, VectorTypes } from '../types';
|
|
2
|
+
export declare class ConfigLoader<TTypes extends VectorTypes = DefaultVectorTypes> {
|
|
3
|
+
private configPath;
|
|
4
|
+
private config;
|
|
5
|
+
constructor(configPath?: string);
|
|
6
|
+
load(): Promise<VectorConfig<TTypes>>;
|
|
7
|
+
private buildLegacyConfig;
|
|
8
|
+
private loadMiddleware;
|
|
9
|
+
loadAuthHandler(): Promise<ProtectedHandler<TTypes> | null>;
|
|
10
|
+
loadCacheHandler(): Promise<CacheHandler | null>;
|
|
11
|
+
getConfig(): VectorConfigSchema<TTypes> | null;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=config-loader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-loader.d.ts","sourceRoot":"","sources":["../../src/core/config-loader.ts"],"names":[],"mappings":"AAEA,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;gBAE7C,UAAU,SAAqB;IAIrC,IAAI,IAAI,OAAO,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;YAgB7B,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"}
|