Files
sharper.ly/apps/cms/src/bootstrap/index.ts
T
2026-09-11 02:46:56 +02:00

32 lines
1.3 KiB
TypeScript

import type { Core } from '@strapi/strapi';
import { revokePublicAuthActions } from './auth-permissions';
import { LOG_PREFIX } from './constants';
import { ensureLocales } from './locales';
import { ensurePublicPermissions } from './public-permissions';
export { revokePublicAuthActions } from './auth-permissions';
export { ensureLocales } from './locales';
export { ensurePublicPermissions } from './public-permissions';
/**
* Boot-time reconciliation, run from `src/index.ts`.
*
* Every step is idempotent: the first two only add what is missing, and the
* third only removes grants this site has decided it never wants. Running the
* lot on each boot - including on every hot reload in development - leaves an
* already-reconciled instance untouched.
*
* Runs after the plugin bootstraps, so the `en` locale and the Public role that
* Strapi creates on a fresh database already exist here - including the auth
* permissions users-permissions grants that role by default, which is exactly
* what the third step takes back.
*/
export const runBootstrap = async ({ strapi }: { strapi: Core.Strapi }): Promise<void> => {
await ensureLocales(strapi);
await ensurePublicPermissions(strapi);
await revokePublicAuthActions(strapi);
strapi.log.debug(`${LOG_PREFIX} bootstrap complete.`);
};