MCPcopy Index your code
hub / github.com/hydro-dev/Hydro / all

Method all

framework/framework/api.ts:192–219  ·  view source on GitHub ↗
({ }, op: string)

Source from the content-addressed store, hash-verified

190export class ApiHandler extends Handler {
191 @param('op', Types.String)
192 async all({ }, op: string) {
193 if (!['get', 'post'].includes(this.request.method.toLowerCase())) {
194 throw new MethodNotAllowedError(this.request.method);
195 }
196 if (!APIS[op]) throw new BadRequestError(`Invalid API operation: ${op}`);
197 if (APIS[op].type === 'Subscription') {
198 throw new BadRequestError('Subscription operation cannot be called in HTTP handler');
199 }
200 if (APIS[op].type === 'Mutation' && this.request.method.toLowerCase() === 'get') {
201 throw new BadRequestError('Mutation operation cannot be called with GET method');
202 }
203 handleArguments(this.args);
204 // @ts-ignore
205 await this.ctx.parallel('handler/api/before', this);
206 // @ts-ignore
207 await this.ctx.parallel(`handler/api/before/${op}`, this);
208 const result = await this.ctx.api.execute(
209 this, op, { domainId: this.args.domainId, ...this.args, ...(this.args.args || {}) },
210 (m, args) => (this.ctx.parallel as any)(m, args), this.args.projection,
211 );
212 if (BinaryResponse.check(result)) {
213 this.binary(result.data, result.filename);
214 } else if (RedirectResponse.check(result)) {
215 this.response.redirect = result.url;
216 } else {
217 this.response.body = result;
218 }
219 }
220}
221
222export class ApiConnectionHandler extends ConnectionHandler {

Callers 3

base.tsFile · 0.45
getFunction · 0.45
updateFunction · 0.45

Calls 4

handleArgumentsFunction · 0.85
executeMethod · 0.80
binaryMethod · 0.80
checkMethod · 0.45

Tested by

no test coverage detected