mirror of
https://github.com/20kaushik02/spotify-manager.git
synced 2025-12-06 10:54:07 +00:00
back to sequelize
This commit is contained in:
parent
b79170aafd
commit
6c497c9be1
@ -1,2 +1,7 @@
|
|||||||
REDIRECT_URI = http://localhost:9001/api/auth/callback
|
REDIRECT_URI = http://localhost:9001/api/auth/callback
|
||||||
TRUST_PROXY=1
|
TRUST_PROXY = 1
|
||||||
|
PG_USER = your_postgres_username
|
||||||
|
PG_PASSWD = your_postgres_password
|
||||||
|
PG_DATABASE = postgres_database_name
|
||||||
|
PG_HOST = localhost
|
||||||
|
PG_PORT = postgres_instance_port
|
||||||
|
|||||||
6
.sequelizerc
Normal file
6
.sequelizerc
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
require("dotenv-flow").config();
|
||||||
|
|
||||||
|
const path = require("path");
|
||||||
|
module.exports = {
|
||||||
|
"config": path.resolve("config", "sequelize.js")
|
||||||
|
};
|
||||||
33
config/sequelize.js
Normal file
33
config/sequelize.js
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
const logger = require("../utils/logger")(module);
|
||||||
|
|
||||||
|
let connConfigs = {
|
||||||
|
development: {
|
||||||
|
username: process.env.PG_USER,
|
||||||
|
password: process.env.PG_PASSWD,
|
||||||
|
database: process.env.PG_DATABASE,
|
||||||
|
host: process.env.PG_HOST,
|
||||||
|
port: process.env.PG_PORT,
|
||||||
|
},
|
||||||
|
test: {
|
||||||
|
username: process.env.PG_USER,
|
||||||
|
password: process.env.PG_PASSWD,
|
||||||
|
database: process.env.PG_DATABASE,
|
||||||
|
host: process.env.PG_HOST,
|
||||||
|
port: process.env.PG_PORT,
|
||||||
|
},
|
||||||
|
production: {
|
||||||
|
username: process.env.PG_USER,
|
||||||
|
password: process.env.PG_PASSWD,
|
||||||
|
database: process.env.PG_DATABASE,
|
||||||
|
host: process.env.PG_HOST,
|
||||||
|
port: process.env.PG_PORT,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
// common config
|
||||||
|
for (const conf in connConfigs) {
|
||||||
|
connConfigs[conf]['logging'] = (msg) => logger.debug(msg);
|
||||||
|
connConfigs[conf]['dialect'] = 'postgres';
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = connConfigs;
|
||||||
1176
package-lock.json
generated
1176
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -27,11 +27,14 @@
|
|||||||
"express-session": "^1.17.3",
|
"express-session": "^1.17.3",
|
||||||
"express-validator": "^7.0.1",
|
"express-validator": "^7.0.1",
|
||||||
"helmet": "^7.0.0",
|
"helmet": "^7.0.0",
|
||||||
|
"pg": "^8.12.0",
|
||||||
|
"sequelize": "^6.37.3",
|
||||||
"winston": "^3.10.0"
|
"winston": "^3.10.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/express": "^4.17.18",
|
"@types/express": "^4.17.18",
|
||||||
"cross-env": "^7.0.3",
|
"cross-env": "^7.0.3",
|
||||||
"nodemon": "^3.0.1"
|
"nodemon": "^3.0.1",
|
||||||
|
"sequelize-cli": "^6.6.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,7 +8,6 @@ const validator = require("../validators");
|
|||||||
router.get(
|
router.get(
|
||||||
"/me",
|
"/me",
|
||||||
isAuthenticated,
|
isAuthenticated,
|
||||||
validator.validate,
|
|
||||||
getUserPlaylists
|
getUserPlaylists
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@ -5,6 +5,10 @@
|
|||||||
* @typedef {import('express').Response} Res
|
* @typedef {import('express').Response} Res
|
||||||
* @typedef {import('express').NextFunction} Next
|
* @typedef {import('express').NextFunction} Next
|
||||||
*
|
*
|
||||||
|
* @typedef {import("sequelize").Sequelize} Sequelize
|
||||||
|
* @typedef {import("sequelize").Model} Model
|
||||||
|
* @typedef {import("sequelize").QueryInterface} QueryInterface
|
||||||
|
*
|
||||||
* @typedef {import('winston').Logger} Logger
|
* @typedef {import('winston').Logger} Logger
|
||||||
*
|
*
|
||||||
* @typedef {{
|
* @typedef {{
|
||||||
|
|||||||
@ -21,7 +21,7 @@ const axiosInstance = axios.default.create({
|
|||||||
});
|
});
|
||||||
|
|
||||||
axiosInstance.interceptors.request.use(request => {
|
axiosInstance.interceptors.request.use(request => {
|
||||||
logger.info("API call", {
|
logger.http("API call", {
|
||||||
url: request.url,
|
url: request.url,
|
||||||
method: request.method,
|
method: request.method,
|
||||||
params: request.params ?? {},
|
params: request.params ?? {},
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
const path = require("path");
|
const path = require("path");
|
||||||
|
|
||||||
const { createLogger, transports, config, format } = require('winston');
|
const { createLogger, transports, config, format } = require('winston');
|
||||||
const { combine, label, timestamp, printf, errors } = format;
|
const { colorize, combine, label, timestamp, printf, errors } = format;
|
||||||
|
|
||||||
const typedefs = require("../typedefs");
|
const typedefs = require("../typedefs");
|
||||||
|
|
||||||
@ -55,10 +55,8 @@ const logger = (callingModule) => {
|
|||||||
logFormat,
|
logFormat,
|
||||||
),
|
),
|
||||||
transports: [
|
transports: [
|
||||||
process.env.NODE_ENV !== 'production' ?
|
new transports.Console({ level: 'debug' }),
|
||||||
new transports.Console() :
|
new transports.File({ filename: __dirname + '/../logs/debug.log', level: 'debug' }),
|
||||||
new transports.Console(),
|
|
||||||
new transports.File({ filename: __dirname + '/../logs/common.log' }),
|
|
||||||
new transports.File({ filename: __dirname + '/../logs/error.log', level: 'error' }),
|
new transports.File({ filename: __dirname + '/../logs/error.log', level: 'error' }),
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user