Skip to content

Commit

Permalink
Refactored db url with a view to making this repo work locally or dep…
Browse files Browse the repository at this point in the history
…loyed from the same branch
  • Loading branch information
pablisch committed Jan 15, 2024
1 parent 47cbec8 commit a30fd9c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
6 changes: 4 additions & 2 deletions api/bin/www
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@ app.set("port", port);
/**
* Connect to MongoDB
**/

var mongoDbUrl = process.env.MONGODB_URL || "mongodb://0.0.0.0/acebook";
const dbUser = process.env.DB_USER;
const dbPassword = process.env.DB_PW;
const dbName = process.env.DB_NAME || 'farcebook';
var mongoDbUrl = `mongodb+srv://${dbUser}:${dbPassword}@cluster0.8rfjmug.mongodb.net/${dbName}?retryWrites=true&w=majority`;
mongoose.connect(mongoDbUrl, {
useNewUrlParser: true,
useUnifiedTopology: true,
Expand Down
5 changes: 3 additions & 2 deletions api/models/token_generator.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const JWT = require("jsonwebtoken");
require('dotenv').config()
const secret = process.env.JWT_SECRET;

class TokenGenerator {
Expand All @@ -7,8 +8,8 @@ class TokenGenerator {
user_id: user_id,
iat: Math.floor(Date.now() / 1000),

// Set the JWT token to expire in 10 minutes
exp: Math.floor(Date.now() / 1000) + (30 * 60) // REAL LINE
// Set the JWT token to expire in 30 minutes
exp: Math.floor(Date.now() / 1000) + (30 * 60)
}, secret);
}
}
Expand Down

0 comments on commit a30fd9c

Please sign in to comment.