Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async handleExecuteRequest(request: HubRequest): Promise {
throw new HubError(`${request.getAction()} handler not implemented.`, HttpStatus.NOT_IMPLEMENTED);
}
export function notImplemented(res: Express.Response) {
return res.status(httpstatus.NOT_IMPLEMENTED).json({ error : 'Not implemented' });
}
export function unknownError(res: Express.Response, err: NodeJS.ErrnoException | any) {
async function trainNewClassifier(req: Express.Request, res: Express.Response) {
const apikey = req.params.scratchkey;
try {
const scratchKey = await store.getScratchKey(apikey);
const classifierStatus = await models.trainModel(scratchKey);
return res.set(headers.NO_CACHE).jsonp(classifierStatus);
}
catch (err) {
if (err.message === 'Only text or numbers models can be trained using a Scratch key') {
return res.status(httpstatus.NOT_IMPLEMENTED).json({ error : err.message });
}
log.error({ err, agent : req.header('X-User-Agent') }, 'Train error');
errors.unknownError(res, err);
}
}