当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript Boom.notFound函数代码示例

本文整理汇总了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) => {
开发者ID:csgpro,项目名称:csgpro.com,代码行数:15,代码来源:blog.controller.ts

示例2: getPostByPostId

 getPostByPostId(postId).then(post => {
     if (!post) {
         reply(boom.notFound());
         return;
     }
     reply({ data: post.toJSON() });
 }).catch((err: Error) => {
开发者ID:csgpro,项目名称:csgpro.com,代码行数:7,代码来源:post.controller.ts

示例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],
    },
  });
}
开发者ID:salihkardan,项目名称:kibana,代码行数:30,代码来源:delete.ts

示例4: reply

 this.userRepository.findById(id).then((user: IUser) => {
   if (user) {
     reply(user);
   } else {
     reply(Boom.notFound());
   }
 }).catch((error) => {
开发者ID:divramod,项目名称:hapi-seed-advanced,代码行数:7,代码来源:userController.ts

示例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);
 });
开发者ID:ericmasiello,项目名称:synbydesign,代码行数:7,代码来源:apiControllers.ts

示例6: reply

 this.doorRepository.findById(id).then((door: IDoor) => {
   if (door) {
     reply(door);
   } else {
     reply(Boom.notFound());
   }
 }).catch((error) => {
开发者ID:Happy-Ferret,项目名称:wachschutz,代码行数:7,代码来源:doorController.ts

示例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()
}
开发者ID:TechNottingham,项目名称:Hack24-API,代码行数:60,代码来源:add-team-entries.ts

示例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) => {
开发者ID:csgpro,项目名称:csgpro.com,代码行数:7,代码来源:careers.controller.ts

示例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)
}
开发者ID:TechNottingham,项目名称:Hack24-API,代码行数:25,代码来源:get-hack.ts

示例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)
}
开发者ID:TechNottingham,项目名称:Hack24-API,代码行数:33,代码来源:get-team-entries.ts


注:本文中的Boom.notFound函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。