This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const uppercaser = require('npm-medium-tutorial'); | |
console.log(uppercaser('hello medium!')); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = (message) => message.toUpperCase(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const mongoose = require('mongoose'); | |
const config = require('../config'); | |
mongoose.Promise = Promise; | |
mongoose.connect(config.mongo.uri, { useNewUrlParser: true }); | |
module.exports = mongoose; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports.mongo = { | |
uri: process.env.MONGOLAB_URI || 'mongodb://127.0.0.1:27017/herokuDeployment', | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const domain = process.env.DOMAIN || 'localhost'; | |
const port = process.env.PORT || 5000; | |
const protocol = process.env.PROTOCOL || 'http://'; | |
module.exports.domain = domain; | |
module.exports.port = port; | |
module.exports.protocol = protocol; | |
module.exports.serverUrl = process.env.SERVER_URL || `${protocol}${domain}${port ? `:${port}` : ''}`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const http = require('http'); | |
const config = require('./config'); | |
http.createServer((req, res) => { | |
res.write('Hello Heroku!'); | |
res.end(); | |
}).listen(config.port); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const mongoose = require('mongoose'); | |
const passport = require('passport'); | |
const router = require('express').Router(); | |
const auth = require('../auth'); | |
const Users = mongoose.model('Users'); | |
//POST new user route (optional, everyone has access) | |
router.post('/', auth.optional, (req, res, next) => { | |
const { body: { user } } = req; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require('express'); | |
const router = express.Router(); | |
router.use('/users', require('./users')); | |
module.exports = router; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require('express'); | |
const router = express.Router(); | |
router.use('/api', require('./api')); | |
module.exports = router; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const jwt = require('express-jwt'); | |
const getTokenFromHeaders = (req) => { | |
const { headers: { authorization } } = req; | |
if(authorization && authorization.split(' ')[0] === 'Token') { | |
return authorization.split(' ')[1]; | |
} | |
return null; | |
}; |
NewerOlder