|
1 éve | |
---|---|---|
.. | ||
README.md | 1 éve |
A loader is a function executed when the Medusa application starts.
To create a loader in your Medusa application, create a TypeScript or JavaScript file under the src/loaders
directory that default exports a function.
export default function () {
console.log(
"[HELLO LOADER] Just started the Medusa application!"
)
}
A loader receives the Medusa container as a first parameter, and the Medusa configuration as a second parameter.
import { MedusaContainer } from "@medusajs/medusa"
import { ConfigModule } from "@medusajs/types"
export default async function (
container: MedusaContainer,
config: ConfigModule
) {
console.log(`You have ${
Object.values(config.modules || {}).length
} modules!`)
}