How to use the http-status-codes.CREATED 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 / carts / getPaymentMethodsIT.js View on Github external
.then(function (res) {
                    expect(res).to.be.json;
                    expect(res).to.have.status(HttpStatus.CREATED);
                    expect(res.body.id).to.not.be.empty;

                    // Store cart id
                    cartId = res.body.id;
                });
        });
github Azure / meta-azure-service-broker / lib / services / azuresqldb / index.js View on Github external
databaseLogin,
        databaseLoginPassword,
        fqdn.replace(/.+\.database/, '*.database.secure'));

        var uri = util.format('mssql://%s:%s@%s:1433/%s?encrypt=true&TrustServerCertificate=false&HostNameInCertificate=%s',
        encodedLogin,
        encodedLoginPassword,
        fqdn,
        sqldbName,
        fqdn.replace(/.+\.database/, '%2A.database')
      );

      // contents of reply.value winds up in VCAP_SERVICES
      var reply = {
        statusCode: HttpStatus.CREATED,
        code: HttpStatus.getStatusText(HttpStatus.CREATED),
        value: {
          credentials: {
            sqldbName: sqldbName,
            sqlServerName: sqlServerName,
            sqlServerFullyQualifiedDomainName: fqdn,
            databaseLogin: databaseLogin,
            databaseLoginPassword: databaseLoginPassword,
            jdbcUrl: jdbcUrl,
            jdbcUrlForAuditingEnabled: jdbcUrlForAuditingEnabled,
            hostname: fqdn,
            port: 1433,
            name: sqldbName,
            username: databaseLogin,
            password: databaseLoginPassword,
            uri: uri
          }
github akshaykmr / oorja / app / imports / ui / actions / roomConfiguration.js View on Github external
.then((response) => {
        if (response.status !== HttpStatus.CREATED) return Promise.reject(response);

        const {
          roomName: createdRoomName, roomSecret, passwordEnabled, roomAccessToken,
        } = response.data;
        // its called createdRoomName because some minor changes may be done to
        // the name sent by the client above.
        // store secret in localStorage
        dispatch({
          type: CREATE_ROOM,
          payload: { createdRoomName },
        });

        if (passwordEnabled) {
          dispatch(storeRoomAccessToken(createdRoomName, roomAccessToken));
        } else {
          dispatch(storeRoomSecret(createdRoomName, roomSecret));
github Azure / meta-azure-service-broker / lib / services / azurerediscache / index.js View on Github external
cp.bind(redisClient, function(err, credentials) {
    if (err) {
      common.handleServiceError(err, next);
    } else {
      // contents of reply.value winds up in VCAP_SERVICES
      var reply = {
        statusCode: HttpStatus.CREATED,
        code: HttpStatus.getStatusText(HttpStatus.CREATED),
        value: {
          credentials: credentials
        }
      };
      next(null, reply, {});
    }
  });
};
github Azure / meta-azure-service-broker / test / unit / services / azuresqldb / poll-spec.js View on Github external
it('succeed on CREATED return code', function (done) {
            var cp = new cmdPoll(afterProvisionValidParamsWithTDE);
            var tdeResult = {
                statusCode:HttpStatus.CREATED,
                body:{
                    message:'success'
                }
            };
            msRestRequest.PUT.withArgs('https://management.azure.com//subscriptions/55555555-4444-3333-2222-111111111111/resourceGroups/sqldbResourceGroup/providers/Microsoft.Sql/servers/golive4/databases/sqldb/transparentDataEncryption/current')
              .yields(null, tdeResult, tdeResult.body);

            cp.poll(sqldbOps, function (err, result) {
                should.not.exist(err);
                result.statusCode.should.equal(HttpStatus.OK);
                result.value.state.should.equal('succeeded');
                done();
            });
        });
    });
github CodepediaOrg / bookmarks.dev-api / routes / users / users.js View on Github external
}

    const userData = new User({
      userId: request.params.userId,
      searches: request.body.searches,
      readLater: request.body.readLater,
      likes: request.body.likes,
      watchedTags: request.body.watchedTags,
      pinned: request.body.pinned,
      favorites: request.body.favorites,
      history: request.body.history
    });

    const newUserData = await userData.save();

    response.status(HttpStatus.CREATED).send(newUserData);

  } catch (err) {
    return response
      .status(HttpStatus.INTERNAL_SERVER_ERROR)
      .send(err);
  }
});
github dstack-group / Butterfly / user-manager / user-manager-rest-api / src / modules / users / controller.ts View on Github external
private createUserCommand: RouteCommand = async routeContext => {
    const userModel = routeContext.getValidatedRequestBody(validateCreateUserBody);

    /**
     * Here we need to manually set undefined values by default because if those fields
     * aren't set, pg-promise is going to complain with a `Property ${property} doesn't exist` error.
     */
    const userParams: CreateUser = {
      enabled: true,
      ...userModel,
    };
    const newUser = await this.manager.create(userParams);

    return {
      data: newUser,
      status: HttpStatus.CREATED,
    };
  }
github Azure / meta-azure-service-broker / lib / services / azurerediscache / client.js View on Github external
function (err, res, body) {
          common.logHttpResponse(res, 'RedisCache - createRedis', false);
          if (err) {
            return callback(err);
          }
          if (res.statusCode != HttpStatus.CREATED && res.statusCode != HttpStatus.OK) {
            return common.formatErrorFromRes(res, callback);
          }

          callback(null, body.properties);
        }
      );
github stanislav-web / ecs-auth-microservice / app / src / api / access / controller.js View on Github external
//noinspection Annotator
    let res = joi.validate(ctx.request.body, schema);
    if (null === res.error) {
        let user = await findUserByEmail(res.value.email);

        if (0 >= user.length) {

            try {

                let recordObject = await createRecordObject(res.value);
                await saveUser(recordObject);
                let tokenObject = await generateTokenObject(res.value);
                ctx.response.status = HttpStatus.CREATED;
                ctx.body = {
                    status: HttpStatus.CREATED,
                    message: {
                        expires_in: tokenObject.expires_in,
                        token: tokenObject.token
                    }
                };
            } catch (err) {
                throw new ApiAccessBoundleError(
                    HttpStatus.SERVICE_UNAVAILABLE, err);
            }
        } else {
            throw new ApiAccessBoundleError(
                HttpStatus.CONFLICT, 'The user already exist');
        }
    } else {
        throw new ApiAccessBoundleError(
            HttpStatus.BAD_REQUEST, res.error.message);
github dstack-group / Butterfly / user-manager / user-manager-rest-api / src / modules / search / controller.ts View on Github external
private searchEventReceiversCommand: RouteCommand = async routeContext => {
    const eventModel = routeContext.getRequestBody() as Event;
    const { saveEvent } = routeContext.getQueryParams() as { saveEvent: string };
    const shouldSaveEvent = saveEvent === 'true';
    const receivers: EventReceiversResult = await this.manager.searchReceiversByRecord(eventModel, shouldSaveEvent);

    return {
      data: receivers.userContactList,
      status: shouldSaveEvent ? HttpStatus.CREATED : HttpStatus.OK,
    };
  }