Signed-off-by: Alexandre Bodin <bodin.alex@gmail.com>
This commit is contained in:
Alexandre Bodin 2020-05-05 14:21:23 +02:00
parent 2b3d94d747
commit 34026fd88c
3 changed files with 39 additions and 6 deletions

View File

@ -205,6 +205,11 @@ program
.description('Starts the admin dev server')
.action(getLocalScript('watchAdmin'));
program
.command('configuration:dump')
.option('-f, --file <file>', 'file to output to')
.action(getLocalScript('configurationDump'));
/**
* Normalize help argument
*/

View File

@ -53,6 +53,7 @@ class Strapi {
this.admin = {};
this.plugins = {};
this.config = loadConfiguration(this.dir, opts);
this.isLoaded = false;
// internal services.
this.fs = createStrapiFs(this);
@ -127,12 +128,9 @@ class Strapi {
async start(cb) {
try {
await this.load();
// Run bootstrap function.
await this.runBootstrapFunctions();
// Freeze object.
await this.freeze();
if (!this.isLoaded) {
await this.load();
}
this.app.use(this.router.routes()).use(this.router.allowedMethods());
@ -236,6 +234,8 @@ class Strapi {
}
async load() {
this.isLoaded = true;
this.app.use(async (ctx, next) => {
if (ctx.request.url === '/_health' && ctx.request.method === 'HEAD') {
ctx.set('strapi', 'You are so French!');
@ -294,6 +294,9 @@ class Strapi {
// Initialize hooks and middlewares.
await initializeMiddlewares.call(this);
await initializeHooks.call(this);
await this.runBootstrapFunctions();
await this.freeze();
}
async startWebhooks() {

View File

@ -0,0 +1,25 @@
'use strict';
const fs = require('fs');
const { logger } = require('strapi-utils');
const loadConfiguration = require('../core/app-configuration');
const strapi = require('../index');
module.exports = async function({ file }) {
const output = file ? fs.createWriteStream(file) : process.stdout;
output.write('this is a test');
const app = strapi();
await app.load();
const confs = await app.query('core_store').find({
key_contains: 'plugin',
});
console.log(confs);
output.write('\n');
output.end();
};