Kaushik Narayan R a74ffc453e MASSIVE commit
- moved to typescript

- axios rate limitmodule is busted, removed for now, do something else for that

- sequelize-typescript

- dotenv, not dotenv-flow

- removed playlist details route

types for API

ton of minor fixes and improvements
2025-03-11 15:24:45 -07:00

36 lines
903 B
TypeScript

"use strict";
import { Sequelize } from "sequelize-typescript";
import seqConfig from "../config/sequelize.ts";
import links from "./links.ts";
import playlists from "./playlists.ts";
import curriedLogger from "../utils/logger.ts";
const logger = curriedLogger(import.meta.filename);
if (!process.env["NODE_ENV"])
throw new TypeError("Node environment not defined");
if (!process.env["DB_URI"])
throw new TypeError("Database connection URI not defined");
// Initialize
const config = seqConfig[process.env["NODE_ENV"]];
const seqConn: Sequelize = new Sequelize(process.env["DB_URI"], config);
// Check connection
(async () => {
try {
await seqConn.authenticate();
logger.info("Sequelize auth success");
} catch (error) {
logger.error("Sequelize auth error", { error });
throw error;
}
})();
// Load models
seqConn.addModels([links, playlists]);
export default seqConn;