From 1dab2bd46ebcad354f1dda19da2821d348c4b2fa Mon Sep 17 00:00:00 2001 From: David Jimenez Date: Sat, 3 Oct 2015 13:32:53 -0700 Subject: [PATCH] initial commit --- client/index.html | 19 +++++++++++++++++++ config/mongoose.js | 12 ++++++++++++ config/routes.js | 7 +++++++ package.json | 9 +++++++++ server.js | 17 +++++++++++++++++ server/controllers/controlller.js | 9 +++++++++ server/models/model.js | 10 ++++++++++ 7 files changed, 83 insertions(+) create mode 100644 client/index.html create mode 100644 config/mongoose.js create mode 100644 config/routes.js create mode 100644 package.json create mode 100644 server.js create mode 100644 server/controllers/controlller.js create mode 100644 server/models/model.js diff --git a/client/index.html b/client/index.html new file mode 100644 index 0000000..1ce600f --- /dev/null +++ b/client/index.html @@ -0,0 +1,19 @@ + + + + + + + + + + + + + +
+
+ + diff --git a/config/mongoose.js b/config/mongoose.js new file mode 100644 index 0000000..213ce70 --- /dev/null +++ b/config/mongoose.js @@ -0,0 +1,12 @@ +var mongoose = require('mongoose'); +var fs = require('fs'); + +mongoose.connect('mongodb://localhost/saburiKonnect'); + +var modelsPath = __dirname + '/../server/models'; + +fs.readdirSync(modelsPath).forEach(function(file){ + if (file.indexOf('.js') > 0){ + require(modelsPath + '/' + file); + } +}); \ No newline at end of file diff --git a/config/routes.js b/config/routes.js new file mode 100644 index 0000000..979cb88 --- /dev/null +++ b/config/routes.js @@ -0,0 +1,7 @@ +var Controller = require('./../server/controllers/controller.js'); + +module.exports = function(app){ + app.post('/user/show', function(req, res){ + Controller.show(req, res); + }) +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..fb08a9e --- /dev/null +++ b/package.json @@ -0,0 +1,9 @@ +{ + "name": "saburiKonnect", + "version": "0.0.1", + "dependencies": { + "body-parser": "latest", + "express": "^4.10.0", + "mongoose": "^4.0.1", + } +} diff --git a/server.js b/server.js new file mode 100644 index 0000000..a689a15 --- /dev/null +++ b/server.js @@ -0,0 +1,17 @@ +var express = require('express'); +var app = express(); +var path = require('path'); +var bodyParser = require('body-parser'); + +app.use(bodyParser.urlencoded({ + extended: true +})); +app.use(bodyParser.json()); +app.use(express.static(path.join(__dirname, './client'))); + +// require('./config/mongoose.js'); +// require('./config/routes.js')(app); + +app.listen(8000, function(){ + console.log('listening on port 8000'); +}) diff --git a/server/controllers/controlller.js b/server/controllers/controlller.js new file mode 100644 index 0000000..dcb1e66 --- /dev/null +++ b/server/controllers/controlller.js @@ -0,0 +1,9 @@ +var mongoose = require('mongoose'); +// var Model = mongoose.Model('Model') + +module.exports = (function(){ + return { + add: function(req, res){ + //code + } +})(); diff --git a/server/models/model.js b/server/models/model.js new file mode 100644 index 0000000..49c5c63 --- /dev/null +++ b/server/models/model.js @@ -0,0 +1,10 @@ +var mongoose = require('mongoose'); + +var modelSchema = new mongoose.Schema({ + title: String, + description: String, + name: String, + checked: {type: Boolean, default: false} +}); + +mongoose.model('Model', modelSchema);