Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function getTrainingData(req: Express.Request, res: Express.Response) {
const apikey = req.params.scratchkey;
try {
const scratchKey = await store.getScratchKey(apikey);
if (scratchKey.type !== 'sounds') {
return res.status(httpstatus.METHOD_NOT_ALLOWED)
.json({
error : 'Method not allowed',
});
}
const trainingInfo = await store.getSoundTraining(scratchKey.projectid, {
start : 0,
limit : 100,
});
const trainingData = await Promise.all(trainingInfo.map(getSoundTrainingItem));
res.set(headers.CACHE_2MINUTES);
return res.json(trainingData);
}
}
switch (request.method) {
case 'POST':
this.handlePost(request, response)
break
case 'GET':
this.handleGet(request, response)
break
case 'OPTIONS':
this.handleOptions(request, response)
break
default:
Server.terminateResponse(
response,
HTTPStatus.METHOD_NOT_ALLOWED,
`Unsupported method. Supported methods: ${this.methodsStr}`
)
}
}
}
else {
response.setHeader('Access-Control-Allow-Origin', '*');
}
switch (request.method) {
case 'POST':
this._handlePost(request, response);
break;
case 'GET':
this._handleGet(request, response);
break;
case 'OPTIONS':
this._handleOptions(request, response);
break;
default:
Server._terminateResponse(response, HTTPStatus.METHOD_NOT_ALLOWED, `Unsupported method. Supported methods: ${this.methodsStr}`);
}
}
_verifyOrigin(request, response) {
}
switch (request.method) {
case 'POST':
this.handlePost(request, response)
break
case 'GET':
this.handleGet(request, response)
break
case 'OPTIONS':
this.handleOptions(request, response)
break
default:
this.terminateResponse(
response,
HTTPStatus.METHOD_NOT_ALLOWED,
`Unsupported method. Supported methods: ${this.methodsStr}`
)
}
}
exports.create = function (req, res) {
res.problem(HttpStatus.METHOD_NOT_ALLOWED,
"You're not allowed to create users on this system",
"Users are created via 3rd party (Facebook) authentication");
};