How to use the http-status.NO_CONTENT function in http-status

To help you get started, we’ve selected a few http-status examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github IBM / taxinomitis / src / lib / restapi / projects.ts View on Github external
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);
    }
}
github restberry / restberry / test / like-minded / libs / testlib.js View on Github external
testlib.client.get('logout', function(err, res) {
        testlib.session.end();
        exports.client = testlib.client;
        if (res.statusCode === httpStatus.NO_CONTENT)  next();
    });
};
github waldemarnt / testable-nodejs-api / test / integration / routes / books.js View on Github external
.end((err, res) => {
        expect(res.statusCode).to.eql(HttpStatus.NO_CONTENT);
        done(err);
      });
    });
github waldemarnt / testable-nodejs-api / controllers / books.js View on Github external
    .then(result => defaultResponse(result, HttpStatus.NO_CONTENT))
    .catch(error => errorResponse(error.message, HttpStatus.UNPROCESSABLE_ENTITY));
github waldemarnt / testable-nodejs-api / test / contract / contracts / users.js View on Github external
.end((err, res) => {
        expect(res.statusCode).to.eql(HttpStatus.NO_CONTENT);
        done(err);
      });
    });
github restberry / restberry / test / testlib.js View on Github external
client.get('logout', function(err, res) {
        if (res.statusCode === httpStatus.NO_CONTENT) {
            exports.session.end();
            next();
        }
    });
};
github deepstreamIO / deepstream.io / src / connection-endpoint / http / node-server.ts View on Github external
}
    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)
  }
github IBM / taxinomitis / src / lib / restapi / watsonapis.ts View on Github external
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);
    }
}
github IBM / taxinomitis / src / lib / restapi / users.ts View on Github external
.then(() => {
            return res.status(httpstatus.NO_CONTENT).send();
        })
        .catch((err) => {
github danielfsousa / express-rest-es2017-boilerplate / src / api / controllers / user.controller.js View on Github external
    .then(() => res.status(httpStatus.NO_CONTENT).end())
    .catch(e => next(e));