Merge pull request #19931 from strapi/v5/facades

chore: cleanup public interface of strapi/strapi
This commit is contained in:
Alexandre BODIN 2024-03-27 10:22:09 +01:00 committed by GitHub
commit e78841e51a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
29 changed files with 89 additions and 98 deletions

View File

@ -9,7 +9,7 @@ const {
}, },
engine: { createTransferEngine }, engine: { createTransferEngine },
} = require('@strapi/data-transfer'); } = require('@strapi/data-transfer');
const { strapiFactory } = require('@strapi/strapi'); const { createStrapi, compileStrapi } = require('@strapi/strapi');
const path = require('path'); const path = require('path');
/** /**
@ -77,8 +77,8 @@ const createDestinationProvider = (datasetPath) => {
}; };
const createStrapiInstance = async (logLevel = 'error') => { const createStrapiInstance = async (logLevel = 'error') => {
const appContext = await strapiFactory.compile(); const appContext = await compileStrapi();
const app = strapiFactory(appContext); const app = createStrapi(appContext);
app.log.level = logLevel; app.log.level = logLevel;
return app.load(); return app.load();

View File

@ -7,7 +7,7 @@ const {
}, },
engine: { createTransferEngine }, engine: { createTransferEngine },
} = require('@strapi/data-transfer'); } = require('@strapi/data-transfer');
const { strapiFactory } = require('@strapi/strapi'); const { createStrapi, compileStrapi } = require('@strapi/strapi');
const { ALLOWED_CONTENT_TYPES } = require('../constants'); const { ALLOWED_CONTENT_TYPES } = require('../constants');
/** /**
@ -83,8 +83,8 @@ const createDestinationProvider = (filePath) =>
}); });
const createStrapiInstance = async (logLevel = 'error') => { const createStrapiInstance = async (logLevel = 'error') => {
const appContext = await strapiFactory.compile(); const appContext = await compileStrapi();
const app = strapiFactory(appContext); const app = createStrapi(appContext);
app.log.level = logLevel; app.log.level = logLevel;
const loadedApp = await app.load(); const loadedApp = await app.load();

View File

@ -42,7 +42,7 @@
"resources/" "resources/"
], ],
"scripts": { "scripts": {
"build": "run pack-up build && run copy-files", "build": "pack-up build && run copy-files",
"clean": "run -T rimraf ./dist", "clean": "run -T rimraf ./dist",
"copy-files": "copyfiles -u 1 -a 'src/**/*.html' 'src/**/*.png' dist", "copy-files": "copyfiles -u 1 -a 'src/**/*.html' 'src/**/*.png' dist",
"lint": "run -T eslint .", "lint": "run -T eslint .",

View File

@ -1,6 +1,3 @@
/* eslint-disable @typescript-eslint/no-namespace */
/* eslint-disable vars-on-top */
/* eslint-disable no-var */
import path from 'path'; import path from 'path';
import _ from 'lodash'; import _ from 'lodash';
import { isFunction } from 'lodash/fp'; import { isFunction } from 'lodash/fp';
@ -12,7 +9,6 @@ import type { Core, Modules, UID, Schema } from '@strapi/types';
import loadConfiguration from './configuration'; import loadConfiguration from './configuration';
import * as factories from './factories'; import * as factories from './factories';
import compile from './compile';
import * as utils from './utils'; import * as utils from './utils';
import * as registries from './registries'; import * as registries from './registries';
@ -625,25 +621,11 @@ class Strapi extends Container implements Core.Strapi {
} }
} }
interface StrapiOptions { export interface StrapiOptions {
appDir?: string; appDir?: string;
distDir?: string; distDir?: string;
autoReload?: boolean; autoReload?: boolean;
serveAdminPanel?: boolean; serveAdminPanel?: boolean;
} }
interface Init { export default Strapi;
(options?: StrapiOptions): Core.Strapi;
factories: typeof factories;
compile: typeof compile;
}
const initFn = (options: StrapiOptions = {}): Core.Strapi => {
const strapi = new Strapi(options);
global.strapi = strapi as LoadedStrapi;
return strapi;
};
const init: Init = Object.assign(initFn, { factories, compile });
export default init;

View File

@ -1,5 +1,15 @@
import strapiFactory from './Strapi'; import type { Core } from '@strapi/types';
import Strapi, { type StrapiOptions } from './Strapi';
export { default as compileStrapi } from './compile';
export * as factories from './factories'; export * as factories from './factories';
export { strapiFactory }; export const createStrapi = (options: StrapiOptions = {}): Core.Strapi => {
const strapi = new Strapi(options);
// TODO: deprecate and remove in next major
global.strapi = strapi as Core.LoadedStrapi;
return strapi;
};

