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


TypeScript nodejs-logging.Logger类代码示例

本文整理汇总了TypeScript中@hmcts/nodejs-logging.Logger的典型用法代码示例。如果您正苦于以下问题:TypeScript Logger类的具体用法?TypeScript Logger怎么用?TypeScript Logger使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Logger类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: requestHandler

import * as express from 'express'
import { Claim } from 'claims/models/claim'
import { ClaimStoreClient } from 'claims/claimStoreClient'
import { ErrorPaths } from 'first-contact/paths'
import { User } from 'idam/user'
import { Logger } from '@hmcts/nodejs-logging'
import { OAuthHelper } from 'idam/oAuthHelper'

const logger = Logger.getLogger('first-contact/guards/claimReferenceMatchesGuard')
const claimStoreClient: ClaimStoreClient = new ClaimStoreClient()

export class ClaimReferenceMatchesGuard {

  static async requestHandler (req: express.Request, res: express.Response, next: express.NextFunction): Promise<void> {
    try {
      const reference = ClaimReferenceMatchesGuard.getClaimRef(req)

      const user: User = res.locals.user
      const claim: Claim = await claimStoreClient.retrieveByLetterHolderId(user.id, user.bearerToken)
      res.locals.claim = claim

      if (claim.claimNumber !== reference) {
        logger.error('Claim reference mismatch - redirecting to access denied page')
        res.redirect(ErrorPaths.claimSummaryAccessDeniedPage.uri)
      } else {
        next()
      }
    } catch (err) {
      next(err)
    }
  }
开发者ID:hmcts,项目名称:cmc-citizen-frontend,代码行数:31,代码来源:claimReferenceMatchesGuard.ts

示例2: requestHandler

import * as express from 'express'
import { Claim } from 'claims/models/claim'
import { Paths } from 'dashboard/paths'
import { Logger } from '@hmcts/nodejs-logging'

const logger = Logger.getLogger('ccj/guards/ccjGuard')

export class CCJGuard {

  static async requestHandler (req: express.Request, res: express.Response, next: express.NextFunction): Promise<void> {
    const claim: Claim = res.locals.claim

    if (claim.eligibleForCCJ
      || claim.eligibleForCCJAfterBreachedSettlementTerms
      || claim.isSettlementAgreementRejected) {
      next()
    } else {
      logger.warn(`Claim ${claim.claimNumber} not eligible for a CCJ - redirecting to dashboard page`)
      res.redirect(Paths.dashboardPage.uri)
    }
  }

}
开发者ID:hmcts,项目名称:cmc-citizen-frontend,代码行数:23,代码来源:ccjGuard.ts

示例3: requestHandler

import * as express from 'express'

import { Draft } from '@hmcts/draft-store-client'
import { Logger } from '@hmcts/nodejs-logging'
import { Claim } from 'claims/models/claim'
import { Paths } from 'claimant-response/paths'
import { TaskListBuilder } from 'claimant-response/helpers/taskListBuilder'
import { DraftClaimantResponse } from 'claimant-response/draft/draftClaimantResponse'
import { MediationDraft } from 'mediation/draft/mediationDraft'

const logger = Logger.getLogger('router/claimant-response/check-and-send')

export class AllClaimantResponseTasksCompletedGuard {

  static async requestHandler (req: express.Request, res: express.Response, next: express.NextFunction): Promise<void> {
    try {
      const draft: Draft<DraftClaimantResponse> = res.locals.claimantResponseDraft
      const mediationDraft: Draft<MediationDraft> = res.locals.mediationDraft
      const claim: Claim = res.locals.claim

      const allTasksCompleted: boolean = TaskListBuilder
        .buildRemainingTasks(draft.document, claim, mediationDraft.document).length === 0

      if (allTasksCompleted) {
        return next()
      }

      logger.debug('State guard: check and send page is disabled until all tasks are completed - redirecting to task list')
      res.redirect(Paths.incompleteSubmissionPage.evaluateUri({ externalId: claim.externalId }))
    } catch (err) {
      next(err)
开发者ID:hmcts,项目名称:cmc-citizen-frontend,代码行数:31,代码来源:allClaimantResponseTasksCompletedGuard.ts

示例4: defendantResponseRequestHandler

import * as express from 'express'
import * as path from 'path'

import { AuthorizationMiddleware } from 'idam/authorizationMiddleware'
import { RouterFinder } from 'shared/router/routerFinder'
import { Logger } from '@hmcts/nodejs-logging'
import { OAuthHelper } from 'idam/oAuthHelper'

const logger = Logger.getLogger('testing-support')

function defendantResponseRequestHandler (): express.RequestHandler {
  function accessDeniedCallback (req: express.Request, res: express.Response): void {
    res.redirect(OAuthHelper.forLogin(req, res))
  }

  const requiredRoles = [
    'citizen'
  ]
  const unprotectedPaths = []
  return AuthorizationMiddleware.requestHandler(requiredRoles, accessDeniedCallback, unprotectedPaths)
}

export class TestingSupportFeature {
  enableFor (app: express.Express) {
    logger.info('Testing support activated')
    app.all('/testing-support*', defendantResponseRequestHandler())
    app.use('/', RouterFinder.findAll(path.join(__dirname, 'routes')))
  }
}
开发者ID:hmcts,项目名称:cmc-citizen-frontend,代码行数:29,代码来源:index.ts

示例5: requestHandler

import * as express from 'express'
import { Paths as DashboardPaths } from 'dashboard/paths'
import { Claim } from 'claims/models/claim'
import { Logger } from '@hmcts/nodejs-logging'

const logger = Logger.getLogger('response/guards/countyCourtJudgmentRequestedGuard')

export class CountyCourtJudgmentRequestedGuard {

  static requestHandler (req: express.Request, res: express.Response, next: express.NextFunction) {
    const claim: Claim = res.locals.claim
    if (claim.countyCourtJudgmentRequestedAt) {
      logger.warn('State guard: CCJ already requested - redirecting to dashboard')
      return res.redirect(DashboardPaths.dashboardPage.uri)
    } else {
      next()
    }
  }
}
开发者ID:hmcts,项目名称:cmc-citizen-frontend,代码行数:19,代码来源:countyCourtJudgmentRequestedGuard.ts

示例6: renderView

import { Form } from 'forms/form'
import { FormValidator } from 'forms/validation/formValidator'
import { User } from 'idam/user'
import { DateOfBirth } from 'forms/models/dateOfBirth'
import { PartyType } from 'common/partyType'

import { ErrorHandling } from 'shared/errorHandling'
import { DraftService } from 'services/draftService'
import { Claim } from 'claims/models/claim'
import { DraftCCJ } from 'ccj/draft/draftCCJ'
import { Draft } from '@hmcts/draft-store-client'

import { Logger } from '@hmcts/nodejs-logging'

const logger = Logger.getLogger('ccj/guards/individualDateOfBirth')

const accessGuardRequestHandler: express.RequestHandler = GuardFactory.create((res: express.Response): boolean => {
  const claim: Claim = res.locals.claim

  return claim.claimData.defendant.type === PartyType.INDIVIDUAL.value
}, (req: express.Request, res: express.Response): void => {
  logger.warn(`CCJ state guard: defendant date of birth is only available for individual defendants - redirecting to dashboard page`)
  res.redirect(DashboardPaths.dashboardPage.uri)
})

function renderView (form: Form<DateOfBirth>, res: express.Response): void {
  res.render(Paths.dateOfBirthPage.associatedView, { form: form })
}

/* tslint:disable:no-default-export */
开发者ID:hmcts,项目名称:cmc-citizen-frontend,代码行数:30,代码来源:date-of-birth.ts

示例7: check

import * as express from 'express'

import { Paths } from 'dashboard/paths'
import { Logger } from '@hmcts/nodejs-logging'
import { Claim } from 'claims/models/claim'
import { User } from 'idam/user'
import { GuardFactory } from 'response/guards/guardFactory'

const logger = Logger.getLogger('offer/guards/offerAcceptedGuard')

export class OfferAcceptedGuard {

  static check (): express.RequestHandler {
    return GuardFactory.create((res: express.Response) => {
      const claim: Claim = res.locals.claim
      const user: User = res.locals.user

      if (claim.settlementReachedAt) {
        logger.warn('State guard: offer settlement reached, redirecting to dashboard')
        return false
      } else if (user.id === claim.claimantId && claim.claimantId !== claim.defendantId
                && claim.settlement.isOfferResponded()) {
        logger.warn('State guard: offer already accepted, redirecting to dashboard')
        return false
      } else {
        return true
      }
    }, (req: express.Request, res: express.Response) => {
      res.redirect(Paths.dashboardPage.uri)
    })
  }
开发者ID:hmcts,项目名称:cmc-citizen-frontend,代码行数:31,代码来源:offerAcceptedGuard.ts

示例8: hasTokenExpired

import * as express from 'express'
import * as config from 'config'
import * as HttpStatus from 'http-status-codes'
import * as Cookies from 'cookies'

import { JwtExtractor } from 'idam/jwtExtractor'
import { IdamClient } from 'idam/idamClient'
import { User } from 'idam/user'
import { Logger } from '@hmcts/nodejs-logging'

const sessionCookieName = config.get<string>('session.cookieName')

const logger = Logger.getLogger('middleware/authorization')

/**
 * IDAM doesn't tell us what is wrong
 * But most likely if we get 401 or 403 then the user's token has expired
 * So make them login again
 */
export function hasTokenExpired (err) {
  return (err.statusCode === HttpStatus.FORBIDDEN || err.statusCode === HttpStatus.UNAUTHORIZED)
}

export class AuthorizationMiddleware {

  static requestHandler (requiredRoles: string[], accessDeniedCallback: (req: express.Request, res: express.Response) => void, unprotectedPaths?: string[]): express.RequestHandler {
    function isPathUnprotected (path: string): boolean {
      return unprotectedPaths.some((unprotectedPath: string) => unprotectedPath === path)
    }

    return (req: express.Request, res: express.Response, next: express.NextFunction) => {
开发者ID:hmcts,项目名称:cmc-citizen-frontend,代码行数:31,代码来源:authorizationMiddleware.ts

示例9: checkClaimantResponseDoesNotExist

import * as express from 'express'

import { GuardFactory } from 'response/guards/guardFactory'
import { Logger } from '@hmcts/nodejs-logging'

import { Claim } from 'claims/models/claim'
import { Paths as DashboardPaths } from 'dashboard/paths'

const logger = Logger.getLogger('claimant-response/guards/claimantResponseGuard')

export class ClaimantResponseGuard {

  static checkClaimantResponseDoesNotExist (): express.RequestHandler {
    const allowed = (res: express.Response) => {
      const claim: Claim = res.locals.claim
      return claim.claimantResponse === undefined
    }
    const accessDeniedCallback = (req: express.Request, res: express.Response) => {
      logger.warn('State guard: claimant response already exists - redirecting to dashboard')
      res.redirect(DashboardPaths.dashboardPage.uri)
    }
    return GuardFactory.create(allowed, accessDeniedCallback)
  }
}
开发者ID:hmcts,项目名称:cmc-citizen-frontend,代码行数:24,代码来源:claimantResponseGuard.ts

示例10: requestHandler

import * as express from 'express'

import { Claim } from 'claims/models/claim'
import { Paths } from 'response/paths'
import { TaskListBuilder } from 'response/helpers/taskListBuilder'
import { Draft } from '@hmcts/draft-store-client'
import { ResponseDraft } from 'response/draft/responseDraft'
import { Logger } from '@hmcts/nodejs-logging'
import { MediationDraft } from 'mediation/draft/mediationDraft'

const logger = Logger.getLogger('router/response/check-and-send')

export class AllResponseTasksCompletedGuard {

  static async requestHandler (req: express.Request, res: express.Response, next: express.NextFunction): Promise<void> {
    try {
      const claim: Claim = res.locals.claim
      const draft: Draft<ResponseDraft> = res.locals.responseDraft
      const mediationDraft: Draft<MediationDraft> = res.locals.mediationDraft

      const allTasksCompleted: boolean = TaskListBuilder
        .buildRemainingTasks(draft.document, claim, mediationDraft.document).length === 0

      if (allTasksCompleted) {
        return next()
      }

      logger.debug('State guard: claim check and send page is disabled until all tasks are completed - redirecting to task list')
      res.redirect(Paths.incompleteSubmissionPage.evaluateUri({ externalId: claim.externalId }))
    } catch (err) {
      next(err)
开发者ID:hmcts,项目名称:cmc-citizen-frontend,代码行数:31,代码来源:allResponseTasksCompletedGuard.ts


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