Skip to content

Commit

Permalink
Implemented option population.
Browse files Browse the repository at this point in the history
  • Loading branch information
NotTimTam committed Sep 12, 2024
1 parent bdb2eb4 commit c6e852a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
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.1",
"version": "1.2.2",
"description": "A headless, self-hostable, open-source file conversion express middleware.",
"main": "index.js",
"type": "module",
Expand Down
23 changes: 17 additions & 6 deletions util/Job.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,24 @@
import { v4 as uuid } from "uuid";
import Module from "./Module.js";
import FileConverter from "../index.js";

/**
* `new Job(fileConverter, files, module, options)`
*/
export default class Job {
/**
* A job utilizes a `Module` to convert and store files.
* @param {FileConverter} fileConverter The `FileConverter` instance this job should be associated with.
* @param {Array<Object>} files The multer file references for the files this job will convert.
* @param {Module} module The module that will be used to convert this job's files.
* @param {Object} options The request options configuration for the module.
*/
constructor(fileConverter, files, module, options) {
if (!module instanceof Module)
throw new Error(
`"module" value provided to Job constructor is not of type "Module".`
);

this.fileConverter = fileConverter;

this.fileConverter.jobs.push(this);
Expand All @@ -11,12 +27,7 @@ export default class Job {

this.files = files;
this.module = module;
this.options = options;

if (!module instanceof Module)
throw new Error(
`"module" value provided to Job constructor is not of type "Module".`
);
this.options = this.__populateOptions(options);

this.status = {
step: "pending",
Expand Down

0 comments on commit c6e852a

Please sign in to comment.