-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow multiple CHEFS forms to be configured
FE can pull from multiple data sources. BE has dynamic basic auth based on the requested form ID
- Loading branch information
1 parent
7620356
commit 5d07e2d
Showing
14 changed files
with
176 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// @ts-expect-error api-problem lacks a defined interface; code still works fine | ||
import Problem from 'api-problem'; | ||
|
||
import config from 'config'; | ||
|
||
import { configArrayToArray } from '../components/utils'; | ||
|
||
import type { NextFunction, Request, Response } from 'express'; | ||
import type { ChefsFormConfig } from '../types/ChefsFormConfig'; | ||
|
||
/** | ||
* @function requireChefsFormId | ||
* Rejects the request if there is no form ID present in the request | ||
* or if the given Form ID is not configured | ||
* @param {object} req Express request object | ||
* @param {object} _res Express response object | ||
* @param {function} next The next callback function | ||
* @returns {function} Express middleware function | ||
* @throws The error encountered upon failure | ||
*/ | ||
export const requireChefsFormId = (req: Request, _res: Response, next: NextFunction) => { | ||
const params = { ...req.query, ...req.params }; | ||
|
||
if (!params.formId) { | ||
throw new Problem(400, { | ||
detail: 'Form ID not present in request.', | ||
instance: req.originalUrl | ||
}); | ||
} | ||
|
||
if ( | ||
!configArrayToArray<ChefsFormConfig>({ ...config.get('server.chefs.forms') }).some( | ||
(x: ChefsFormConfig) => x.formId === (params.formId as string) | ||
) | ||
) { | ||
throw new Problem(412, { | ||
detail: 'Form not present or misconfigured.', | ||
instance: req.originalUrl | ||
}); | ||
} | ||
|
||
next(); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export type ChefsFormConfig = { | ||
name: string; | ||
formId: string; | ||
formApiKey: string; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<script setup lang="ts"> | ||
import { Button } from '@/lib/primevue'; | ||
import { RouteNames } from '@/utils/constants'; | ||
</script> | ||
|
||
<template> | ||
<router-link :to="{ name: RouteNames.SUBMISSIONS }"> | ||
<Button>Housing</Button> | ||
</router-link> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.