Feat/services api#27
Open
codewizdave wants to merge 13 commits into
Open
Conversation
The manual installation guide was removed as it's no longer needed or has been superseded by other documentation. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Removes the old router-based API (createAPI, createPublicAPI, d.router) and replaces it with a simpler services-based approach using query(), mutation(), bind(), and defineServices(). This is a complete rewrite of the server package's public API: - query() and mutation() create typed service handlers - bind() attaches context to a service - defineServices() creates a local API proxy with bound services - Services are composable and simpler than the router model Old files removed: api factory, router builder, all procedures, middleware, hooks, events system, and associated tests. New files added: services module (query, mutation, bind, api), new types, and services test. BREAKING CHANGE: The router-based API is removed. Migrate to services-based approach using defineServices(). Co-Authored-By: martyy-code <nesalia.inc@gmail.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
When a service has no args (TArgs = {}), allow calling it without
passing {}. Previously required api.service({}), now works with
api.service().
The fix is in api.ts where the proxy handler checks if args is
undefined or empty object and conditionally calls bound.call()
with or without args.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Service types (ServiceConfig, ServiceInternal, BoundService, etc.) are now in src/services/types.ts. Root types.ts re-exports them for backward compatibility. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Use inline type specifiers in imports
- Remove unused TCtx type parameter from LocalAPI
- Add targeted eslint-disable for {} in conditional types
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This avoids the @typescript-eslint/no-empty-object-type lint warning while maintaining the same semantics for detecting empty args. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1. Add validation using StandardSchemaV1's validate method 2. Unify query/mutation via createProcedure (DRY) 3. Memoize bound services in defineServices proxy 4. Store _args explicitly in ServiceInternal to avoid Parameters extraction 5. Remove redundant bind.ts (now in createProcedure) 6. Export ProcedureKind type Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1. Handle async validation (StandardSchemaV1 allows Promise) 2. Return validation issues instead of full error object 3. Extract issues array properly from validation result Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…tput directly Handler now returns Promise<TOutput> - user is free to use Result, Maybe, or direct values. Validation errors are thrown (not wrapped). Tests updated to: - Test validation failures (rejects.toThrow()) - Test handler errors propagation - Test async validation - Test edge cases Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Core changes: - Handler returns TOutput directly (no Result wrapper) - user is free - Validation errors throw ValidationError (not returned in Result) - Support async validation (await StandardSchemaV1 validate) - Support sync handlers (TOutput | Promise<TOutput>) - ValidationError class with issues array for better error handling - Use transformed value from schema if available Types: - BoundService now returns Promise<Awaited<TOutput>> - LocalAPI uses ReturnType properly for sync/async handlers - ValidationError exported for user consumption Tests (20 total): - Validation errors with ValidationError checks - Async validation with Valibot pipeAsync - Sync handler support - ValidationError.issues array verification - Handler error propagation Examples: - 01-basic-services: CRUD with query/mutation - 02-validation: Zod, Valibot, async validation - 03-no-args-services: services without arguments Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
| services: { getTime, getDateInfo, createSession }, | ||
| context: { | ||
| getTime: () => new Date(), | ||
| sessionId: 'sess_' + Math.random().toString(36).substring(2), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.