From 808692564c52a537f3909d47bb5c775e91323e53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20M=C3=BCller?= Date: Thu, 24 Sep 2015 23:16:07 +0200 Subject: [PATCH] first route --- server.js | 11 +++++++++-- src/page.js | 3 +-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/server.js b/server.js index b29ca3d..5bd1b04 100644 --- a/server.js +++ b/server.js @@ -4,10 +4,17 @@ var app = express(); app.use(express.static(__dirname + '/resources/public')); -app.get('/api', function (req, res) { - res.send(page.build("api")); +app.get('/:year/:month/:day/:title', function (req, res) { + var params = req.params; + var id = params.year + "/" + params.month + "/" + params.day + "/" + params.title; + res.send("opening note " + id); }); +app.get('/:link', function (req, res) { + +}); + + var server = app.listen(3000, function () { console.log('NoteHub server listening on port %s', server.address().port); }); \ No newline at end of file diff --git a/src/page.js b/src/page.js index 700e32b..69550c9 100644 --- a/src/page.js +++ b/src/page.js @@ -7,11 +7,10 @@ var template = fs.readFileSync("resources/template.html", "utf-8"); var buildHTML = (title, content) => template .replace("%TITLE%", title) .replace("%CONTENT%", content); -var apiPage = buildHTML("API", marked(fs.readFileSync("API.md", "utf-8"))); module.exports.build = id => { if (CACHE.has(id)) return CACHE.get(id); - var content = id == "api" ? apiPage : "This is page " + id; + var content = "This is page " + id; CACHE.set(id, content); return content; };