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

Method post

packages/hydrooj/src/handler/manage.ts:102–133  ·  view source on GitHub ↗
(domainId: string, id: string, raw = '{}')

Source from the content-addressed store, hash-verified

100 @param('id', Types.Name)
101 @param('args', Types.Content, true)
102 async post(domainId: string, id: string, raw = '{}') {
103 if (!global.Hydro.script[id]) throw new ValidationError('id');
104 let args = JSON.parse(raw);
105 if (typeof global.Hydro.script[id].validate === 'function') {
106 args = global.Hydro.script[id].validate(args);
107 }
108 const rid = await record.add(domainId, -1, this.user._id, '-', id, false, { input: [raw], type: 'pretest' });
109 const c = new JudgeResultCallbackContext(this.ctx, { type: 'judge', domainId, rid });
110 c.next({ message: `Running script: ${id} `, status: STATUS.STATUS_JUDGING });
111 const start = Date.now();
112 // Maybe async?
113 global.Hydro.script[id].run(args, (data) => c.next(data))
114 .then((ret: any) => c.end({
115 status: STATUS.STATUS_ACCEPTED,
116 message: inspect(ret, false, 10, true),
117 judger: 1,
118 time: Date.now() - start,
119 memory: 0,
120 }))
121 .catch((err: Error) => {
122 logger.error(err);
123 c.end({
124 status: STATUS.STATUS_SYSTEM_ERROR,
125 message: `${err.message} \n${(err as any).params || []} \n${err.stack} `,
126 judger: 1,
127 time: Date.now() - start,
128 memory: 0,
129 });
130 });
131 this.response.body = { rid };
132 this.response.redirect = this.url('record_detail', { rid });
133 }
134}
135
136class SystemSettingHandler extends SystemHandler {

Callers

nothing calls this directly

Calls 7

nextMethod · 0.95
endMethod · 0.95
thenMethod · 0.80
urlMethod · 0.80
runMethod · 0.65
addMethod · 0.45
errorMethod · 0.45

Tested by

no test coverage detected