本文整理汇总了TypeScript中Boom.badImplementation函数的典型用法代码示例。如果您正苦于以下问题:TypeScript badImplementation函数的具体用法?TypeScript badImplementation怎么用?TypeScript badImplementation使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了badImplementation函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: async
const createNewIndex = async (reindexOp: ReindexSavedObject) => {
const { indexName, newIndexName } = reindexOp.attributes;
const flatSettings = await actions.getFlatSettings(indexName);
if (!flatSettings) {
throw Boom.notFound(`Index ${indexName} does not exist.`);
}
const { settings, mappings } = transformFlatSettings(flatSettings);
const createIndex = await callCluster('indices.create', {
index: newIndexName,
body: {
settings,
mappings,
},
});
if (!createIndex.acknowledged) {
throw Boom.badImplementation(`Index could not be created: ${newIndexName}`);
}
return actions.updateReindexOp(reindexOp, {
lastCompletedStep: ReindexStep.newIndexCreated,
});
};
示例2: createUser
public async createUser(request: Hapi.Request, reply: Hapi.ReplyNoContinue) {
try {
let user: any = await this.database.userModel.create(request.payload);
return reply({ token: this.generateToken(user)}).code(201);
} catch (error) {
return reply(Boom.badImplementation(error));
}
}
示例3: checkAndSendSchema
export function checkAndSendSchema(object: any, schema: j.AnySchema<any>, log: any, reply: h.IReply) {
let err;
if(err = j.validate(object, schema).error) {
log.error(err);
reply(b.badImplementation())
} else {
reply(object);
}
}
示例4: updateUser
public async updateUser(request: Hapi.Request, reply: Hapi.ReplyNoContinue) {
const id = request.auth.credentials.id;
try {
let user: IUser = await this.database.userModel.findByIdAndUpdate(id, { $set: request.payload }, { new: true });
return reply(user);
} catch (error) {
return reply(Boom.badImplementation(error));
}
}
示例5: if
.then(status => {
if (status.code >= 400 && status.code < 500) {
throw boom.badRequest(status.message);
} else if (status.code >= 500) {
throw boom.badImplementation(status.message);
}
res.json({
success: true,
});
})
示例6: reply
.catch(function (err) {
if (err.isBoom) {
reply(err);
} else if (err.statusCode != null) {
reply(err).code(err.statusCode);
} else {
reply(Boom.badImplementation(err.message || err, err));
}
if (profile) console.timeEnd(request.path + " handler");
if (profile) console.timeEnd(request.path + " overall");
})
示例7: async
handler: async (request, reply) => {
try {
const canvas: Canvas = await db.getCanvas(request.params.id);
if (!canvas) {
reply(Boom.notFound());
}
reply(canvas);
} catch (error) {
logger.error(error);
reply(Boom.badImplementation());
}
}
示例8: createTask
public async createTask(request: Hapi.Request, reply: Hapi.ReplyNoContinue) {
let userId = request.auth.credentials.id;
var newTask: ITask = request.payload;
newTask.userId = userId;
try {
let task: ITask = await this.database.taskModel.create(newTask);
return reply(task).code(201);
} catch (error) {
return reply(Boom.badImplementation(error));
}
}