/** * Route params: id * Deleta o projeto associado ao id presente nos parĂ¢metros da rota. */ server.delete('/projects/:id', checkProjectExists, (req, res) => { const { id } = req.params; const projectIndex = projects.findIndex(p => p.id == id); projects.splice(projectIndex, 1); return res.send(); });
private registerRoutes() { this.app.get('/', this.indexHandler.bind(this)) this.app.get(API_ENDPOINT, this.getHandler.bind(this)) this.app.post(API_ENDPOINT, this.addHandler.bind(this)) this.app.put(`${API_ENDPOINT}/:isbn`, this.editHandler.bind(this)) this.app.delete(`${API_ENDPOINT}/:isbn`, this.removeHandler.bind(this)) }