Skip to content

Instantly share code, notes, and snippets.

@schoettker
Created August 27, 2017 07:19
Show Gist options
  • Select an option

  • Save schoettker/9be4c62db63536d0b5a13acd33521113 to your computer and use it in GitHub Desktop.

Select an option

Save schoettker/9be4c62db63536d0b5a13acd33521113 to your computer and use it in GitHub Desktop.
const express = require('express');
const app = express();
// const path = require('path');
// const config = require('./config').config; Configuration
// const routes = require('./routes'); Routes
// Common Middleware uncomment and npm install when required
// const cors = require('cors');
// const bodyparser = require('body-parser');
// const mongoose = require('mongoose');
// mongoose.connect(config.mongoAddress, { useMongoClient: true });
// mongoose.connection.on('connected', () => { console.log(`Connected to database on ${config.mongoAddress}`); });
// mongoose.connection.on('error', (err) => { console.log(`Database error: ${err} while trying to connect on ${config.mongoAddress}`);});
// const passport = require('passport');
// app.use(passport.initialize());
// config.passportStrategy(passport);
// app.use(bodyparser.json());
// app.use(cors());
// Set Static Folder
app.use(express.static(path.join(__dirname, 'public')));
app.get('/', function (req, res) { // let frontend handle client side routing
res.sendFile(path.join(__dirname, 'public', 'index.html'));
});
// Use Routes
app.use('/api', routes);
app.listen(config.port, () => {
console.log(`Server running on port ${port}`);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment