How to use the http-status-codes.OK function in http-status-codes

To help you get started, we’ve selected a few http-status-codes 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 adobe / commerce-cif-magento / test / customer / getCustomerIT.js View on Github external
.then(function (res) {
                    expect(res).to.be.json;
                    expect(res).to.have.status(HttpStatus.OK);

                    // Verify structure
                    requiredFields.verifyCustomer(res.body);
                });
        });
github adobe / commerce-cif-magento / test / carts / postPaymentIT.js View on Github external
.then(function(res) {
                    expect(res).to.be.json;
                    expect(res).to.have.status(HttpStatus.OK);
                    requiredFields.verifyCart(res.body);
                    let payment = res.body.payment;
                    requiredFields.verifyPayment(payment);
                    expect(payment.method).to.equal('checkmo');
                });
        });
github dinevillar / adonis-json-api-serializer / src / Http / Controller / ResourceController.js View on Github external
const idField = _.get(jsonApi, 'registry.structure.id', 'id')
    const modelInstance = await Model.findBy(idField, params.id)
    if (modelInstance) {
      let data = _.clone(jsonApi.data)
      if (typeof Model.writeable === 'object') {
        data = _.pick(data, Model.writeable)
      }
      modelInstance.merge(data)
      await modelInstance.save()
      const relationships = _.get(request.all(), 'data.relationships', false)
      if (relationships) {
        const relationshipsHandler = JsonApiRelationshipHandler.init(jsonApi, modelInstance)
        await relationshipsHandler.handleRelationshipUpdate(relationships)
      }
      response
        .status(HttpStatus.OK)
        .send(modelInstance.toJSON())
    } else {
      throw JSE.ResourceObjectDoesNotExist.invoke(
        jsonApi.type,
        params.id
      )
    }
  }
github Tangerine-Community / Tangerine / tree / routes / makeApk.js View on Github external
buildIt(function(err) {
      if (err) return console.log(err) 
      res.status(HttpStatus.OK).json({
          token : token
      })
    })
  })
github Sunbird-Ed / SunbirdEd-portal / src / app / helpers / review-comments / index.js View on Github external
.then((data) => {
        sendSuccessResponse(responseObj, API_IDS.createthread, data, HttpStatus.OK)
      })
      .catch((err) => {console.log('ee', err)
github RouteInjector / route-injector / lib / engine / routeinjector / rest / export.js View on Github external
}
                                }
                            );
                        } else if (format == 'xlsx') {
                            var xls = json2xls(result, { fields: fields });
                            res.statusCode = statusCode.OK;
                            res.attachment(Model.modelName + ".xlsx");
                            return res.end(xls, 'binary');

                        } else if (format == 'json') {
                            res.statusCode = statusCode.OK;
                            res.attachment(Model.modelName + ".json");
                            return res.end(JSON.stringify(result), 'UTF-8');
                        } else if (format == 'json+zip') {
                            var by = req.body.by || req.query.by || "_id";
                            res.statusCode = statusCode.OK;

                            //Create tmp folder
                            var fs = require('fs');
                            var JSZip = require('node-zip');
                            var zip = new JSZip();
                            zip.file(Model.modelName + '.zip');

                            //Export all the models
                            for (var i in result) {
                                var doc = result[i];
                                var fileName = doc[by] + ".json";
                                //fs.writeFileSync(fileName, doc, 'UTF-8');
                                zip.file(fileName, JSON.stringify(doc));
                            }

                            //ZIP file
github microsoft / BotFramework-Emulator / packages / app / main / src / server / routes / channel / userToken / handlers / signOut.ts View on Github external
export function signOut(req: Restify.Request, res: Restify.Response, next: Restify.Next): any {
  try {
    const params: TokenParams = req.params;
    const botEndpoint: BotEndpoint = (req as any).botEndpoint;
    TokenCache.deleteTokenFromCache(botEndpoint.botId, params.userId, params.connectionName);

    res.send(HttpStatus.OK);
    res.end();
  } catch (err) {
    sendErrorResponse(req, res, next, err);
  }
  next();
}
github Matterwiki / Matterwiki / src / api / routes / authRouter.js View on Github external
const finishCheck = (req, res) => res.status(HttpStatus.OK).json(req.user);
github microsoft / BotFramework-Emulator / packages / app / main / src / controllers / emulator / emulatorController.ts View on Github external
static getUsers = (req: Restify.Request, res: Restify.Response, next: Restify.Next): any => {
        try {
            const conversation = getConversation(req.params.conversationId);
            res.json(HttpStatus.OK, conversation.members);
            res.end();
        } catch (err) {
            sendErrorResponse(req, res, next, err);
        }
    }
github microsoft / BotFramework-Emulator / packages / app / main / src / server / routes / emulator / handlers / sendTokenResponse.ts View on Github external
export async function sendTokenResponse(req: ConversationAwareRequest, res: Response, next: Next): Promise {
  const body: {
    token: string;
    connectionName: string;
  } = req.body[0];

  const { statusCode } = await req.conversation.sendTokenResponse(body.connectionName, body.token, true);

  if (statusCode === HttpStatus.OK) {
    res.send(HttpStatus.OK, body);
  } else {
    res.send(statusCode);
  }
  res.end();

  next();
}