Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
})
.catch(next);
}
@httpPost('/', authMiddlware.bearerStrategy)
public addTodo(req: IRequest, res: Response, next: NextFunction) {
const _todo = req.body;
_todo.userId = req.user.id;
return this._todoService.addTodo(_todo)
.then((todo) => {
return res.json({ todo });
})
.catch(next);
}
@httpDelete('/:id', authMiddlware.bearerStrategy)
public removeTodo(req: IRequest, res: Response, next: NextFunction) {
const id = req.params.id;
return this._todoService.removeTodo(id, req.user.id)
.then((todo) => {
return res.json({ todo });
})
.catch(next);
}
@httpPut('/:id', authMiddlware.bearerStrategy)
public changeComplete(req: IRequest, res: Response, next: NextFunction) {
const id = req.params.id;
return this._todoService.changeComplete(id, req.user.id, req.body.completed)
.then((todo) => {
return res.json({ todo });
})
@injectable()
export class ListController implements interfaces.Controller {
constructor( @inject("ListService") private listService: ListService) { }
@httpGet("/")
private async list(): Promise {
return this.listService.findAll();
}
@httpPost('/')
public async create( @response() res: Response, @requestBody() body: any): Promise {
await this.listService.create(body);
return {};
}
@httpDelete('/:id')
public async destroy( @response() res: Response, @requestParam('id') id: string): Promise {
await this.listService.delete(id);
return {};
}
@httpPut('/:id')
public async update( @response() res: Response, @requestParam('id') id: string, @requestBody() body: any): Promise {
await this.listService.update(id, body);
return {};
}
}
.setTitle(error.name)
.setStatus(HttpStatus.NOT_FOUND)
.setDetail(error.stack)
.setMessage(error.message)
.setSource(req.url)
.build();
this.loggerService.logAPITrace(req, res, HttpStatus.NOT_FOUND);
this.metricsService.logAPIMetrics(req, res, HttpStatus.NOT_FOUND);
reject(resp);
}
);
});
}
@httpDelete('/products/:name')
public async deleteCampaignByName(
@requestParam('name') name: string,
@request() req: Request,
@response() res: Response
) {
return new Promise((resolve, reject) => {
this.scraperService.deleteMicrositeByID(name).subscribe(
result => {
this.loggerService.info(result.timings);
this.loggerService.logAPITrace(req, res, HttpStatus.OK);
this.metricsService.logAPIMetrics(req, res, HttpStatus.OK);
resolve(result);
},
err => {
const error: HttpError = err as HttpError;
const resp = new ErrorResponseBuilder()
this.syncRunnerService.setupSyncList();
}
@httpGet("/")
private async list( @queryParam("username") username: string = ''): Promise {
return this.settingsService.findAll();
}
@httpPost('/')
public async create( @response() res: Response, @requestBody() body: any): Promise {
await this.settingsService.create(body);
this.syncRunnerService.setupSyncList();
return {};
}
@httpDelete('/:id')
public async destroy( @response() res: Response, @requestParam('id') id: string): Promise {
await this.settingsService.delete(id);
return {};
}
@httpPut('/:id')
public async update( @response() res: Response, @requestParam('id') id: string, @requestBody() body: any): Promise {
await this.settingsService.update(id, body);
this.syncRunnerService.setupSyncList();
return {};
}
}
const resp = new ErrorResponseBuilder()
.setTitle(error.name)
.setStatus(HttpStatus.NOT_FOUND)
.setDetail(error.stack)
.setMessage(error.message)
.setSource(req.url)
.build();
this.loggerService.logAPITrace(req, res, HttpStatus.NOT_FOUND);
this.metricsService.logAPIMetrics(req, res, HttpStatus.NOT_FOUND);
reject(resp);
}
);
});
}
@httpDelete('/publish/:name')
public async deleteCampaignPublishByName(
@requestParam('name') name: string,
@request() req: Request,
@response() res: Response
) {
return new Promise((resolve, reject) => {
this.scraperService.deleteMicrositePublishByID(name).subscribe(
result => {
this.loggerService.info(result.timings);
this.loggerService.logAPITrace(req, res, HttpStatus.OK);
this.metricsService.logAPIMetrics(req, res, HttpStatus.OK);
resolve(result);
},
err => {
const error: HttpError = err as HttpError;
const resp = new ErrorResponseBuilder()