Skip to content

Commit

Permalink
Bugfix.
Browse files Browse the repository at this point in the history
  • Loading branch information
NotTimTam committed Sep 13, 2024
1 parent fa2ac48 commit 4a64157
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 17 deletions.
33 changes: 17 additions & 16 deletions controllers/convert.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,20 +88,21 @@ export const convert = async (req, res) => {

const parsedOptions = options && JSON.parse(options);

for (const { label, required } of moduleObject.options) {
// If a value is required, but none is provided
if (
required &&
(!parsedOptions.hasOwnProperty(label) ||
parsedOptions[label] === undefined ||
parsedOptions[label] === null)
)
return res
.status(400)
.send(
`The "${moduleObject.label}" module requires a value for the option "${label}", but none was provided.`
);
}
if (moduleObject.options)
for (const { label, required } of moduleObject.options) {
// If a value is required, but none is provided
if (
required &&
(!parsedOptions.hasOwnProperty(label) ||
parsedOptions[label] === undefined ||
parsedOptions[label] === null)
)
return res
.status(400)
.send(
`The "${moduleObject.label}" module requires a value for the option "${label}", but none was provided.`
);
}

if (parsedOptions) {
for (const [option, value] of Object.entries(parsedOptions)) {
Expand Down Expand Up @@ -138,9 +139,9 @@ export const convert = async (req, res) => {

const job = fileConverter.createJob(files, moduleObject, parsedOptions);

job.run(); // Start the job asynchronously without awaiting it.
res.status(200).send({ jobId: job._id });

return res.status(200).send({ jobId: job._id });
job.run(); // Start the job asynchronously without awaiting it.
} catch (err) {
return await unlinkAndGo(req.files, () => handleError(res, err));
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nottimtam/file-converter",
"version": "1.2.5",
"version": "1.2.6",
"description": "A headless, self-hostable, open-source file conversion express middleware.",
"main": "index.js",
"type": "module",
Expand Down

0 comments on commit 4a64157

Please sign in to comment.