diesel-core 1.4.2 → 1.4.3

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/ctx.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  import { Server } from "bun";
2
2
  import type { ContextType } from "./types";
3
3
  export default function createCtx(req: Request, server: Server, pathname: string, routePattern: string | undefined): ContextType;
4
+ export declare function extractDynamicParams(originalPath: string, incomingPath: string): Record<string, string> | null;
@@ -1,10 +1,14 @@
1
1
  import { BunRequest, Server } from "bun";
2
- import type { ContextType, DieselT } from "./types";
2
+ import type { ContextType, DieselT, HookType } from "./types";
3
3
  /** Fast parse that extracts pathname and raw query without constructing URL */
4
4
  export declare function parseRequestUrl(rawUrl: string): string;
5
5
  export default function handleRequest(req: BunRequest, server: Server, diesel: DieselT): Promise<Response>;
6
+ export declare function runHooks<T extends any[]>(label: HookType, hooksArray: any, args: T): Promise<any>;
7
+ export declare function runMiddlewares(diesel: DieselT, pathname: string, ctx: ContextType, server: Server): Promise<Response | null>;
6
8
  export declare function executeBunMiddlewares(middlewares: Function[], req: BunRequest, server: Server): Promise<any>;
9
+ export declare function runFilter(diesel: DieselT, path: string, ctx: ContextType, server: Server): Promise<any>;
7
10
  export declare function handleFilterRequest(diesel: DieselT, path: string, ctx: ContextType, server: Server): Promise<Response | undefined>;
8
11
  export declare function handleBunFilterRequest(diesel: DieselT, path: string, req: BunRequest, server: Server): Promise<Response | undefined>;
12
+ export declare function handleRouteNotFound(diesel: DieselT, ctx: ContextType, pathname: string): Promise<Response>;
9
13
  export declare function generateErrorResponse(status: number, error: string): Response;
10
14
  export declare function handleStaticFiles(diesel: DieselT, pathname: string, ctx: ContextType): Promise<Response | null>;
package/dist/main.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import Trie from "./trie.js";
2
- import { ContextType, corsT, FilterMethods, HookFunction, HookType, listenArgsT, middlewareFunc, onError, onRequest, RouteNotFoundHandler, type handlerFunction, type Hooks, type HttpMethod } from "./types.js";
2
+ import { CompileConfig, ContextType, corsT, FilterMethods, HookFunction, HookType, listenArgsT, middlewareFunc, onError, onRequest, RouteNotFoundHandler, type handlerFunction, type Hooks, type HttpMethod } from "./types.js";
3
3
  import { BunRequest, Server } from "bun";
4
4
  import { AdvancedLoggerOptions, LoggerOptions } from "./middlewares/logger/logger.js";
5
5
  import { ServerOptions } from "http";
@@ -11,18 +11,12 @@ export default class Diesel {
11
11
  globalMiddlewares: middlewareFunc[];
12
12
  middlewares: Map<string, middlewareFunc[]>;
13
13
  trie: Trie;
14
- hasOnReqHook: boolean;
15
- hasMiddleware: boolean;
16
- hasPreHandlerHook: boolean;
17
- hasPostHandlerHook: boolean;
18
- hasOnSendHook: boolean;
19
- hasOnError: boolean;
20
14
  hooks: Hooks;
21
15
  corsConfig: corsT;
22
16
  FilterRoutes: string[] | null | undefined;
23
17
  filters: Set<string>;
24
- filterFunction: middlewareFunc[];
25
- hasFilterEnabled: boolean;
18
+ filterFunction: Function[];
19
+ private hasFilterEnabled;
26
20
  private serverInstance;
27
21
  staticPath: any;
28
22
  staticFiles: any;
@@ -32,6 +26,7 @@ export default class Diesel {
32
26
  idleTimeOut: number;
33
27
  routeNotFoundFunc: (c: ContextType) => void | Promise<void> | Promise<Response> | Response;
34
28
  private prefixApiUrl;
29
+ compileConfig: CompileConfig | null;
35
30
  constructor({ jwtSecret, baseApiUrl, enableFileRouting, idleTimeOut, prefixApiUrl, }?: {
36
31
  jwtSecret?: string;
37
32
  baseApiUrl?: string;
@@ -57,9 +52,9 @@ export default class Diesel {
57
52
  private loadRoutes;
58
53
  useLogger(options: LoggerOptions): this;
59
54
  useAdvancedLogger(options: AdvancedLoggerOptions): this;
60
- BunRoute(method: string, path: string, ...handlers: any[]): void;
55
+ BunRoute(method: string, path: string, ...handlers: any[]): this;
61
56
  listen(port: any, ...args: listenArgsT[]): Server | void;
62
- fetch(): (req: BunRequest, server: Server) => Promise<Response>;
57
+ fetch(): (req: BunRequest, server: Server) => Promise<any>;
63
58
  close(callback?: () => void): void;
64
59
  /**
65
60
  * Registers a router instance for subrouting.
@@ -10,11 +10,4 @@ declare class RedisStore implements RateLimitStore {
10
10
  set(key: string, value: string, ttlMs: number): Promise<void>;
11
11
  reset(key: string): Promise<void>;
12
12
  }
13
- declare class DiceDbStore implements RateLimitStore {
14
- private dicedb;
15
- constructor(dicedb: any);
16
- get(key: string): Promise<number | null>;
17
- set(key: string, value: string, ttlMs: number): Promise<void>;
18
- reset(key: string): Promise<void>;
19
- }
20
- export { RedisStore, DiceDbStore };
13
+ export { RedisStore, };
@@ -0,0 +1,3 @@
1
+ import { CompileConfig, DieselT } from "./types";
2
+ export declare const buildRequestPipeline: (config: CompileConfig, diesel: DieselT) => any;
3
+ export declare const BunRequestPipline: (config: CompileConfig, diesel: DieselT, method: string, path: string, ...handlers: Function[]) => any;
package/dist/trie.d.ts CHANGED
@@ -16,9 +16,7 @@ export default class Trie {
16
16
  search(path: string, method: HttpMethod): {
17
17
  path: string;
18
18
  handler: handlerFunction;
19
- isDynamic: boolean;
20
19
  pattern: string;
21
- method: string;
22
20
  } | null;
23
21
  }
24
22
  export {};
package/dist/types.d.ts CHANGED
@@ -94,6 +94,7 @@ export interface DieselT {
94
94
  routeNotFoundFunc: RouteNotFoundHandler;
95
95
  routerInstance: DieselT;
96
96
  tempRoutes: Map<string, TempRouteEntry>;
97
+ routes: Record<string, Function>;
97
98
  }
98
99
  export type corsT = {
99
100
  origin?: string | string[] | null;
@@ -126,3 +127,12 @@ declare global {
126
127
  [key: string]: any;
127
128
  }
128
129
  }
130
+ export interface CompileConfig {
131
+ hasMiddleware: boolean;
132
+ hasOnReqHook: boolean;
133
+ hasPreHandlerHook: boolean;
134
+ hasOnError: boolean;
135
+ hasPostHandlerHook: boolean;
136
+ hasOnSendHook: boolean;
137
+ hasFilterEnabled: boolean;
138
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "diesel-core",
3
- "version": "1.4.2",
3
+ "version": "1.4.3",
4
4
  "description": "Web framework built on Web Standards",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",