salix/back/methods/viaexpress-config/deleteExpeditionRenderer.js

45 lines
1.2 KiB
JavaScript
Raw Permalink Normal View History

const fs = require('fs');
const ejs = require('ejs');
module.exports = Self => {
2023-11-24 09:53:38 +00:00
Self.remoteMethod('deleteExpeditionRenderer', {
description: 'Renders the data from an XML',
accessType: 'READ',
accepts: [{
arg: 'expeditionFk',
type: 'number',
required: true
}],
returns: {
type: ['object'],
root: true
},
http: {
2023-11-24 09:53:38 +00:00
path: `/deleteExpeditionRenderer`,
verb: 'GET'
}
});
2023-11-24 09:53:38 +00:00
Self.deleteExpeditionRenderer = async expeditionFk => {
const models = Self.app.models;
const viaexpressConfig = await models.ViaexpressConfig.findOne({
fields: ['client', 'user', 'password']
});
const expedition = await models.Expedition.findOne({
fields: ['id', 'externalId'],
where: {id: expeditionFk}
});
const data = {
viaexpressConfig,
externalId: expedition.externalId
};
2023-11-24 09:53:38 +00:00
const template = fs.readFileSync(__dirname + '/deleteExpedition.ejs', 'utf-8');
const renderedXml = ejs.render(template, data);
return renderedXml;
};
};