Skip to content

Commit

Permalink
fix DB_CA_SSL certificate usage
Browse files Browse the repository at this point in the history
  • Loading branch information
leovergaramarq committed Jun 7, 2024
1 parent 38eaaa4 commit 723424c
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/config/index.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const API_GATEWAY_URL = process.env.API_GATEWAY_URL || 'http://localhost:
// db
export const DB_HOST = process.env.DB_HOST || 'localhost';
export const DB_PORT = process.env.DB_PORT || 3306;
export const DB_SSL_CA = NODE_ENV === 'production' ? Buffer.from(process.env.DB_SSL_CA, 'base64').toString('ascii') : undefined;
export const DB_SSL_CA = NODE_ENV === 'production' && process.env.DB_SSL_CA ? Buffer.from(process.env.DB_SSL_CA, 'base64').toString('ascii') : undefined;
export const DB_USER = process.env.DB_USER || 'api';
export const DB_PASSWORD = process.env.DB_PASSWORD || 'secret';
export const DB_PAIDIFY_SCHEMA = process.env.DB_PAIDIFY_SCHEMA || 'paidify';
Expand Down
1 change: 1 addition & 0 deletions src/gateway/payment.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ router.post('/', async (req, res) => {
try {
token = jwt.verify(auth.split(' ')[1], JWT_SECRET);
} catch (err) {}
if(!token) return res.status(401).json({ message: 'Invalid token' });
if (token.role !== ROLE_DEFAULT) {
return res.status(401).json({ message: 'You are not authorized to perform this action' });
}
Expand Down
2 changes: 1 addition & 1 deletion src/services/dbPaidify.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
const pool = createPool({
port: DB_PORT,
host: DB_HOST,
ssl: NODE_ENV === 'production' ? { ca: DB_SSL_CA } : undefined,
ssl: NODE_ENV === 'production' && DB_SSL_CA ? { ca: DB_SSL_CA } : undefined,
user: DB_USER,
password: DB_PASSWORD,
database: DB_PAIDIFY_SCHEMA,
Expand Down
2 changes: 1 addition & 1 deletion src/services/dbUniv.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
const pool = createPool({
port: DB_PORT,
host: DB_HOST,
ssl: NODE_ENV === 'production' ? { ca: DB_SSL_CA } : undefined,
ssl: NODE_ENV === 'production' && DB_SSL_CA ? { ca: DB_SSL_CA } : undefined,
user: DB_USER,
password: DB_PASSWORD,
database: DB_UNIV_SCHEMA,
Expand Down

0 comments on commit 723424c

Please sign in to comment.