Update config variables and add nodemailer's ones
This commit is contained in:
parent
f8af75d7d3
commit
2b4832a4f7
@ -1,7 +1,13 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
jwt_secret: process.env.JWT_SECRET,
|
// from '.env' in root folder
|
||||||
port: process.env.PORT || 3001,
|
port: process.env.PORT || 3001,
|
||||||
db_url: process.env.DATABASE_URL,
|
|
||||||
environment: process.env.NODE_ENV || 'development',
|
environment: process.env.NODE_ENV || 'development',
|
||||||
|
dbURL: process.env.DATABASE_URL,
|
||||||
|
jwtSecret: process.env.JWT_SECRET,
|
||||||
|
smtpHost: process.env.SMTP_HOST,
|
||||||
|
smtpPort: process.env.SMTP_PORT,
|
||||||
|
smtpUsername: process.env.SMTP_USERNAME,
|
||||||
|
smtpPassword: process.env.SMTP_PASSWORD,
|
||||||
|
// Others
|
||||||
saltingRounds: process.env.SALTING_ROUNDS || 10,
|
saltingRounds: process.env.SALTING_ROUNDS || 10,
|
||||||
};
|
};
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
const jwt = require('jsonwebtoken');
|
const jwt = require('jsonwebtoken');
|
||||||
const { jwt_secret } = require('../config/config');
|
const { jwtSecret } = require('../config/config');
|
||||||
|
|
||||||
function generateToken(user) {
|
function generateToken(user) {
|
||||||
const payload = {
|
const payload = {
|
||||||
@ -11,7 +11,7 @@ function generateToken(user) {
|
|||||||
expiresIn: '30d',
|
expiresIn: '30d',
|
||||||
};
|
};
|
||||||
|
|
||||||
return jwt.sign(payload, jwt_secret, options);
|
return jwt.sign(payload, jwtSecret, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.generateToken = generateToken;
|
exports.generateToken = generateToken;
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
require('dotenv').config();
|
require('dotenv').config();
|
||||||
const { db_url } = require('./config/config');
|
const { dbURL } = require('./config/config');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
development: {
|
development: {
|
||||||
client: 'pg',
|
client: 'pg',
|
||||||
connection: db_url,
|
connection: dbURL,
|
||||||
migrations: {
|
migrations: {
|
||||||
directory: './data/migrations',
|
directory: './data/migrations',
|
||||||
},
|
},
|
||||||
@ -14,7 +14,7 @@ module.exports = {
|
|||||||
|
|
||||||
testing: {
|
testing: {
|
||||||
client: 'pg',
|
client: 'pg',
|
||||||
connection: db_url,
|
connection: dbURL,
|
||||||
migrations: {
|
migrations: {
|
||||||
directory: './data/migrations',
|
directory: './data/migrations',
|
||||||
},
|
},
|
||||||
@ -24,7 +24,7 @@ module.exports = {
|
|||||||
|
|
||||||
production: {
|
production: {
|
||||||
client: 'pg',
|
client: 'pg',
|
||||||
connection: db_url,
|
connection: dbURL,
|
||||||
migrations: {
|
migrations: {
|
||||||
directory: './data/migrations',
|
directory: './data/migrations',
|
||||||
},
|
},
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
const jwt = require('jsonwebtoken');
|
const jwt = require('jsonwebtoken');
|
||||||
const { jwt_secret } = require('../config/config');
|
const { jwtSecret } = require('../config/config');
|
||||||
|
|
||||||
function authenticate(req, res, next) {
|
function authenticate(req, res, next) {
|
||||||
const token = req.get('Authorization');
|
const token = req.get('Authorization');
|
||||||
|
|
||||||
if (token) {
|
if (token) {
|
||||||
jwt.verify(token, jwt_secret, (err, decoded) => {
|
jwt.verify(token, jwtSecret, (err, decoded) => {
|
||||||
if (err) return res.status(401).json(err);
|
if (err) return res.status(401).json(err);
|
||||||
req.decoded = decoded;
|
req.decoded = decoded;
|
||||||
next();
|
next();
|
||||||
|
5
package-lock.json
generated
5
package-lock.json
generated
@ -1428,6 +1428,11 @@
|
|||||||
"resolved": "https://registry.npmjs.org/nocache/-/nocache-2.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/nocache/-/nocache-2.1.0.tgz",
|
||||||
"integrity": "sha512-0L9FvHG3nfnnmaEQPjT9xhfN4ISk0A8/2j4M37Np4mcDesJjHgEUfgPhdCyZuFI954tjokaIj/A3NdpFNdEh4Q=="
|
"integrity": "sha512-0L9FvHG3nfnnmaEQPjT9xhfN4ISk0A8/2j4M37Np4mcDesJjHgEUfgPhdCyZuFI954tjokaIj/A3NdpFNdEh4Q=="
|
||||||
},
|
},
|
||||||
|
"nodemailer": {
|
||||||
|
"version": "6.4.11",
|
||||||
|
"resolved": "https://registry.npmjs.org/nodemailer/-/nodemailer-6.4.11.tgz",
|
||||||
|
"integrity": "sha512-BVZBDi+aJV4O38rxsUh164Dk1NCqgh6Cm0rQSb9SK/DHGll/DrCMnycVDD7msJgZCnmVa8ASo8EZzR7jsgTukQ=="
|
||||||
|
},
|
||||||
"normalize-package-data": {
|
"normalize-package-data": {
|
||||||
"version": "2.5.0",
|
"version": "2.5.0",
|
||||||
"resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.5.0.tgz",
|
"resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.5.0.tgz",
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
"helmet": "^3.22.0",
|
"helmet": "^3.22.0",
|
||||||
"jsonwebtoken": "^8.5.1",
|
"jsonwebtoken": "^8.5.1",
|
||||||
"knex": "^0.21.1",
|
"knex": "^0.21.1",
|
||||||
|
"nodemailer": "^6.4.11",
|
||||||
"pg": "^8.0.3",
|
"pg": "^8.0.3",
|
||||||
"pgtools": "^0.3.0",
|
"pgtools": "^0.3.0",
|
||||||
"uuid": "^8.0.0"
|
"uuid": "^8.0.0"
|
||||||
|
Loading…
Reference in New Issue
Block a user