Skip to content

Commit

Permalink
BE #13 add env settings, connect to db, cleanup static files
Browse files Browse the repository at this point in the history
  • Loading branch information
tito433 committed May 14, 2020
1 parent b8eaf37 commit 49d2e88
Show file tree
Hide file tree
Showing 8 changed files with 645 additions and 30 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,4 @@ cache_temp/*
static_temp/*
.vscode
notice-config.js
package-lock.json
.env
22 changes: 18 additions & 4 deletions app.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,33 @@
var debug = require('debug')('cms-backend-api:*');
var express = require('express');
var path = require('path');
var cookieParser = require('cookie-parser');
var logger = require('morgan');
var mongoose=require('mongoose');

//custom modules
var indexRouter = require('./routes/index');
var usersRouter = require('./routes/users');

//connect to database
var connect = mongoose.connect(process.env.DB_URL,{
autoIndex: false,
useNewUrlParser: true,
useUnifiedTopology: true
});

connect.then((db) => {
debug('Connected to database ' + process.env.DB_URL);
}, (err) => { console.log(err); });



var app = express();

//middleware
app.use(logger('dev'));
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));

//routes
app.use('/', indexRouter);
app.use('/users', usersRouter);

Expand Down
4 changes: 3 additions & 1 deletion bin/www
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
/**
* Module dependencies.
*/
const dotenv = require('dotenv');
dotenv.config();

var app = require('../app');
var debug = require('debug')('cms-backend-api:server');
var debug = require('debug')('cms-backend-api:*');
var http = require('http');

/**
Expand Down
Loading

0 comments on commit 49d2e88

Please sign in to comment.