gui-controller/modules/platforms/index.js
jmarchel bdd410672d Adding dockerfile
Change-Id: Iaa70ed769c7d693ff5172f4fd3204677e4834a8a
2024-02-26 21:50:27 +02:00

52 lines
1.3 KiB
JavaScript

const {v4: uuidv4} = require("uuid");
module.exports = {
extend: '@apostrophecms/piece-type',
options: {
label: 'Platform',
},
fields: {
add: {
uuid: {
type: 'string',
label: 'UUID',
required: false
}
},
group: {
basics: {
label: 'Basics',
fields: ['uuid']
}
}
},
handlers(self) {
return {
beforeSave: {
async generateUuid(req, doc) {
if (!doc.uuid) {
doc.uuid = uuidv4();
}
}
}
}
},
apiRoutes(self) {
return {
get: {
async all(req) {
const projection = {
title: 1,
uuid: 1,
};
try {
const platforms = await self.find(req).project(projection).toArray();
return platforms;
} catch (error) {
throw self.apos.error('notfound', 'Platforms not found');
}
}
}
}
}
};