本文整理汇总了TypeScript中guards/optInFeatureToggleGuard.OptInFeatureToggleGuard类的典型用法代码示例。如果您正苦于以下问题:TypeScript OptInFeatureToggleGuard类的具体用法?TypeScript OptInFeatureToggleGuard怎么用?TypeScript OptInFeatureToggleGuard使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了OptInFeatureToggleGuard类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: enableFor
enableFor (app: express.Express) {
if (app.settings.nunjucksEnv && app.settings.nunjucksEnv.globals) {
app.settings.nunjucksEnv.globals.FullAdmissionPaths = FullAdmissionPaths
app.settings.nunjucksEnv.globals.PartAdmissionPaths = PartAdmissionPaths
app.settings.nunjucksEnv.globals.StatementOfMeansPaths = StatementOfMeansPaths
app.settings.nunjucksEnv.globals.DefenceType = DefenceType
app.settings.nunjucksEnv.globals.FreeMediationOption = FreeMediationOption
app.settings.nunjucksEnv.globals.domain = {
ResponseType: ResponseType,
PaymentOption: PaymentOption,
PaymentSchedule: PaymentSchedule
}
}
const allResponseRoutes = '/case/*/response/*'
app.all(allResponseRoutes, defendantResponseRequestHandler())
app.all(allResponseRoutes, ClaimMiddleware.retrieveByExternalId)
app.all(/^\/case\/.+\/response\/(?!receipt|summary|claim-details).*$/, OnlyDefendantLinkedToClaimCanDoIt.check())
app.all(
/^\/case\/.+\/response\/(?!confirmation|counter-claim|receipt|summary|claim-details).*$/,
ResponseGuard.checkResponseDoesNotExist()
)
app.all('/case/*/response/summary', OnlyClaimantLinkedToClaimCanDoIt.check(), ResponseGuard.checkResponseExists())
app.all(/^\/case\/.*\/response\/(?!claim-details).*$/, CountyCourtJudgmentRequestedGuard.requestHandler)
app.all(/^\/case\/.*\/response\/statement-of-means\/.*/, OptInFeatureToggleGuard.featureEnabledGuard('admissions'))
app.all(/^\/case\/.+\/response\/(?!confirmation|receipt|summary).*$/,
DraftMiddleware.requestHandler(new DraftService(), 'response', 100, (value: any): ResponseDraft => {
return new ResponseDraft().deserialize(value)
}),
(req: express.Request, res: express.Response, next: express.NextFunction) => {
res.locals.draft = res.locals.responseDraft
next()
},
initiatePartyFromClaimHandler
)
app.all(/^\/case\/.+\/response\/task-list|check-and-send|incomplete-submission.*$/,
DraftMiddleware.requestHandler(new DraftService(), 'mediation', 100, (value: any): MediationDraft => {
return new MediationDraft().deserialize(value)
}))
app.use('/', RouterFinder.findAll(path.join(__dirname, 'routes')))
}
示例2: get
import { partialAdmissionPath, Paths } from 'response/paths'
class ModelAccessor extends AbstractModelAccessor<ResponseDraft, PaymentIntention> {
get (draft: ResponseDraft): PaymentIntention {
return draft.partialAdmission.paymentIntention
}
set (draft: ResponseDraft, model: PaymentIntention): void {
draft.partialAdmission.paymentIntention = model
}
}
class PaymentDatePage extends AbstractPaymentDatePage<ResponseDraft> {
getHeading (): string {
return 'What date will you pay on?'
}
createModelAccessor (): AbstractModelAccessor<ResponseDraft, PaymentIntention> {
return new ModelAccessor()
}
buildPostSubmissionUri (req: express.Request, res: express.Response): string {
const { externalId } = req.params
return Paths.taskListPage.evaluateUri({ externalId: externalId })
}
}
/* tslint:disable:no-default-export */
export default new PaymentDatePage()
.buildRouter(partialAdmissionPath, OptInFeatureToggleGuard.featureEnabledGuard('admissions'))
示例3: renderView
function renderView (form: Form<HowMuchHaveYouPaid>, res: express.Response) {
const pastDate: Moment = MomentFactory.currentDate().subtract(3, 'months')
res.render(page.associatedView, {
form: form,
totalAmount: res.locals.claim.totalAmountTillToday,
pastDate
})
}
/* tslint:disable:no-default-export */
export default express.Router()
.get(
page.uri,
PartialAdmissionGuard.requestHandler(),
OptInFeatureToggleGuard.featureEnabledGuard('admissions'),
ErrorHandling.apply(async (req: express.Request, res: express.Response, next: express.NextFunction) => {
const draft: Draft<ResponseDraft> = res.locals.responseDraft
renderView(new Form(draft.document.partialAdmission.howMuchHaveYouPaid), res)
}))
.post(
page.uri,
PartialAdmissionGuard.requestHandler(),
OptInFeatureToggleGuard.featureEnabledGuard('admissions'),
FormValidator.requestHandler(HowMuchHaveYouPaid, HowMuchHaveYouPaid.fromObject),
ErrorHandling.apply(async (req: express.Request, res: express.Response, next: express.NextFunction): Promise<void> => {
const form: Form<HowMuchHaveYouPaid> = req.body
if (form.hasErrors()) {
renderView(form, res)
} else {
示例4: buildPostSubmissionUri
buildPostSubmissionUri (path: string, req: express.Request, res: express.Response): string {
const model: PaymentOption = req.body.model
if (model.isOfType(PaymentType.INSTALMENTS)) {
return this.buildTaskListUri(req, res)
}
return super.buildPostSubmissionUri(path, req, res)
}
buildTaskListUri (req: express.Request, res: express.Response): string {
const { externalId } = req.params
return Paths.taskListPage.evaluateUri({ externalId: externalId })
}
}
const setHowMuchDoYouOweAmount = (req: express.Request, res: express.Response, next: express.NextFunction) => {
const draft: ResponseDraft = res.locals.responseDraft.document
if (draft.isResponsePartiallyAdmitted() && draft.partialAdmission.howMuchDoYouOwe) {
res.locals.amount = draft.partialAdmission.howMuchDoYouOwe.amount || 0
}
next()
}
/* tslint:disable:no-default-export */
export default new PaymentOptionPage()
.buildRouter(partialAdmissionPath, OptInFeatureToggleGuard.featureEnabledGuard('admissions'), setHowMuchDoYouOweAmount)