barejs 0.1.45 → 0.1.48
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/LICENSE +20 -20
- package/README.md +184 -179
- package/dist/index.js +111 -192
- package/dist/types/core/bare.d.ts +2 -1
- package/dist/types/core/context.d.ts +2 -0
- package/dist/types/core/router.d.ts +1 -9
- package/dist/types/index.d.ts +0 -1
- package/dist/types/security/auth.d.ts +2 -2
- package/package.json +1 -1
- package/src/core/bare.ts +315 -286
- package/src/core/config.ts +31 -31
- package/src/core/context.ts +111 -81
- package/src/core/loader.ts +12 -12
- package/src/core/radix.ts +184 -176
- package/src/core/router.ts +60 -68
- package/src/index.ts +60 -60
- package/src/security/auth.ts +174 -157
- package/src/security/cors.ts +45 -26
- package/src/security/hash.ts +22 -19
- package/src/security/validators.ts +133 -132
- package/src/utils/static.ts +42 -25
- package/dist/types/utils/logger.d.ts +0 -2
- package/src/utils/logger.ts +0 -23
|
@@ -9,10 +9,11 @@ export interface NotFoundResponse {
|
|
|
9
9
|
export declare class BareJS extends BareRouter {
|
|
10
10
|
private tree;
|
|
11
11
|
private pool;
|
|
12
|
-
private poolIdx;
|
|
13
12
|
private hotFetch?;
|
|
14
13
|
private compiled;
|
|
15
14
|
private poolMask;
|
|
15
|
+
private _useLog;
|
|
16
|
+
useLog(enabled?: boolean): this;
|
|
16
17
|
constructor(poolSize?: number);
|
|
17
18
|
private notFoundHandler;
|
|
18
19
|
setNotFound(handler: () => NotFoundResponse): void;
|
|
@@ -11,6 +11,7 @@ export declare class Context {
|
|
|
11
11
|
_headers?: Record<string, string> | undefined;
|
|
12
12
|
store: Map<string, any>;
|
|
13
13
|
body: any;
|
|
14
|
+
query: Record<string, string>;
|
|
14
15
|
constructor();
|
|
15
16
|
jsonBody(): Promise<any>;
|
|
16
17
|
reset(req: Request): this;
|
|
@@ -19,4 +20,5 @@ export declare class Context {
|
|
|
19
20
|
set(key: string, value: any): this;
|
|
20
21
|
get(key: string): any;
|
|
21
22
|
setHeader(name: string, value: string): this;
|
|
23
|
+
send(message: string, extra?: Record<string, any>): Response;
|
|
22
24
|
}
|
|
@@ -3,11 +3,7 @@ type HandlersChain = (Middleware | Handler)[];
|
|
|
3
3
|
export declare class BareRouter {
|
|
4
4
|
prefix: string;
|
|
5
5
|
groupMiddleware: any[];
|
|
6
|
-
routes:
|
|
7
|
-
method: string;
|
|
8
|
-
path: string;
|
|
9
|
-
handlers: any[];
|
|
10
|
-
}[];
|
|
6
|
+
routes: any[];
|
|
11
7
|
constructor(prefix?: string, groupMiddleware?: any[]);
|
|
12
8
|
private _add;
|
|
13
9
|
get: (path: string, ...h: HandlersChain) => this;
|
|
@@ -16,10 +12,6 @@ export declare class BareRouter {
|
|
|
16
12
|
patch: (path: string, ...h: HandlersChain) => this;
|
|
17
13
|
delete: (path: string, ...h: HandlersChain) => this;
|
|
18
14
|
group: (path: string, ...args: any[]) => this;
|
|
19
|
-
/**
|
|
20
|
-
* 🔗 Use: Mounts a router or middleware
|
|
21
|
-
* Supports nested routers with automatic path prefixing
|
|
22
|
-
*/
|
|
23
15
|
use(mw: any): this;
|
|
24
16
|
}
|
|
25
17
|
export {};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -16,7 +16,6 @@ import { Type } from "@sinclair/typebox";
|
|
|
16
16
|
export { Type, Type as T, Type as TypeBox };
|
|
17
17
|
import { typebox, zod, native, validate, Z } from './security/validators';
|
|
18
18
|
export { typebox, typebox as t, zod, zod as z, Z, Z as Zod, native, native as n, validate, validate as v };
|
|
19
|
-
export { logger } from './utils/logger';
|
|
20
19
|
export { cors } from './security/cors';
|
|
21
20
|
export { staticFile } from './utils/static';
|
|
22
21
|
export { BareRouter } from './core/router';
|
|
@@ -5,9 +5,9 @@ import type { Next } from '../core/context';
|
|
|
5
5
|
export declare const createToken: (payload: object, secret: string) => Promise<string>;
|
|
6
6
|
/**
|
|
7
7
|
* 1. BARE TOKEN AUTH (Standard JWT Middleware)
|
|
8
|
-
* High-performance JWT
|
|
8
|
+
* High-performance, constant-time JWT middleware for BareJS
|
|
9
9
|
*/
|
|
10
|
-
export declare const bareAuth: (secret: string) => (ctx: any, next: any) =>
|
|
10
|
+
export declare const bareAuth: (secret: string) => (ctx: any, next: any) => any;
|
|
11
11
|
/**
|
|
12
12
|
* 2. BASIC AUTH
|
|
13
13
|
* Useful for internal tools and simple admin panels
|