"use strict";

const Lien = require("../lib");

// Init lien server
let server = new Lien({
    host: "localhost"
  , port: 9000
  , public: __dirname + "/public"
});

// Listen for load
server.on("load", err => {
    console.log(err || "Server started on port 9000.");
    err && process.exit(1);
});

// Add page
server.addPage("/", lien => {
    lien.end("Hello World");
});

// Add a dynamic route
server.addPage("/post/:id", lien => {
    lien.end("Post id: " + lien.params.id);
});

server.hook("before", "/post/:id", "get", (lien, next) => {
    console.log(">> " + lien.path + " | " + lien.query.id);
    setTimeout(function() {
        next();
    }, 100);
});

server.addPage("/test", "/index.html");
server.errorPages();

server.on("serverError", err => {
    console.log(err.stack);
});

@@ -478,24 +478,259 @@
 s.id);%0A%7D);%0A%0A
+server.hook(%22before%22, %22/post/:id%22, %22get%22, lien =%3E %7B%0A    console.log(%22Before%22);%0A%7D);%0A%0Aserver.hook(%22after%22, %22/post/:id%22, %22get%22, (res, next) =%3E %7B%0A    setTimeout(function() %7B%0A        res.content = %22hi%22;%0A        next();%0A    %7D, 1000);%0A%0A%7D);%0A%0A%0A
 server.hook(
@@ -891,16 +891,17 @@
   %7D, 100
+0
 );%0A%7D);%0A%0A

Add hook examples