"use strict";

module.exports = function(imports) {

    let express = imports.modules.express;
    let Promise = imports.modules.Promise;
    let fs = require("fs"); // TODO: put this into initImports
    let util = imports.util;
    let handler = util.handler;

    let router = express.Router();

    let pages = {
        signup: "Signup",
    };

    for (let page in pages) {

        router.get("/" + page, handler(function*(req, res) {

            res.render("../../morteam-web/src/page.html.ejs", {
                page: pages[page]
            });

        }));

    }

    router.get("/js/:page", handler(function*(req, res) {
        let page = req.params.page;
        let file = "../morteam-web/build/" + page + ".js";
        // TODO: use the package fs-promise
        fs.exists(file, function(exists) {
            if (!exists) {
                return res.end("fail"); // AHHHH
            }
            fs.createReadStream(file).pipe(res);
        });
    }));

    router.get("/src/bundle.css", handler(function*(req, res) {
        fs.createReadStream("../morteam-web/src/bundle.css").pipe(res)
    }));
    
    return router;

};

@@ -979,157 +979,8 @@
 );%0A%0A
-    router.get(%22/src/bundle.css%22, handler(function*(req, res) %7B%0A        fs.createReadStream(%22../morteam-web/src/bundle.css%22).pipe(res)%0A    %7D));%0A    %0A
     

Stop serving css file