import path from "path";
import { promises as fs } from "fs";

export default (router, tpl) => {
  router.static({
    dir: path.resolve() + "/public/b",
    route: /^\/b\//
  });
  
  router.static({
    dir: path.resolve() + "/public/s",
    route: /^\/s\//
  });
  
  router.static({
    dir: path.resolve() + "/public/t",
    route: /^\/t\//
  });
  
  router.static({
    dir: path.resolve() + "/public/ca",
    route: /^\/ca\//
  });

  router.get(/^\/robots\.txt$/, async (req, res) => {
    res.reply({
      type: "text/plain",
      body: await fs.readFile(path.resolve() + "/public/robots.txt", "utf-8")
    });
  });
};
