2017-09-14 15:10:08 +02:00

40 lines
912 B
JavaScript
Executable File

'use strict';
const fs = require('fs');
const path = require('path');
/**
* A set of functions called "actions" for `Admin`
*/
module.exports = {
index: async(ctx) => {
try {
// Send the HTML file with injected scripts
ctx.body = strapi.admin.services.admin.generateAdminIndexFile();
} catch (err) {
ctx.body = err;
}
},
pluginFile: async ctx => {
try {
const file = fs.readFileSync(path.resolve(process.cwd(), 'plugins', ctx.params.plugin, 'admin', 'build', 'main.js'));
ctx.body = file;
} catch (err) {
ctx.body = ctx.notFound();
}
},
file: async ctx => {
try {
const file = fs.readFileSync(path.resolve(__dirname, '..', 'admin', 'build', ctx.params.file));
ctx.body = file;
} catch (err) {
// Fallback, render admin page
ctx.body = strapi.admin.services.admin.generateAdminIndexFile();
}
}
};