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 deleteProject(req: auth.RequestWithProject, res: Express.Response) {
const classid = req.params.classid;
const userid = req.params.studentid;
const projectid = req.params.projectid;
try {
const project: Objects.Project = req.project;
// if this is an images or sounds project, schedule a job to
// clean up any usage of the S3 Object Store by training data
if (project.type === 'images' || project.type === 'sounds') {
await store.storeDeleteProjectObjectsJob(classid, userid, projectid);
}
await store.deleteEntireProject(userid, classid, project);
return res.sendStatus(httpstatus.NO_CONTENT);
}
catch (err) {
log.error({ err, func : 'deleteProject' }, 'Server error');
errors.unknownError(res, err);
}
}
testlib.client.get('logout', function(err, res) {
testlib.session.end();
exports.client = testlib.client;
if (res.statusCode === httpStatus.NO_CONTENT) next();
});
};
.end((err, res) => {
expect(res.statusCode).to.eql(HttpStatus.NO_CONTENT);
done(err);
});
});
.then(result => defaultResponse(result, HttpStatus.NO_CONTENT))
.catch(error => errorResponse(error.message, HttpStatus.UNPROCESSABLE_ENTITY));
.end((err, res) => {
expect(res.statusCode).to.eql(HttpStatus.NO_CONTENT);
done(err);
});
});
client.get('logout', function(err, res) {
if (res.statusCode === httpStatus.NO_CONTENT) {
exports.session.end();
next();
}
});
};
}
const requestHeaders = requestHeadersRaw.split(',')
for (let i = 0; i < requestHeaders.length; i++) {
if (this.headersLower.indexOf(requestHeaders[i].trim().toLowerCase()) === -1) {
Server.terminateResponse(
response,
HTTPStatus.FORBIDDEN,
`Header ${requestHeaders[i]} is forbidden. Supported headers: ${this.headersStr}`
)
return
}
}
response.setHeader('Access-Control-Allow-Methods', this.methodsStr)
response.setHeader('Access-Control-Allow-Headers', this.headersStr)
Server.terminateResponse(response, HTTPStatus.NO_CONTENT)
}
async function deleteCredentials(req: Express.Request, res: Express.Response) {
const tenant = req.params.classid;
const credsid = req.params.credentialsid;
try {
const credentials = await store.getBluemixCredentialsById(credsid);
if (credentials.classid !== tenant) {
return errors.notFound(res);
}
await credentialsmgr.deleteBluemixCredentials(credentials);
return res.sendStatus(httpstatus.NO_CONTENT);
}
catch (err){
if (err.message === 'Unexpected response when retrieving the service credentials') {
return errors.notFound(res);
}
log.error({ err }, 'Failed to delete credentials');
errors.unknownError(res, err);
}
}
.then(() => {
return res.status(httpstatus.NO_CONTENT).send();
})
.catch((err) => {
.then(() => res.status(httpStatus.NO_CONTENT).end())
.catch(e => next(e));