add initial server

This commit is contained in:
Francesco Esposito 2019-02-19 18:56:25 +01:00
parent b0232abd63
commit cdcf6472ee
1 changed files with 24 additions and 0 deletions

24
server.js Normal file
View File

@ -0,0 +1,24 @@
const express = require('express');
const mongoose = require('mongoose');
const bodyParser = require('body-parser');
const config = require('./config');
const { db } = config;
const app = express();
const port = process.env.PORT || config.app.port;
const connectionString = `${db.prefix}${db.user}:${db.password}@${db.host}/${db.database}`;
console.log(connectionString);
mongoose.connect(connectionString, { useNewUrlParser: true });
mongoose.set('useFindAndModify', false);
const mongodb = mongoose.connection;
app.use(bodyParser.urlencoded({ extended: true}));
app.use(bodyParser.json());
app.listen(port, () => {
console.log(`trackmyd-api running. PORT: ${port}`);
});