Created
June 29, 2020 16:49
-
-
Save birendra-b/02db794a13550fbec4fce674dd5f488d to your computer and use it in GitHub Desktop.
src/db.ts with Redis initialization
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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