Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export async function clearAllTables(config: VendureConfig, logging = true) {
config = await preBootstrapConfig(config);
const entityIdStrategy = config.entityIdStrategy;
const connection = await createConnection({ ...config.dbConnectionOptions });
if (logging) {
console.log('Clearing all tables...');
}
try {
await connection.synchronize(true);
} catch (err) {
console.error('Error occurred when attempting to clear tables!');
console.error(err);
} finally {
await connection.close();
}
if (logging) {
console.log('Done!');
}
private async bootstrapForTesting(
userConfig: Partial,
): Promise<[INestApplication, INestMicroservice | undefined]> {
const config = await preBootstrapConfig(userConfig);
Logger.useLogger(config.logger);
const appModule = await import('@vendure/core/dist/app.module');
try {
DefaultLogger.hideNestBoostrapLogs();
const app = await NestFactory.create(appModule.AppModule, { cors: config.cors, logger: false });
let worker: INestMicroservice | undefined;
await app.listen(config.port);
if (config.workerOptions.runInMainProcess) {
const workerModule = await import('@vendure/core/dist/worker/worker.module');
worker = await NestFactory.createMicroservice(workerModule.WorkerModule, {
transport: config.workerOptions.transport,
logger: new Logger(),
options: config.workerOptions.options,
});
await worker.listenAsync();
}