fix plugin name in service

dev
Shahriar 2024-01-19 18:02:06 +03:30
parent ae26b28238
commit 189c8f55c6
2 changed files with 19 additions and 26 deletions

View File

@ -1,28 +1,11 @@
// "use strict";
// module.exports = ({ strapi }) => ({
// getContentTypes(ctx) {
// const data = strapi
// .plugin("content-type-explorer")
// .service("explorerService")
// .getContentTypes();
// let neededData = Object.keys(data).map((key) => ({
// name: key,
// attributes: data[key]["attributes"],
// info: data[key]["info"],
// // kind: data[key]["kind"],
// key: data[key]["uid"],
// }));
// ctx.body = neededData;
// },
// });
"use strict";
module.exports = {
module.exports = ({ strapi }) => ({
async getTypes(ctx) {
ctx.body = "You are in the my-plugin-content-type controller!";
const contentTypes = await strapi
.service("plugin::strapi-content-type-explorer.explorerService")
.getContentTypes();
ctx.body = contentTypes;
},
};
});

View File

@ -1,7 +1,17 @@
"use strict";
module.exports = ({ strapi }) => ({
getContentTypes() {
return strapi.contentTypes;
async getContentTypes() {
const types = strapi.contentTypes;
let formattedTypes = Object.keys(types).map((key) => ({
name: key,
attributes: types[key]["attributes"],
info: types[key]["info"],
// kind: data[key]["kind"],
key: types[key]["uid"],
}));
return formattedTypes;
},
});