mirror of
https://github.com/20kaushik02/spotify-manager.git
synced 2026-01-25 14:14:06 +00:00
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
This commit is contained in:
35
models/index.ts
Normal file
35
models/index.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
"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;
|
||||
Reference in New Issue
Block a user