fets 0.0.1 → 0.0.2
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/README.md +9 -5
- package/package.json +1 -1
- package/types.d.ts +2 -1
package/README.md
CHANGED
|
@@ -104,15 +104,19 @@ const router = createRouter().route({
|
|
|
104
104
|
id: { type: 'string' },
|
|
105
105
|
name: { type: 'string' }
|
|
106
106
|
}
|
|
107
|
-
}
|
|
108
|
-
|
|
107
|
+
},
|
|
108
|
+
404: {
|
|
109
|
+
type: 'object',
|
|
110
|
+
properties: {
|
|
111
|
+
message: { type: 'string' }
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
} as const // schemas should always be const
|
|
109
115
|
},
|
|
110
116
|
handler: ({ params }) => {
|
|
111
117
|
const user = users.find(user => user.id === params.id);
|
|
112
118
|
if (!user) {
|
|
113
|
-
return
|
|
114
|
-
status: 404
|
|
115
|
-
});
|
|
119
|
+
return Response.json({ message: 'User not found' }, { status: 404 });
|
|
116
120
|
}
|
|
117
121
|
return Response.json(user, { status: 200 });
|
|
118
122
|
}
|
package/package.json
CHANGED
package/types.d.ts
CHANGED
|
@@ -134,7 +134,7 @@ export type RouterInput<TRouter extends Router<any, {}>, TRouterSDK extends Rout
|
|
|
134
134
|
type ResponseByPathAndMethod<TRouterSDK extends RouterSDK, TPath extends keyof TRouterSDK, TMethod extends keyof TRouterSDK[TPath]> = TMethod extends Lowercase<HTTPMethod> ? ResolvedPromise<ReturnType<TRouterSDK[TPath][TMethod]>> : never;
|
|
135
135
|
export type RouterOutput<TRouter extends Router<any, {}>, TRouterSDK extends RouterSDK = TRouter['__client']> = {
|
|
136
136
|
[TPathKey in keyof TRouterSDK]: {
|
|
137
|
-
[TMethodKey in keyof TRouterSDK[TPathKey]]: TMethodKey extends HTTPMethod ? ResponseByPathAndMethod<TRouterSDK, TPathKey, TMethodKey> extends {
|
|
137
|
+
[TMethodKey in keyof TRouterSDK[TPathKey]]: TMethodKey extends Lowercase<HTTPMethod> ? ResponseByPathAndMethod<TRouterSDK, TPathKey, TMethodKey> extends {
|
|
138
138
|
status: infer TStatusCode;
|
|
139
139
|
json(): Promise<infer TJSON>;
|
|
140
140
|
} ? {
|
|
@@ -142,4 +142,5 @@ export type RouterOutput<TRouter extends Router<any, {}>, TRouterSDK extends Rou
|
|
|
142
142
|
} : never : never;
|
|
143
143
|
};
|
|
144
144
|
};
|
|
145
|
+
export type RouterClient<TRouter extends Router<any, any>> = TRouter['__client'];
|
|
145
146
|
export declare const Response: TypedResponseCtor;
|