From 1c5ddd7e82f1a7ec4ace678e4ddfab03252ca107 Mon Sep 17 00:00:00 2001 From: Jan Philipp Timme Date: Fri, 13 Sep 2013 18:49:44 +0200 Subject: [PATCH] [TASK] Introduce basic files for nodejs. --- .gitignore | 5 +++++ .npmignore | 2 ++ app.js | 31 +++++++++++++++++++++++++++++++ package.json | 27 +++++++++++++++++++++++++++ 4 files changed, 65 insertions(+) create mode 100644 .gitignore create mode 100644 .npmignore create mode 100644 app.js create mode 100644 package.json diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3f3e9d0 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +node_modules +snakeoil/*.pem +snakeoil/*.csr +settings.json +!settings.json.template diff --git a/.npmignore b/.npmignore new file mode 100644 index 0000000..a947c12 --- /dev/null +++ b/.npmignore @@ -0,0 +1,2 @@ +.git* +*.md diff --git a/app.js b/app.js new file mode 100644 index 0000000..d5a9bec --- /dev/null +++ b/app.js @@ -0,0 +1,31 @@ +var express = require("express"); +var http = require("http"); +var https = require("https"); +var fs = require("fs"); + +var app = express(); + +app.use(function(req, res, next) { + console.log("%s %s", req.method, req.url); + next(); +}); + +//deliver static files by default +app.use(express.static(__dirname + '/static')); + +app.use("/ohai", function(req, res) { + res.send("ohai!"); +}); + + +app.use(function(req, res) { + res.status(404).send("Sorry, nothing here."); +}); + +//http.createServer(app).listen(3000); + +var httpsOptions = { + "key": fs.readFileSync("snakeoil/privkey.pem"), + "cert": fs.readFileSync("snakeoil/cert.pem") +}; +https.createServer(httpsOptions, app).listen(3000); diff --git a/package.json b/package.json new file mode 100644 index 0000000..3de8ff5 --- /dev/null +++ b/package.json @@ -0,0 +1,27 @@ +{ + "name": "dashboard", + "version": "0.0.1", + "description": "iGoogle-like dashboard", + "keywords": [ + "web", + "dashboard" + ], + "repository": "git://github.com/JPT580/dashboard.git", + "author": "Jan Philipp Timme ", + "dependencies": { + "express": "*" + }, + "devDependencies": {}, + /* + "licenses": [{ + "type": "MIT", + "url": "https://raw.github.com/senchalabs/connect/master/LICENSE" + }], + */ + "engines": { + "node": ">= 0.8.0" + }, + "scripts": { + "start": "node app.js" + } +}