vector-framework 0.9.6 → 0.9.8

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/src/http.ts CHANGED
@@ -1,17 +1,13 @@
1
- import {
2
- cors,
3
- type IRequest,
4
- type RouteEntry,
5
- withContent,
6
- withCookies,
7
- } from "itty-router";
1
+ import { cors, type IRequest, type RouteEntry, withContent } from "itty-router";
8
2
  import { CONTENT_TYPES, HTTP_STATUS } from "./constants";
9
3
  import type {
4
+ CacheOptions,
10
5
  DefaultVectorTypes,
11
6
  GetAuthType,
12
7
  VectorRequest,
13
8
  VectorTypes,
14
9
  } from "./types";
10
+ import { getVectorInstance } from "./core/vector";
15
11
 
16
12
  export interface ProtectedRequest<
17
13
  TTypes extends VectorTypes = DefaultVectorTypes
@@ -33,7 +29,9 @@ interface ExtendedApiOptions extends ApiOptions {
33
29
  path: string;
34
30
  }
35
31
 
36
- export interface RouteDefinition<TTypes extends VectorTypes = DefaultVectorTypes> {
32
+ export interface RouteDefinition<
33
+ TTypes extends VectorTypes = DefaultVectorTypes
34
+ > {
37
35
  entry: RouteEntry;
38
36
  options: ExtendedApiOptions;
39
37
  handler: (req: VectorRequest<TTypes>) => Promise<unknown>;
@@ -64,7 +62,7 @@ export function route<TTypes extends VectorTypes = DefaultVectorTypes>(
64
62
  return {
65
63
  entry,
66
64
  options,
67
- handler: fn
65
+ handler: fn,
68
66
  };
69
67
  }
70
68
 
@@ -263,7 +261,6 @@ export const protectedRoute = async <
263
261
  responseContentType?: string
264
262
  ) => {
265
263
  // Get the Vector instance to access the protected handler
266
- const { getVectorInstance } = await import("./core/vector");
267
264
  const vector = getVectorInstance();
268
265
 
269
266
  const protectedHandler = vector.getProtectedHandler();
@@ -290,7 +287,7 @@ export interface ApiOptions {
290
287
  expose?: boolean;
291
288
  rawRequest?: boolean;
292
289
  rawResponse?: boolean;
293
- cache?: number | null;
290
+ cache?: CacheOptions | number | null;
294
291
  responseContentType?: string;
295
292
  }
296
293
 
@@ -325,8 +322,6 @@ export function api<TTypes extends VectorTypes = DefaultVectorTypes>(
325
322
  await withContent(request);
326
323
  }
327
324
 
328
- withCookies(request);
329
-
330
325
  // Cache handling is now done in the router
331
326
  const result = await fn(request as any as VectorRequest<TTypes>);
332
327
 
@@ -51,6 +51,9 @@ export interface VectorRequest<TTypes extends VectorTypes = DefaultVectorTypes>
51
51
  metadata?: GetMetadataType<TTypes>;
52
52
  content?: any;
53
53
  params?: Record<string, string>;
54
+ query: { [key: string]: string | string[] | undefined };
55
+ headers: Headers;
56
+ cookies?: Record<string, string>;
54
57
  startTime?: number;
55
58
  [key: string]: any;
56
59
  }