mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-09 17:33:55 +00:00
refactor: use strict typing
This commit is contained in:
@@ -25,10 +25,11 @@ export async function requestConnection(
|
||||
res: Response<{ verification_url: string; user_code: string } | ErrorResponse>,
|
||||
) {
|
||||
const { sheetId } = req.params;
|
||||
const file = req.file.path;
|
||||
// the check for the file is done in the validation middleware
|
||||
const filePath = (req.file as Express.Multer.File).path;
|
||||
|
||||
try {
|
||||
const client = readFileSync(file, 'utf-8');
|
||||
const client = readFileSync(filePath, 'utf-8');
|
||||
const clientSecret = handleClientSecret(client);
|
||||
const { verification_url, user_code } = await handleInitialConnection(clientSecret, sheetId);
|
||||
|
||||
@@ -40,7 +41,7 @@ export async function requestConnection(
|
||||
|
||||
// delete uploaded file after parsing
|
||||
try {
|
||||
deleteFile(file);
|
||||
await deleteFile(filePath);
|
||||
} catch (_error) {
|
||||
/** we dont handle failure here */
|
||||
}
|
||||
|
||||
@@ -16,6 +16,10 @@ export const validateRequestConnection = [
|
||||
(req: Request, res: Response, next: NextFunction) => {
|
||||
const errors = validationResult(req);
|
||||
if (!errors.isEmpty()) return res.status(422).json({ errors: errors.array() });
|
||||
// check that the file exists
|
||||
if (!req.file) {
|
||||
return res.status(422).json({ errors: 'File not found' });
|
||||
}
|
||||
next();
|
||||
},
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user