本文整理汇总了TypeScript中Boom.notFound函数的典型用法代码示例。如果您正苦于以下问题:TypeScript notFound函数的具体用法?TypeScript notFound怎么用?TypeScript notFound使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了notFound函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: getPostByPostId
getPostByPostId(postId).then(post => {
if (!post) {
reply(boom.notFound());
return;
}
let host = request.headers['host'];
let protocol = getProtocolByHost(host);
let postJSON = post.toJSON();
if (postJSON.permalink && postJSON.permalink !== 'undefined') {
let POST_URL = `${protocol}://${host}${postJSON.permalink}`;
reply.redirect(POST_URL);
} else {
reply(boom.notFound());
}
}).catch((err: Error) => {
示例2: getPostByPostId
getPostByPostId(postId).then(post => {
if (!post) {
reply(boom.notFound());
return;
}
reply({ data: post.toJSON() });
}).catch((err: Error) => {
示例3: initDeleteSpacesApi
export function initDeleteSpacesApi(server: any, routePreCheckLicenseFn: any) {
server.route({
method: 'DELETE',
path: '/api/spaces/space/{id}',
async handler(request: any, reply: any) {
const { SavedObjectsClient } = server.savedObjects;
const spacesClient: SpacesClient = server.plugins.spaces.spacesClient.getScopedClient(
request
);
const id = request.params.id;
let result;
try {
result = await spacesClient.delete(id);
} catch (error) {
if (SavedObjectsClient.errors.isNotFoundError(error)) {
return reply(Boom.notFound());
}
return reply(wrapError(error));
}
return reply(result).code(204);
},
config: {
pre: [routePreCheckLicenseFn],
},
});
}
示例4: reply
this.userRepository.findById(id).then((user: IUser) => {
if (user) {
reply(user);
} else {
reply(Boom.notFound());
}
}).catch((error) => {
示例5: getById
return getById(id).then(item => {
if (!item) {
Sentry.captureMessage(`Portfolio item does not exist: ${id}`);
return next(boom.notFound(`Portfolio item does not exist: ${id}`));
}
return res.json(item);
});
示例6: reply
this.doorRepository.findById(id).then((door: IDoor) => {
if (door) {
reply(door);
} else {
reply(Boom.notFound());
}
}).catch((error) => {
示例7: handler
export default async function handler(req: Request, reply: IReply) {
const { teamId: teamid } = req.params
const requestDoc: TeamEntriesRelationship.TopLevelDocument = req.payload
const team = await TeamModel
.findOne({ teamid }, 'teamid name entries')
.populate('entries', 'hackid')
.exec()
if (team === null) {
reply(Boom.notFound('Team not found'))
return
}
const hackIdsToAdd = requestDoc.data.map((hack) => hack.id)
const existingHackIds = hackIdsToAdd.filter((hackIdToAdd) => team.entries.some((actualhack) => actualhack.hackid === hackIdToAdd))
if (existingHackIds.length > 0) {
reply(Boom.badRequest('One or more hacks are already entries of this team'))
return
}
const hacks = await HackModel
.find({ hackid: { $in: hackIdsToAdd } }, 'hackid name')
.exec()
if (hacks.length !== hackIdsToAdd.length) {
reply(Boom.badRequest('One or more of the specified hacks could not be found'))
return
}
const hackObjectIds = hacks.map((hack) => hack._id)
const teams = await TeamModel
.find({ entries: { $in: hackObjectIds } }, 'teamid')
.exec()
if (teams.length > 0) {
reply(Boom.badRequest('One or more of the specified hacks are already in a team'))
return
}
team.entries = team.entries.concat(hacks.map((hack) => hack._id))
await team.save()
const eventBroadcaster: EventBroadcaster = req.server.app.eventBroadcaster
hacks.forEach((hack) => {
eventBroadcaster.trigger('teams_update_entries_add', {
teamid: team.teamid,
name: team.name,
entry: {
hackid: hack.hackid,
name: hack.name,
},
}, req.logger)
})
reply()
}
示例8: getPost
getPost(postSlug, 'career').then(job => {
if (!job) {
reply(boom.notFound());
}
let jobJSON = job.toJSON();
reply.view('post', { title: jobJSON.title, post: jobJSON }, { layout: 'hero-layout' });
}).catch((err: Error) => {
示例9: handler
export default async function handler(req: Request, reply: IReply) {
const { hackId: hackid } = req.params
const hack = await HackModel
.findOne({ hackid }, 'hackid name')
.exec()
if (hack === null) {
reply(Boom.notFound('Hack not found'))
return
}
const hackResponse: HackResource.TopLevelDocument = {
links: { self: `/hacks/${encodeURIComponent(hack.hackid)}` },
data: {
type: 'hacks',
id: hack.hackid,
attributes: {
name: hack.name,
},
},
}
reply(hackResponse)
}
示例10: handler
export default async function handler(req: Request, reply: IReply) {
const { teamId: teamid } = req.params
const team = await TeamModel
.findOne({ teamid }, 'teamid entries')
.populate('entries', 'hackid name')
.exec()
if (team === null) {
reply(Boom.notFound('Team not found'))
return
}
const entries = team.entries.map((hack): JSONApi.ResourceIdentifierObject => ({
type: 'hacks',
id: hack.hackid,
}))
const includedHacks = team.entries.map((hack): HackResource.ResourceObject => ({
links: { self: `/hacks/${hack.hackid}` },
type: 'hacks',
id: hack.hackid,
attributes: { name: hack.name },
}))
const entriesResponse: TeamEntriesRelationship.TopLevelDocument = {
links: { self: `/teams/${encodeURIComponent(team.teamid)}/entries` },
data: entries,
included: includedHacks,
}
reply(entriesResponse)
}