Feature: Delete a project

As a vision user
I want to delete a project
So that I can remove projects no longer in use

Let's add a test to ./test/project.js for our feature Delete a project. This resource will DELETE a project at route /project/:id and return a 204 No Content status:

describe('when deleting an existing resource /project/:id', function(){
  it('should respond with 204', function(done){
    request(app)
    .del('/project/' + id)
    .expect(204, done);
  });
});

Let's implement the Delete a project feature ./lib/project/index.js and add a del function. We attempt to delete a project by calling the static function Project.findOne. If we get an error, we return it; if we cannot find the project, we return null. If we find the project, we delete it and ...

Get Advanced Express Web Application Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.