Permalink
Browse files

Added an index page for more visual confirmation everything works

  • Loading branch information...
1 parent e33e99f commit 1770bc86f71043c9623a8012dd126afb0228caf3 @tdegrunt committed Oct 3, 2010
Showing with 62 additions and 23 deletions.
  1. +1 −1 config.json
  2. +13 −2 lib/main.js
  3. BIN public/favicon.ico
  4. BIN public/images/logo.png
  5. +21 −0 public/stylesheets/style.css
  6. +15 −20 server.js
  7. +3 −0 views/index.jade
  8. +9 −0 views/layout.jade
View
@@ -8,5 +8,5 @@
"address": "0.0.0.0"
},
"flavor": "sproutcore",
- "debug": false
+ "debug": true
}
View
@@ -1,5 +1,16 @@
-var app = module.parent.exports.app;
+var mongo = require("mongodb"),
+ app = module.parent.exports.app,
+ config = module.parent.exports.config,
+ util = require("./util");
app.get('/', function(req, res){
- res.send('index');
+ if(config.debug == true) {
+ res.render('index', {
+ locals: {
+ config: config,
+ }
+ });
+ } else {
+ res.send();
+ }
});
View
Binary file not shown.
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -0,0 +1,21 @@
+body {
+ margin: 0;
+ padding: 0;
+ border: none;
+ background-color: #f3f4eb;
+ font-family: helvetica, arial, sans-serif;
+ color: #4c3a2c;
+}
+
+#header {
+ height: 126px;
+ background-color: #402817;
+}
+
+#content {
+ margin: 10px;
+}
+
+h1 {
+ margin: 0px;
+}
View
@@ -11,7 +11,7 @@ var fs = require("fs"),
sys = require("sys"),
express = require('express');
-var config = module.exports.config = { "db": {
+var config = { "db": {
'port': 27017,
'host': "localhost"
},
@@ -20,7 +20,7 @@ var config = module.exports.config = { "db": {
'address': "0.0.0.0"
},
'flavor': "regular",
- 'debug': false
+ 'debug': true
};
var app = module.exports.app = express.createServer();
@@ -29,27 +29,22 @@ app.configure(function(){
app.use(express.bodyDecoder());
app.use(express.staticProvider(__dirname + '/public'));
app.use(express.logger());
+ app.set('views', __dirname + '/views');
+ app.set('view engine', 'jade');
});
+try {
+ config = JSON.parse(fs.readFileSync("./config.json"));
+} catch(e) {
+ // ignore
+}
+
+module.exports.config = config;
+
require('./lib/main');
require('./lib/command');
require('./lib/rest');
-fs.readFile("./config.json", 'utf8', function(err, data) {
- if (err) {
- sys.puts("No config.json found. Using default configuration");
- }
- try {
- config = JSON.parse(data);
- } catch (e) {
- sys.puts("Error parsing config.json");
- process.exit(1);
- }
-
- if(process.argv[0] == "node") {
- app.listen(config.server.port, config.server.address);
- }
-
-});
-
-
+if(process.argv[0] == "node") {
+ app.listen(config.server.port, config.server.address);
+}
View
@@ -0,0 +1,3 @@
+h1 REST Server
+p Running with the folowing configuration:
+pre=JSON.stringify(config)
View
@@ -0,0 +1,9 @@
+!!! 5
+html
+ head
+ title MongoDB REST
+ link(rel: "stylesheet", href: "/stylesheets/style.css")
+ body
+ #header
+ img(src='/images/logo.png')
+ #content!= body

0 comments on commit 1770bc8

Please sign in to comment.