Skip to content

Commit

Permalink
.env
Browse files Browse the repository at this point in the history
  • Loading branch information
o5faruk committed Oct 21, 2018
1 parent de39fc3 commit 05a5b44
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 6 deletions.
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
SECRET=SECRET
DB_STRING=mongodb://localhost/ibuapibackend
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
node_modules
config.js
.env
3 changes: 1 addition & 2 deletions api/services/token/create.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
const jwt = require('jsonwebtoken')
const config = require('../../../config')

module.exports = async (user) => {
const token = await jwt.sign(user, config.secret, {
const token = await jwt.sign(user, process.env.SECRET, {
expiresIn: 24 * 60 * 60
})
return token
Expand Down
3 changes: 1 addition & 2 deletions api/services/token/decode.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
const jwt = require('jsonwebtoken')
const config = require('../../../config')

module.exports = async (token) => {
let decoded = await jwt.verify(token, config.secret)
let decoded = await jwt.verify(token, process.env.SECRET)
return decoded
}
2 changes: 1 addition & 1 deletion app.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const express = require('express'),
bodyParser = require('body-parser'),
mongoose = require('mongoose')

mongoose.connect('mongodb://localhost/ibuapibackend', { useNewUrlParser: true })
mongoose.connect(process.env.DB_STRING, { useNewUrlParser: true })

app.use(express.json())

Expand Down

0 comments on commit 05a5b44

Please sign in to comment.