salix/modules/mdb/back/methods/mdbVersion/upload.js

51 lines
1.3 KiB
JavaScript
Raw Normal View History

2022-05-25 12:59:28 +00:00
module.exports = Self => {
Self.remoteMethodCtx('upload', {
description: 'Returns a list of tag values',
accepts: [
{
arg: 'appName',
type: 'string',
required: true,
description: 'The app name'
},
{
arg: 'newVersion',
type: 'number',
required: true,
description: `The new version number`
},
{
arg: 'branch',
type: 'string',
required: true,
description: `The branch name`
}
],
returns: {
type: ['object'],
root: true
},
http: {
path: `/upload`,
verb: 'POST'
}
});
Self.upload = async(ctx, appName, newVersion, branch, options) => {
const models = Self.app.models;
const myOptions = {};
const moduleFile = ctx.req;
if (!moduleFile) return;
if (typeof options == 'object')
Object.assign(myOptions, options);
const newMdb = await models.mdbVersion.create({
app: appName,
version: newVersion,
branchFk: branch
}, myOptions);
};
};