Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async home(ctx: Context) {
// Normally in an HTML template
const response = new HttpResponseOK();
setCsrfCookie(response, await getCsrfToken());
return response;
}
}
home() {
return new HttpResponseOK('Home page');
}
}
foo() {
return new HttpResponseOK();
}
foo() {
return new HttpResponseOK();
}
home() {
return new HttpResponseOK('You are on the home page!');
}
}
async patchById(ctx: Context) {
const testFooBar = await getRepository(TestFooBar).findOne(ctx.request.params.testFooBarId);
if (!testFooBar) {
return new HttpResponseNotFound();
}
Object.assign(testFooBar, ctx.request.body);
await getRepository(TestFooBar).save(testFooBar);
return new HttpResponseOK(testFooBar);
}
async putById(ctx: Context) {
const testFooBar = await getRepository(TestFooBar).findOne(ctx.request.params.testFooBarId);
if (!testFooBar) {
return new HttpResponseNotFound();
}
Object.assign(testFooBar, ctx.request.body);
await getRepository(TestFooBar).save(testFooBar);
return new HttpResponseOK(testFooBar);
}
getOpenApiDefinition(ctx: Context) {
if (isUrlOption(this.options)) {
return new HttpResponseNotFound();
}
if (!Array.isArray(this.options)) {
const document = createOpenApiDocument(this.options.controllerClass, this.controllers);
return new HttpResponseOK(document);
}
const name = ctx.request.query.name;
if (typeof name !== 'string') {
return new HttpResponseBadRequest('Missing URL parameter "name".');
}
const option = this.options.find(option => option.name === name);
if (!option || isUrlOption(option)) {
return new HttpResponseNotFound();
}
return new HttpResponseOK(createOpenApiDocument(option.controllerClass, this.controllers));
}
async putById(ctx: Context) {
const product = await getRepository(Product).findOne(ctx.request.params.id);
if (!product) {
return new HttpResponseNotFound();
}
Object.assign(product, ctx.request.body);
await getRepository(Product).save(product);
return new HttpResponseOK(product);
}
token() {
return new HttpResponseOK(tokens);
}
}