@mateosuarezdev/brpc 1.0.50 → 1.0.52

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.
@@ -1,3 +1,4 @@
1
1
  export * from "./pathblocker";
2
2
  export * from "./ratelimiter";
3
3
  export * from "./profanity";
4
+ export * from "./createMiddleware";
@@ -3,8 +3,8 @@ import type { BaseContext, Handler, InferInput, Procedure, StreamableResponse }
3
3
  import type { BunFile } from "bun";
4
4
  declare class ProcedureBuilder<C extends BaseContext> {
5
5
  private middlewares;
6
- constructor(middlewares?: ((ctx: C) => Promise<void>)[]);
7
- use(middleware: (ctx: C) => Promise<void>): ProcedureBuilder<C>;
6
+ constructor(middlewares?: ((ctx: any) => Promise<Record<string, any> | void>)[]);
7
+ use<M extends (ctx: C) => Promise<Record<string, any> | void>>(middleware: M): ProcedureBuilder<Awaited<ReturnType<M>> extends Record<string, any> ? C & Awaited<ReturnType<M>> : C>;
8
8
  input<I extends z.ZodType>(schema: I): InputProcedureBuilder<C, I>;
9
9
  query<O>(handler: Handler<C, {}, O>): Procedure<C, z.ZodObject<{}>, O, "query">;
10
10
  mutation<O>(handler: Handler<C, {}, O>): Procedure<C, z.ZodObject<{}>, O, "mutation">;
@@ -18,7 +18,7 @@ declare class InputProcedureBuilder<C extends BaseContext, I extends z.ZodType>
18
18
  private middlewares;
19
19
  private inputSchema;
20
20
  private timeoutMs?;
21
- constructor(middlewares: ((ctx: C) => Promise<void>)[], inputSchema: I, timeoutMs?: number | undefined);
21
+ constructor(middlewares: ((ctx: any) => Promise<Record<string, any> | void>)[], inputSchema: I, timeoutMs?: number | undefined);
22
22
  /**
23
23
  * Set a custom timeout for this procedure (in milliseconds).
24
24
  * Overrides the default router timeout.
@@ -32,5 +32,6 @@ declare class InputProcedureBuilder<C extends BaseContext, I extends z.ZodType>
32
32
  fileStream(handler: Handler<C, InferInput<I>, StreamableResponse | Blob | string>): Procedure<C, I, StreamableResponse | Blob | string, "fileStream">;
33
33
  html(handler: Handler<C, {}, string>): Procedure<C, z.ZodObject<{}>, string, "html">;
34
34
  }
35
+ export declare function createProcedure<C extends BaseContext>(_context: (req: Request) => Promise<C>): ProcedureBuilder<C>;
35
36
  export declare function createProcedure<C extends BaseContext>(): ProcedureBuilder<C>;
36
37
  export {};
@@ -17,6 +17,9 @@ interface RouteStats {
17
17
  maxDepth: number;
18
18
  procedureTypes: Record<ProcedureType, number>;
19
19
  }
20
+ /**
21
+ * Optimized route matcher for the BRPC Framework
22
+ */
20
23
  export declare class RouteMatcher {
21
24
  private routeTree;
22
25
  private routeCache;
package/dist/types.d.ts CHANGED
@@ -37,7 +37,7 @@ export type Procedure<C extends BaseContext, I extends z.ZodType, O, P> = {
37
37
  _ctx: C;
38
38
  _type: P;
39
39
  _timeout?: number;
40
- middlewares: ((ctx: C) => Promise<void>)[];
40
+ middlewares: ((ctx: any) => Promise<Record<string, any> | void>)[];
41
41
  handler?: Handler<C, InferInput<I>, O>;
42
42
  };
43
43
  export type Routes = {
@@ -46,7 +46,7 @@ export type Routes = {
46
46
  export type RouterConfig<C extends BaseContext> = {
47
47
  context: (req: Request) => Promise<C>;
48
48
  routes: Routes;
49
- globalMiddlewares?: ((ctx: C) => Promise<void>)[];
49
+ globalMiddlewares?: ((ctx: C) => Promise<Record<string, any> | void>)[];
50
50
  /**
51
51
  * Simple hooks to debug websockets, you don't need to pass anything
52
52
  * for brpc subscription procedures to work
package/package.json CHANGED
@@ -1,103 +1,103 @@
1
- {
2
- "name": "@mateosuarezdev/brpc",
3
- "version": "1.0.50",
4
- "description": "A Type-Safe, Flexible Web application framework for Bun",
5
- "type": "module",
6
- "main": "./dist/index.cjs",
7
- "module": "./dist/index.js",
8
- "types": "./dist/index.d.ts",
9
- "exports": {
10
- ".": {
11
- "types": "./dist/index.d.ts",
12
- "import": "./dist/index.js",
13
- "require": "./dist/index.cjs"
14
- },
15
- "./storage": {
16
- "types": "./dist/storage/index.d.ts",
17
- "import": "./dist/storage/index.js",
18
- "require": "./dist/storage/index.cjs"
19
- },
20
- "./client": {
21
- "types": "./dist/client/index.d.ts",
22
- "import": "./dist/client/index.js",
23
- "require": "./dist/client/index.cjs"
24
- },
25
- "./client/react": {
26
- "types": "./dist/client/react/index.d.ts",
27
- "import": "./dist/client/react/index.js",
28
- "require": "./dist/client/react/index.cjs"
29
- }
30
- },
31
- "files": [
32
- "dist/**/*.js",
33
- "dist/**/*.cjs",
34
- "dist/**/*.d.ts",
35
- "dist/**/*.map"
36
- ],
37
- "sideEffects": false,
38
- "scripts": {
39
- "build": "yarn clean && bun run build.ts && tsc --emitDeclarationOnly",
40
- "typecheck": "tsc --noEmit",
41
- "clean": "rimraf dist",
42
- "prepublish": "yarn typecheck && yarn build",
43
- "rel": "yarn npm publish --access public",
44
- "rel:patch": "yarn version patch && yarn npm publish --access public",
45
- "rel:minor": "yarn version minor && yarn npm publish --access public",
46
- "rel:major": "yarn version major && yarn npm publish --access public"
47
- },
48
- "packageManager": "yarn@4.10.3",
49
- "keywords": [
50
- "bun",
51
- "router",
52
- "brpc",
53
- "rpc",
54
- "trpc",
55
- "api",
56
- "http"
57
- ],
58
- "author": "Mateo Suarez <msdevuy@gmail.com>",
59
- "repository": {
60
- "type": "git",
61
- "url": "git+https://github.com/mateosuarezdev/brpc-space.git",
62
- "directory": "packages/brpc"
63
- },
64
- "bugs": {
65
- "url": "https://github.com/mateosuarezdev/brpc-space/issues"
66
- },
67
- "homepage": "https://github.com/mateosuarezdev/brpc-space/tree/main/packages/brpc#readme",
68
- "license": "MIT",
69
- "engines": {
70
- "bun": ">=1.2.0"
71
- },
72
- "peerDependencies": {
73
- "zod": "^3.23.8"
74
- },
75
- "peerDependenciesMeta": {
76
- "react": {
77
- "optional": true
78
- },
79
- "react-dom": {
80
- "optional": true
81
- },
82
- "sharp": {
83
- "optional": true
84
- },
85
- "zod": {
86
- "optional": false
87
- }
88
- },
89
- "devDependencies": {
90
- "@types/bun": "^1.2.23",
91
- "@types/react": "^19.2.2",
92
- "@types/react-dom": "^19.2.2",
93
- "react": "^19.2.0",
94
- "react-dom": "^19.2.0",
95
- "rimraf": "^6.0.1",
96
- "sharp": "^0.34.4",
97
- "typescript": "^5.9.3",
98
- "zod": "^3.23.8"
99
- },
100
- "dependencies": {
101
- "@mateosuarezdev/headers-builder": "^1.0.5"
102
- }
103
- }
1
+ {
2
+ "name": "@mateosuarezdev/brpc",
3
+ "version": "1.0.52",
4
+ "description": "A Type-Safe, Flexible Web application framework for Bun",
5
+ "type": "module",
6
+ "main": "./dist/index.cjs",
7
+ "module": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.js",
13
+ "require": "./dist/index.cjs"
14
+ },
15
+ "./storage": {
16
+ "types": "./dist/storage/index.d.ts",
17
+ "import": "./dist/storage/index.js",
18
+ "require": "./dist/storage/index.cjs"
19
+ },
20
+ "./client": {
21
+ "types": "./dist/client/index.d.ts",
22
+ "import": "./dist/client/index.js",
23
+ "require": "./dist/client/index.cjs"
24
+ },
25
+ "./client/react": {
26
+ "types": "./dist/client/react/index.d.ts",
27
+ "import": "./dist/client/react/index.js",
28
+ "require": "./dist/client/react/index.cjs"
29
+ }
30
+ },
31
+ "files": [
32
+ "dist/**/*.js",
33
+ "dist/**/*.cjs",
34
+ "dist/**/*.d.ts",
35
+ "dist/**/*.map"
36
+ ],
37
+ "sideEffects": false,
38
+ "scripts": {
39
+ "build": "yarn clean && bun run build.ts && tsc --emitDeclarationOnly",
40
+ "typecheck": "tsc --noEmit",
41
+ "clean": "rimraf dist",
42
+ "prepublish": "yarn typecheck && yarn build",
43
+ "rel": "yarn npm publish --access public",
44
+ "rel:patch": "yarn version patch && yarn npm publish --access public",
45
+ "rel:minor": "yarn version minor && yarn npm publish --access public",
46
+ "rel:major": "yarn version major && yarn npm publish --access public"
47
+ },
48
+ "keywords": [
49
+ "bun",
50
+ "router",
51
+ "brpc",
52
+ "rpc",
53
+ "trpc",
54
+ "api",
55
+ "http"
56
+ ],
57
+ "author": "Mateo Suarez <msdevuy@gmail.com>",
58
+ "repository": {
59
+ "type": "git",
60
+ "url": "git+https://github.com/mateosuarezdev/brpc-space.git",
61
+ "directory": "packages/brpc"
62
+ },
63
+ "bugs": {
64
+ "url": "https://github.com/mateosuarezdev/brpc-space/issues"
65
+ },
66
+ "homepage": "https://github.com/mateosuarezdev/brpc-space/tree/main/packages/brpc#readme",
67
+ "license": "MIT",
68
+ "engines": {
69
+ "bun": ">=1.2.0"
70
+ },
71
+ "peerDependencies": {
72
+ "react": "^19.0.0",
73
+ "react-dom": "^19.0.0",
74
+ "sharp": "^0.34.4",
75
+ "zod": "^3.23.8"
76
+ },
77
+ "peerDependenciesMeta": {
78
+ "react": {
79
+ "optional": true
80
+ },
81
+ "react-dom": {
82
+ "optional": true
83
+ },
84
+ "sharp": {
85
+ "optional": true
86
+ },
87
+ "zod": {
88
+ "optional": false
89
+ }
90
+ },
91
+ "devDependencies": {
92
+ "@types/bun": "^1.2.23",
93
+ "@types/react": "^19.2.2",
94
+ "@types/react-dom": "^19.2.2",
95
+ "rimraf": "^6.0.1",
96
+ "sharp": "^0.34.4",
97
+ "typescript": "^5.9.3",
98
+ "zod": "^3.23.8"
99
+ },
100
+ "dependencies": {
101
+ "@mateosuarezdev/headers-builder": "^1.0.5"
102
+ }
103
+ }