mirror of
https://github.com/FranP-code/shortly.git
synced 2025-10-13 00:43:28 +00:00
first working prototype of shortly
This commit is contained in:
19
src/scripts/checkMissingData.ts
Normal file
19
src/scripts/checkMissingData.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import { Request } from 'express'
|
||||
|
||||
export default function (values: string[], req: Request) {
|
||||
const missingData = values.reduce((arr: string[], valueName) => {
|
||||
if (!req.headers[valueName]) {
|
||||
return [...arr, valueName]
|
||||
} else {
|
||||
return arr
|
||||
}
|
||||
}, [])
|
||||
if (missingData.length) {
|
||||
throw new Error(
|
||||
JSON.stringify({
|
||||
mesasage: 'no data from user',
|
||||
properties: missingData,
|
||||
})
|
||||
)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user