-
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.
Resolve unit tests. Allow proper Axios options override. Adding comments Fix minor bug
- Loading branch information
Showing
21 changed files
with
189 additions
and
362 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
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,36 @@ | ||
// @ts-expect-error api-problem lacks a defined interface; code still works fine | ||
import Problem from 'api-problem'; | ||
|
||
import { getChefsApiKey } from '../components/utils'; | ||
|
||
import type { NextFunction, Request, Response } from 'express'; | ||
|
||
/** | ||
* @function requireChefsFormConfigData | ||
* Rejects the request if there is no form ID present in the request | ||
* or if the given Form ID/Api Key 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 requireChefsFormConfigData = (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 (!getChefsApiKey(params.formId as string)) { | ||
throw new Problem(501, { | ||
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,10 @@ | ||
export type ChefsFormConfig = { | ||
form1: ChefsFormConfigData; | ||
form2: ChefsFormConfigData; | ||
}; | ||
|
||
export type ChefsFormConfigData = { | ||
name: string; | ||
id: string; | ||
apiKey: string; | ||
}; |
Oops, something went wrong.