Skip to content

Instantly share code, notes, and snippets.

@birendra-b
Created June 29, 2020 16:49
Show Gist options
  • Save birendra-b/02db794a13550fbec4fce674dd5f488d to your computer and use it in GitHub Desktop.
Save birendra-b/02db794a13550fbec4fce674dd5f488d to your computer and use it in GitHub Desktop.
src/db.ts with Redis initialization
import "reflect-metadata";
import {createConnection} from "typeorm";
import { Tedis} from "tedis";
// import {User} from "../entities/User";
import logger from '@shared/Logger';
async function intializeDB(): Promise<void> {
await createConnection()
logger.info('Database successfully initialized');
}
export function initializeCache(port: number | undefined) : unknown {
const tedis = new Tedis({
port: port,
host: "127.0.0.1"
});
logger.info('Redis cache successfully initialized');
return tedis;
}
// Export express instance
export default intializeDB;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment