@rsc-labs/medusa-documents
Version:
Generate documents from Medusa
44 lines (43 loc) • 1.36 kB
JavaScript
;
/*
* Copyright 2024 RSC-Labs, https://rsoftcon.com/
*
* MIT License
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.GET = exports.POST = void 0;
const POST = async (req, res) => {
const invoiceService = req.scope.resolve('invoiceService');
try {
const body = req.body;
const result = await invoiceService.generateInvoiceForOrder(body.orderId);
res.status(201).json(result);
}
catch (e) {
res.status(400).json({
message: e.message
});
}
};
exports.POST = POST;
const GET = async (req, res) => {
const invoiceService = req.scope.resolve('invoiceService');
const invoiceId = req.query.invoiceId;
const includeBuffer = req.query.includeBuffer;
try {
const result = await invoiceService.getInvoice(invoiceId, includeBuffer !== undefined);
res.status(200).json(result);
}
catch (e) {
res.status(400).json({
message: e.message
});
}
};
exports.GET = GET;