mirror of
https://github.com/20kaushik02/spotify-manager.git
synced 2026-01-25 06:04:05 +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:
@@ -1,3 +0,0 @@
|
||||
// https://github.com/motdotla/dotenv/issues/133#issuecomment-255298822
|
||||
import DotenvFlow from "dotenv-flow";
|
||||
export default DotenvFlow.config();
|
||||
18
config/dotenv.ts
Normal file
18
config/dotenv.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
// https://github.com/motdotla/dotenv/issues/133#issuecomment-255298822
|
||||
// explanation: ESM import statements execute first
|
||||
// so the .config gets called after all other imports in index.ts
|
||||
// and one of those imports is the sequelize loader, which depends on env being loaded
|
||||
// soln: raise the priority of dotenv to match by placing it in a separate module like this
|
||||
|
||||
import { config, type DotenvConfigOutput } from "dotenv";
|
||||
|
||||
const result: DotenvConfigOutput = config({
|
||||
path: [
|
||||
`.env.${process.env["NODE_ENV"]}.local`,
|
||||
`.env.${process.env["NODE_ENV"]}`,
|
||||
".env.local",
|
||||
".env",
|
||||
],
|
||||
});
|
||||
|
||||
export default result;
|
||||
@@ -1,29 +0,0 @@
|
||||
import curriedLogger from "../utils/logger.js";
|
||||
const logger = curriedLogger(import.meta);
|
||||
|
||||
const connConfigs = {
|
||||
development: {
|
||||
username: process.env.DB_USER || "postgres",
|
||||
password: process.env.DB_PASSWD || "",
|
||||
database: process.env.DB_NAME || "postgres",
|
||||
host: process.env.DB_HOST || "127.0.0.1",
|
||||
port: process.env.DB_PORT || 5432,
|
||||
},
|
||||
test: {
|
||||
use_env_variable: "DB_URL", // use connection string for non-dev env
|
||||
},
|
||||
production: {
|
||||
use_env_variable: "DB_URL", // use connection string for non-dev env
|
||||
// dialectOptions: {
|
||||
// ssl: true,
|
||||
// },
|
||||
}
|
||||
}
|
||||
|
||||
// common config
|
||||
for (const conf in connConfigs) {
|
||||
connConfigs[conf]["logging"] = (msg) => logger.debug(msg);
|
||||
connConfigs[conf]["dialect"] = process.env.DB_DIALECT || "postgres";
|
||||
}
|
||||
|
||||
export default connConfigs;
|
||||
25
config/sequelize.ts
Normal file
25
config/sequelize.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import type { SequelizeOptions } from "sequelize-typescript";
|
||||
|
||||
import curriedLogger from "../utils/logger.ts";
|
||||
const logger = curriedLogger(import.meta.filename);
|
||||
|
||||
type ConnConfigs = Record<string, SequelizeOptions>;
|
||||
|
||||
// env-specific config
|
||||
const connConfigs: ConnConfigs = {
|
||||
development: {},
|
||||
test: {},
|
||||
production: {
|
||||
// dialectOptions: {
|
||||
// ssl: true,
|
||||
// },
|
||||
},
|
||||
};
|
||||
|
||||
// common config
|
||||
for (const conf in connConfigs) {
|
||||
connConfigs[conf]!.logging = (msg: any) => logger.debug(msg);
|
||||
connConfigs[conf]!.dialect = "postgres";
|
||||
}
|
||||
|
||||
export default connConfigs;
|
||||
Reference in New Issue
Block a user