typeorm#getConnectionOptions TypeScript Examples

The following examples show how to use typeorm#getConnectionOptions. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: typeormLoader.ts    From spurtcommerce with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
typeormLoader: MicroframeworkLoader = async (settings: MicroframeworkSettings | undefined) => {

    const loadedConnectionOptions = await getConnectionOptions();

    const connectionOptions = Object.assign(loadedConnectionOptions, {
        type: env.db.type as any, // See createConnection options for valid types
        host: env.db.host,
        port: env.db.port,
        username: env.db.username,
        password: env.db.password,
        database: env.db.database,
        synchronize: env.db.synchronize,
        logging: true,
        logger: 'advanced-console',
        entities: env.app.dirs.entities,
        migrations: env.app.dirs.migrations,
    });

    const connection = await createConnection(connectionOptions);

    await connection.runMigrations();

    if (settings) {
        settings.setData('connection', connection);
        settings.onShutdown(() => connection.close());
    }
}