feat(medusa): Modules initializer (#3352)

This commit is contained in:
Carlos R. L. Rodrigues
2023-03-17 12:18:52 -03:00
committed by GitHub
parent 8a7421db5b
commit aa690beed7
51 changed files with 1290 additions and 715 deletions

View File

@@ -36,7 +36,7 @@ export async function loadInternalModule(
return {
error: new Error(
"No service found in module. Make sure your module exports at least one service."
"No service found in module. Make sure your module exports a service."
),
}
}
@@ -112,3 +112,15 @@ export async function loadInternalModule(
"module"
)
}
export async function loadModuleMigrations(
resolution: ModuleResolution
): Promise<[Function | undefined, Function | undefined]> {
let loadedModule: ModuleExports
try {
loadedModule = (await import(resolution.resolutionPath as string)).default
return [loadedModule.runMigrations, loadedModule.revertMigration]
} catch {
return [undefined, undefined]
}
}