You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// putEcho.handler.ts <-- allows Whook to detect it is an handler and to build schemas for it// ...import{typeEcho,typeHandler}from'./putEcho.d.ts';// Needs `schema2dts` updateexportconstechoSchema={name: 'Echo',example: {// ...},schema: {// ...}// `const` allows to keep schema usable as consts// `satisfies` allows to type check awaiting more TS module checks}asconstsatisfiesWhookAPISchemaDefinition<Echo>;exportconstMETHOD='put'asconstsatisfiesWhookAPIMethod;exportconstPATH='/echo'asconstsatisfiesWhookAPIPath;exportconstoperation={// ...}asconstsatisfiesWhookAPIOperation;exportconstinitPutEcho=async({ log }: {log: LogService},)=>Promise<Handler>{return({ body })=>{// ...return{status: 200,
body,};}};// Use service instead of handler that should be removed of knifecycleexportdefaultautoService(initPutEcho);
The satisfies part is aimed to be removed when TypeScript will support pattern based module exports definition (see nfroidure/knifecycle#138).
The same kind of improvements could be done for schemas defined outside of handlers by detecting their file name (srs/lib/api.schemas.ts).
The text was updated successfully, but these errors were encountered:
An handler like
whook/packages/whook-example/src/handlers/putEcho.ts
Lines 12 to 111 in 1cc3956
The satisfies part is aimed to be removed when TypeScript will support pattern based module exports definition (see nfroidure/knifecycle#138).
The same kind of improvements could be done for schemas defined outside of handlers by detecting their file name (
srs/lib/api.schemas.ts
).The text was updated successfully, but these errors were encountered: