app.js 887 Bytes
var express = require('express');
var app = express();
var bodyParser = require('body-parser');
//var session = require('express-session');
var mongoose = require('mongoose');

//DB연결
mongoose.connect('mongodb://username:pwd@1.201.139.92/dbname');
var db = mongoose.connection;

//연결실패
db.on('error', function()
{
    console.log('Connection Failed!');
});

//연결 성공
db.once('open', function()
{
    console.log('Connected!');
});


// DB모델정의
var Users = require('./models/users');

// ejs사용
// json사용설정
app.set('view engine','ejs');
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended: true}));

// router import
var router = require('./routing')(app, Users);

var server = app.listen(23023, function()
{
    var host = server.address().address;
    var port = server.address().port;
    console.log("http://%s:%s",host, port);
});