initial done

This commit is contained in:
2017-08-29 16:11:45 +02:00
parent 6f98b217ac
commit 27461dd3f5
10 changed files with 101 additions and 68 deletions

18
shrt.js
View File

@@ -1,8 +1,6 @@
const Hapi = require('hapi');
const server = new Hapi.Server();
const routes = require('./routes');
const mongoose = require('mongoose');
const mongoUri = process.env.MONGOURI || 'mongodb://localhost/shortio';
const options = {
server: {
@@ -12,23 +10,17 @@ const options = {
socketOptions: { keepAlive: 300000, connectTimeoutMS : 30000 }
}
};
mongoose.connect(mongoUri, options);
const db = mongoose.connection;
server.connection({
port: process.env.PORT || 3000,
routes: { cors: true }
});
server.register(require('inert'), (err) => {
db.on('error', console.error.bind(console, 'connection error:'))
.once('open', () => {
server.route(routes);
server.route(routes);
server.start(err => {
if (err) throw err;
server.start(err => {
if (err) throw err;
console.log(`Server running at port ${server.info.port}`);
});
});
console.log(`Server running at port ${server.info.port}`);
});
});