當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript Logger.getLogger方法代碼示例

本文整理匯總了TypeScript中@hmcts/nodejs-logging.Logger.getLogger方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Logger.getLogger方法的具體用法?TypeScript Logger.getLogger怎麽用?TypeScript Logger.getLogger使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在@hmcts/nodejs-logging.Logger的用法示例。


在下文中一共展示了Logger.getLogger方法的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.getLogger方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。