@veloxts/router 0.6.82 → 0.6.84

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/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # @veloxts/router
2
2
 
3
+ ## 0.6.84
4
+
5
+ ### Patch Changes
6
+
7
+ - - auth: add simplified guard() function with overloads + fluent builder
8
+ - Updated dependencies
9
+ - @veloxts/core@0.6.84
10
+ - @veloxts/validation@0.6.84
11
+
12
+ ## 0.6.83
13
+
14
+ ### Patch Changes
15
+
16
+ - docs(templates): add /veloxts skill to CLAUDE.md files and links to online documentation
17
+ - Updated dependencies
18
+ - @veloxts/core@0.6.83
19
+ - @veloxts/validation@0.6.83
20
+
3
21
  ## 0.6.82
4
22
 
5
23
  ### Patch Changes
package/GUIDE.md CHANGED
@@ -13,7 +13,7 @@ export const userProcedures = procedures('users', {
13
13
  .input(z.object({ id: z.string().uuid() }))
14
14
  .output(UserSchema)
15
15
  .query(async ({ input, ctx }) => {
16
- return ctx.db.user.findUnique({ where: { id: input.id } });
16
+ return ctx.db.user.findUniqueOrThrow({ where: { id: input.id } });
17
17
  }),
18
18
 
19
19
  createUser: procedure()
@@ -67,7 +67,7 @@ const userProcedures = procedures('users', {
67
67
  .input(z.object({ email: z.string().email() }))
68
68
  .rest({ method: 'GET', path: '/users/by-email/:email' })
69
69
  .query(async ({ input, ctx }) => {
70
- return ctx.db.user.findUnique({ where: { email: input.email } });
70
+ return ctx.db.user.findUniqueOrThrow({ where: { email: input.email } });
71
71
  }),
72
72
 
73
73
  // Custom action endpoint
@@ -187,6 +187,18 @@ function createBuilder(state) {
187
187
  guards: [...state.guards, guardDef],
188
188
  });
189
189
  },
190
+ /**
191
+ * Adds multiple authorization guards at once
192
+ *
193
+ * Convenience method equivalent to chaining multiple `.guard()` calls.
194
+ * Guards execute left-to-right. All must pass for the procedure to execute.
195
+ */
196
+ guards(...guardDefs) {
197
+ return createBuilder({
198
+ ...state,
199
+ guards: [...state.guards, ...guardDefs],
200
+ });
201
+ },
190
202
  /**
191
203
  * Sets REST route override
192
204
  */
@@ -205,6 +205,33 @@ export interface ProcedureBuilder<TInput = unknown, TOutput = unknown, TContext
205
205
  guardNarrow<TNarrowedContext>(guard: GuardLike<Partial<TContext>> & {
206
206
  readonly _narrows: TNarrowedContext;
207
207
  }): ProcedureBuilder<TInput, TOutput, TContext & TNarrowedContext>;
208
+ /**
209
+ * Adds multiple authorization guards at once
210
+ *
211
+ * This is a convenience method equivalent to chaining multiple `.guard()` calls.
212
+ * Guards execute left-to-right. All must pass for the procedure to execute.
213
+ *
214
+ * @param guards - Guard definitions to apply (spread)
215
+ * @returns Same builder (no type changes)
216
+ *
217
+ * @example
218
+ * ```typescript
219
+ * import { authenticated, hasRole, emailVerified } from '@veloxts/auth';
220
+ *
221
+ * // Multiple guards in one call
222
+ * procedure()
223
+ * .guards(authenticated, hasRole('admin'), emailVerified)
224
+ * .mutation(async ({ input, ctx }) => { ... });
225
+ *
226
+ * // Equivalent to:
227
+ * procedure()
228
+ * .guard(authenticated)
229
+ * .guard(hasRole('admin'))
230
+ * .guard(emailVerified)
231
+ * .mutation(async ({ input, ctx }) => { ... });
232
+ * ```
233
+ */
234
+ guards<TGuards extends GuardLike<Partial<TContext>>[]>(...guards: TGuards): ProcedureBuilder<TInput, TOutput, TContext>;
208
235
  /**
209
236
  * Configures REST route override
210
237
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@veloxts/router",
3
- "version": "0.6.82",
3
+ "version": "0.6.84",
4
4
  "description": "Procedure definitions with tRPC and REST routing for VeloxTS framework",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -40,8 +40,8 @@
40
40
  "@trpc/server": "11.8.0",
41
41
  "fastify": "5.6.2",
42
42
  "zod-to-json-schema": "3.24.5",
43
- "@veloxts/validation": "0.6.82",
44
- "@veloxts/core": "0.6.82"
43
+ "@veloxts/core": "0.6.84",
44
+ "@veloxts/validation": "0.6.84"
45
45
  },
46
46
  "devDependencies": {
47
47
  "@vitest/coverage-v8": "4.0.16",