View File

@ -24,7 +24,7 @@ const transaction = jest.fn(async (cb) => {
await cb({ trx, rollback }); await cb({ trx, rollback });
}); });
const strapiFactory = getStrapiFactory({ const createStrapi = getStrapiFactory({
dirs: { dirs: {
static: { static: {
public: 'static/public/assets', public: 'static/public/assets',
@ -57,7 +57,7 @@ describe('Local Strapi Destination Provider - Get Assets Stream', () => {
test('Returns a stream when assets restore is true', async () => { test('Returns a stream when assets restore is true', async () => {
const provider = createLocalStrapiDestinationProvider({ const provider = createLocalStrapiDestinationProvider({
getStrapi: () => strapiFactory(), getStrapi: () => createStrapi(),
strategy: 'restore', strategy: 'restore',
restore: { restore: {
assets: true, assets: true,
@ -72,7 +72,7 @@ describe('Local Strapi Destination Provider - Get Assets Stream', () => {
test('Throw an error if attempting to create stream while restore assets is false', async () => { test('Throw an error if attempting to create stream while restore assets is false', async () => {
const provider = createLocalStrapiDestinationProvider({ const provider = createLocalStrapiDestinationProvider({
getStrapi: () => strapiFactory(), getStrapi: () => createStrapi(),
strategy: 'restore', strategy: 'restore',
restore: { restore: {
assets: false, assets: false,
@ -96,7 +96,7 @@ describe('Local Strapi Destination Provider - Get Assets Stream', () => {
}; };
const provider = createLocalStrapiDestinationProvider({ const provider = createLocalStrapiDestinationProvider({
getStrapi: () => getStrapi: () =>
strapiFactory({ createStrapi({
dirs: { dirs: {
static: { static: {
public: assetsDirectory, public: assetsDirectory,

View File

@ -13,7 +13,9 @@ export default defineConfig({
}, },
{ {
source: './src/cli/index.ts', source: './src/cli/index.ts',
import: './dist/cli/index.ts',
require: './dist/cli/index.js', require: './dist/cli/index.js',
types: './dist/cli/index.d.ts',
runtime: 'node', runtime: 'node',
}, },
{ {

View File

@ -26,11 +26,10 @@ const mock = {
}; };
jest.mock('@strapi/core', () => { jest.mock('@strapi/core', () => {
const strapiFactory: any = jest.fn(() => mock); const createStrapi: any = jest.fn(() => mock);
const compileStrapi = jest.fn();
strapiFactory.compile = jest.fn(); return { createStrapi, compileStrapi };
return { strapiFactory };
}); });
describe('admin:create command', () => { describe('admin:create command', () => {

View File

@ -17,13 +17,11 @@ const mock = {
}; };
jest.mock('@strapi/core', () => { jest.mock('@strapi/core', () => {
const strapiFactory = jest.fn(() => mock); const createStrapi = jest.fn(() => mock);
Object.assign(strapiFactory, { const compileStrapi = jest.fn();
compile: jest.fn(),
});
return { strapiFactory }; return { createStrapi, compileStrapi };
}); });
describe('admin:reset-password command', () => { describe('admin:reset-password command', () => {

View File

@ -2,7 +2,7 @@ import { createCommand } from 'commander';
import { yup } from '@strapi/utils'; import { yup } from '@strapi/utils';
import _ from 'lodash'; import _ from 'lodash';
import inquirer from 'inquirer'; import inquirer from 'inquirer';
import { strapiFactory } from '@strapi/core'; import { createStrapi, compileStrapi } from '@strapi/core';
import { runAction } from '../../utils/helpers'; import { runAction } from '../../utils/helpers';
import type { StrapiCommand } from '../../types'; import type { StrapiCommand } from '../../types';
@ -73,8 +73,8 @@ const promptQuestions: inquirer.QuestionCollection<Answers> = [
]; ];
async function createAdmin({ email, password, firstname, lastname }: CmdOptions) { async function createAdmin({ email, password, firstname, lastname }: CmdOptions) {
const appContext = await strapiFactory.compile(); const appContext = await compileStrapi();
const app = await strapiFactory(appContext).load(); const app = await createStrapi(appContext).load();
const user = await app.admin.services.user.exists({ email }); const user = await app.admin.services.user.exists({ email });

View File

@ -1,7 +1,7 @@
import _ from 'lodash'; import _ from 'lodash';
import inquirer from 'inquirer'; import inquirer from 'inquirer';
import { createCommand } from 'commander'; import { createCommand } from 'commander';
import { strapiFactory } from '@strapi/core'; import { createStrapi, compileStrapi } from '@strapi/core';
import type { StrapiCommand } from '../../types'; import type { StrapiCommand } from '../../types';
import { runAction } from '../../utils/helpers'; import { runAction } from '../../utils/helpers';
@ -28,8 +28,8 @@ const promptQuestions: ReadonlyArray<inquirer.DistinctQuestion<Answers>> = [
]; ];
async function changePassword({ email, password }: CmdOptions) { async function changePassword({ email, password }: CmdOptions) {
const appContext = await strapiFactory.compile(); const appContext = await compileStrapi();
const app = await strapiFactory(appContext).load(); const app = await createStrapi(appContext).load();
await app.admin.services.user.resetPasswordByEmail(email, password); await app.admin.services.user.resetPasswordByEmail(email, password);

View File

@ -1,14 +1,14 @@
import { createCommand } from 'commander'; import { createCommand } from 'commander';
import CLITable from 'cli-table3'; import CLITable from 'cli-table3';
import chalk from 'chalk'; import chalk from 'chalk';
import { strapiFactory } from '@strapi/core'; import { createStrapi, compileStrapi } from '@strapi/core';
import type { StrapiCommand } from '../../types'; import type { StrapiCommand } from '../../types';
import { runAction } from '../../utils/helpers'; import { runAction } from '../../utils/helpers';
const action = async () => { const action = async () => {
const appContext = await strapiFactory.compile(); const appContext = await compileStrapi();
const app = await strapiFactory(appContext).register(); const app = await createStrapi(appContext).register();
const list = Object.keys(app.components); const list = Object.keys(app.components);

View File

@ -1,6 +1,6 @@
import fs from 'fs'; import fs from 'fs';
import { createCommand } from 'commander'; import { createCommand } from 'commander';
import { strapiFactory } from '@strapi/core'; import { createStrapi, compileStrapi } from '@strapi/core';
import type { StrapiCommand } from '../../types'; import type { StrapiCommand } from '../../types';
import { runAction } from '../../utils/helpers'; import { runAction } from '../../utils/helpers';
@ -32,8 +32,8 @@ const CHUNK_SIZE = 100;
const action = async ({ file: filePath, pretty }: CmdOptions) => { const action = async ({ file: filePath, pretty }: CmdOptions) => {
const output: Output = filePath ? fs.createWriteStream(filePath) : process.stdout; const output: Output = filePath ? fs.createWriteStream(filePath) : process.stdout;
const appContext = await strapiFactory.compile(); const appContext = await compileStrapi();
const app = await strapiFactory(appContext).load(); const app = await createStrapi(appContext).load();
const count = await app.query('strapi::core-store').count(); const count = await app.query('strapi::core-store').count();

View File

@ -1,7 +1,7 @@
import { createCommand } from 'commander'; import { createCommand } from 'commander';
import fs from 'fs'; import fs from 'fs';
import _ from 'lodash'; import _ from 'lodash';
import { strapiFactory } from '@strapi/core'; import { createStrapi, compileStrapi } from '@strapi/core';
import type { Database } from '@strapi/database'; import type { Database } from '@strapi/database';
import type { StrapiCommand } from '../../types'; import type { StrapiCommand } from '../../types';
@ -20,8 +20,8 @@ interface CmdOptions {
const action = async ({ file: filePath, strategy = 'replace' }: CmdOptions) => { const action = async ({ file: filePath, strategy = 'replace' }: CmdOptions) => {
const input = filePath ? fs.readFileSync(filePath) : await readStdin(); const input = filePath ? fs.readFileSync(filePath) : await readStdin();
const appContext = await strapiFactory.compile(); const appContext = await compileStrapi();
const app = await strapiFactory(appContext).load(); const app = await createStrapi(appContext).load();
let dataToImport; let dataToImport;
try { try {

View File

@ -1,13 +1,13 @@
import REPL from 'repl'; import REPL from 'repl';
import { createCommand } from 'commander'; import { createCommand } from 'commander';
import { strapiFactory } from '@strapi/core'; import { createStrapi, compileStrapi } from '@strapi/core';
import type { StrapiCommand } from '../types'; import type { StrapiCommand } from '../types';
import { runAction } from '../utils/helpers'; import { runAction } from '../utils/helpers';
const action = async () => { const action = async () => {
const appContext = await strapiFactory.compile(); const appContext = await compileStrapi();
const app = await strapiFactory(appContext).load(); const app = await createStrapi(appContext).load();
app.start().then(() => { app.start().then(() => {
const repl = REPL.start(app.config.info.name + ' > ' || 'strapi > '); // eslint-disable-line prefer-template const repl = REPL.start(app.config.info.name + ' > ' || 'strapi > '); // eslint-disable-line prefer-template

View File

@ -2,14 +2,14 @@ import { createCommand } from 'commander';
import CLITable from 'cli-table3'; import CLITable from 'cli-table3';
import chalk from 'chalk'; import chalk from 'chalk';
import { strapiFactory } from '@strapi/core'; import { createStrapi, compileStrapi } from '@strapi/core';
import type { StrapiCommand } from '../../types'; import type { StrapiCommand } from '../../types';
import { runAction } from '../../utils/helpers'; import { runAction } from '../../utils/helpers';
const action = async () => { const action = async () => {
const appContext = await strapiFactory.compile(); const appContext = await compileStrapi();
const app = await strapiFactory(appContext).register(); const app = await createStrapi(appContext).register();
const list = app.get('content-types').keys(); const list = app.get('content-types').keys();

View File

@ -2,14 +2,14 @@ import { createCommand } from 'commander';
import CLITable from 'cli-table3'; import CLITable from 'cli-table3';
import chalk from 'chalk'; import chalk from 'chalk';
import { strapiFactory } from '@strapi/core'; import { createStrapi, compileStrapi } from '@strapi/core';
import type { StrapiCommand } from '../../types'; import type { StrapiCommand } from '../../types';
import { runAction } from '../../utils/helpers'; import { runAction } from '../../utils/helpers';
const action = async () => { const action = async () => {
const appContext = await strapiFactory.compile(); const appContext = await compileStrapi();
const app = await strapiFactory(appContext).register(); const app = await createStrapi(appContext).register();
const list = app.get('controllers').keys(); const list = app.get('controllers').keys();

View File

@ -1,14 +1,14 @@
import { createCommand } from 'commander'; import { createCommand } from 'commander';
import CLITable from 'cli-table3'; import CLITable from 'cli-table3';
import chalk from 'chalk'; import chalk from 'chalk';
import { strapiFactory } from '@strapi/core'; import { createStrapi, compileStrapi } from '@strapi/core';
import type { StrapiCommand } from '../../types'; import type { StrapiCommand } from '../../types';
import { runAction } from '../../utils/helpers'; import { runAction } from '../../utils/helpers';
const action = async () => { const action = async () => {
const appContext = await strapiFactory.compile(); const appContext = await compileStrapi();
const app = await strapiFactory(appContext).register(); const app = await createStrapi(appContext).register();
const list = app.get('hooks').keys(); const list = app.get('hooks').keys();

View File

@ -1,14 +1,14 @@
import { createCommand } from 'commander'; import { createCommand } from 'commander';
import CLITable from 'cli-table3'; import CLITable from 'cli-table3';
import chalk from 'chalk'; import chalk from 'chalk';
import { strapiFactory } from '@strapi/core'; import { createStrapi, compileStrapi } from '@strapi/core';
import type { StrapiCommand } from '../../types'; import type { StrapiCommand } from '../../types';
import { runAction } from '../../utils/helpers'; import { runAction } from '../../utils/helpers';
const action = async () => { const action = async () => {
const appContext = await strapiFactory.compile(); const appContext = await compileStrapi();
const app = await strapiFactory(appContext).register(); const app = await createStrapi(appContext).register();
const list = app.get('middlewares').keys(); const list = app.get('middlewares').keys();

View File

@ -1,14 +1,14 @@
import { createCommand } from 'commander'; import { createCommand } from 'commander';
import CLITable from 'cli-table3'; import CLITable from 'cli-table3';
import chalk from 'chalk'; import chalk from 'chalk';
import { strapiFactory } from '@strapi/core'; import { createStrapi, compileStrapi } from '@strapi/core';
import type { StrapiCommand } from '../../types'; import type { StrapiCommand } from '../../types';
import { runAction } from '../../utils/helpers'; import { runAction } from '../../utils/helpers';
const action = async () => { const action = async () => {
const appContext = await strapiFactory.compile(); const appContext = await compileStrapi();
const app = await strapiFactory(appContext).register(); const app = await createStrapi(appContext).register();
const list = app.get('policies').keys(); const list = app.get('policies').keys();

View File

@ -1,6 +1,6 @@
import { createCommand } from 'commander'; import { createCommand } from 'commander';
import { EOL } from 'os'; import { EOL } from 'os';
import { strapiFactory } from '@strapi/core'; import { createStrapi, compileStrapi } from '@strapi/core';
import type { StrapiCommand } from '../types'; import type { StrapiCommand } from '../types';
import { runAction } from '../utils/helpers'; import { runAction } from '../utils/helpers';
@ -16,8 +16,8 @@ const action = async ({ uuid, dependencies, all }: CmdOptions) => {
reportDependencies: Boolean(all || dependencies), reportDependencies: Boolean(all || dependencies),
}; };
const appContext = await strapiFactory.compile(); const appContext = await compileStrapi();
const app = await strapiFactory(appContext).register(); const app = await createStrapi(appContext).register();
let debugInfo = `Launched In: ${Date.now() - app.config.launchedAt} ms let debugInfo = `Launched In: ${Date.now() - app.config.launchedAt} ms
Environment: ${app.config.environment} Environment: ${app.config.environment}

View File

@ -3,14 +3,14 @@ import CLITable from 'cli-table3';
import chalk from 'chalk'; import chalk from 'chalk';
import { toUpper } from 'lodash/fp'; import { toUpper } from 'lodash/fp';
import { strapiFactory } from '@strapi/core'; import { createStrapi, compileStrapi } from '@strapi/core';
import type { StrapiCommand } from '../../types'; import type { StrapiCommand } from '../../types';
import { runAction } from '../../utils/helpers'; import { runAction } from '../../utils/helpers';
const action = async () => { const action = async () => {
const appContext = await strapiFactory.compile(); const appContext = await compileStrapi();
const app = await strapiFactory(appContext).load(); const app = await createStrapi(appContext).load();
const list = app.server.mount().listRoutes(); const list = app.server.mount().listRoutes();

View File

@ -1,14 +1,14 @@
import { createCommand } from 'commander'; import { createCommand } from 'commander';
import CLITable from 'cli-table3'; import CLITable from 'cli-table3';
import chalk from 'chalk'; import chalk from 'chalk';
import { strapiFactory } from '@strapi/core'; import { createStrapi, compileStrapi } from '@strapi/core';
import type { StrapiCommand } from '../../types'; import type { StrapiCommand } from '../../types';
import { runAction } from '../../utils/helpers'; import { runAction } from '../../utils/helpers';
const action = async () => { const action = async () => {
const appContext = await strapiFactory.compile(); const appContext = await compileStrapi();
const app = await strapiFactory(appContext).register(); const app = await createStrapi(appContext).register();
const list = app.get('services').keys(); const list = app.get('services').keys();

View File

@ -1,7 +1,7 @@
import { createCommand } from 'commander'; import { createCommand } from 'commander';
import fs from 'fs'; import fs from 'fs';
import tsUtils from '@strapi/typescript-utils'; import tsUtils from '@strapi/typescript-utils';
import { strapiFactory } from '@strapi/core'; import { createStrapi } from '@strapi/core';
import type { StrapiCommand } from '../types'; import type { StrapiCommand } from '../types';
import { runAction } from '../utils/helpers'; import { runAction } from '../utils/helpers';
@ -20,7 +20,7 @@ const action = async () => {
`${outDir} directory not found. Please run the build command before starting your application` `${outDir} directory not found. Please run the build command before starting your application`
); );
strapiFactory({ appDir, distDir }).start(); createStrapi({ appDir, distDir }).start();
}; };
/** /**

View File

@ -1,6 +1,6 @@
import { createCommand } from 'commander'; import { createCommand } from 'commander';
import tsUtils from '@strapi/typescript-utils'; import tsUtils from '@strapi/typescript-utils';
import { strapiFactory } from '@strapi/core'; import { createStrapi, compileStrapi } from '@strapi/core';
import type { StrapiCommand } from '../../types'; import type { StrapiCommand } from '../../types';
import { runAction } from '../../utils/helpers'; import { runAction } from '../../utils/helpers';
@ -18,8 +18,8 @@ const action = async ({ debug, silent, verbose, outDir }: CmdOptions) => {
process.exit(1); process.exit(1);
} }
const appContext = await strapiFactory.compile({ ignoreDiagnostics: true }); const appContext = await compileStrapi({ ignoreDiagnostics: true });
const app = await strapiFactory(appContext).register(); const app = await createStrapi(appContext).register();
await tsUtils.generators.generate({ await tsUtils.generators.generate({
strapi: app, strapi: app,

View File

@ -2,7 +2,7 @@ import chalk from 'chalk';
import Table from 'cli-table3'; import Table from 'cli-table3';
import { Command, Option } from 'commander'; import { Command, Option } from 'commander';
import { configs, createLogger } from '@strapi/logger'; import { configs, createLogger } from '@strapi/logger';
import { strapiFactory } from '@strapi/core'; import { createStrapi, compileStrapi } from '@strapi/core';
import ora from 'ora'; import ora from 'ora';
import { merge } from 'lodash/fp'; import { merge } from 'lodash/fp';
import type { Core } from '@strapi/types'; import type { Core } from '@strapi/types';
@ -153,8 +153,8 @@ const createStrapiInstance = async (
opts: { logLevel?: string } = {} opts: { logLevel?: string } = {}
): Promise<Core.Strapi & Required<Core.Strapi>> => { ): Promise<Core.Strapi & Required<Core.Strapi>> => {
try { try {
const appContext = await strapiFactory.compile(); const appContext = await compileStrapi();
const app = strapiFactory({ ...opts, ...appContext }); const app = createStrapi({ ...opts, ...appContext });
app.log.level = opts.logLevel || 'error'; app.log.level = opts.logLevel || 'error';
return await app.load(); return await app.load();

View File

@ -2,7 +2,7 @@ import os from 'node:os';
import path from 'node:path'; import path from 'node:path';
import fs from 'node:fs/promises'; import fs from 'node:fs/promises';
import browserslist from 'browserslist'; import browserslist from 'browserslist';
import { strapiFactory } from '@strapi/core'; import { createStrapi } from '@strapi/core';
import { Core, Modules } from '@strapi/types'; import { Core, Modules } from '@strapi/types';
import type { CLIContext } from '../cli/types'; import type { CLIContext } from '../cli/types';
@ -66,7 +66,7 @@ const createBuildContext = async <TOptions extends BaseOptions>({
*/ */
const strapiInstance = const strapiInstance =
strapi ?? strapi ??
strapiFactory({ createStrapi({
// Directories // Directories
appDir: cwd, appDir: cwd,
distDir: tsconfig?.config.options.outDir ?? '', distDir: tsconfig?.config.options.outDir ?? '',

View File

@ -4,7 +4,7 @@ import chokidar from 'chokidar';
import fs from 'node:fs/promises'; import fs from 'node:fs/promises';
import path from 'node:path'; import path from 'node:path';
import cluster from 'node:cluster'; import cluster from 'node:cluster';
import { strapiFactory } from '@strapi/core'; import { createStrapi } from '@strapi/core';
import type { CLIContext } from '../cli/types'; import type { CLIContext } from '../cli/types';
import { checkRequiredDependencies } from './core/dependencies'; import { checkRequiredDependencies } from './core/dependencies';
@ -166,7 +166,7 @@ const develop = async ({
timer.start('loadStrapi'); timer.start('loadStrapi');
const loadStrapiSpinner = logger.spinner(`Loading Strapi`).start(); const loadStrapiSpinner = logger.spinner(`Loading Strapi`).start();
const strapi = strapiFactory({ const strapi = createStrapi({
appDir: cwd, appDir: cwd,
distDir: tsconfig?.config.options.outDir ?? '', distDir: tsconfig?.config.options.outDir ?? '',
autoReload: true, autoReload: true,

View File

@ -3,7 +3,7 @@
const path = require('path'); const path = require('path');
const _ = require('lodash'); const _ = require('lodash');
const dotenv = require('dotenv'); const dotenv = require('dotenv');
const { strapiFactory } = require('../../core/strapi'); const { createStrapi } = require('../../core/strapi');
const { createUtils } = require('./utils'); const { createUtils } = require('./utils');
const superAdminCredentials = { const superAdminCredentials = {
@ -30,7 +30,7 @@ const createStrapiInstance = async ({
appDir: baseDir, appDir: baseDir,
distDir: baseDir, distDir: baseDir,
}; };
const instance = strapiFactory(options); const instance = createStrapi(options);
if (bypassAuth) { if (bypassAuth) {
instance.get('auth').register('content-api', { instance.get('auth').register('content-api', {