var env = {};

const APP_HOST = env.APP_HOST || "127.0.0.1";
const APP_PORT = env.APP_PORT || 4000;
const DB_PATH = env.DB_PATH || "./db/users.json";

import {data} from "./db.js";
import App from 'express';
import Router from 'node-async-router';

const app = App(),
      router = Router();




import fs from 'fs';

const tpls = {
  index: fs.readFileSync('./index.html')+''
};
const print = function(data) {
  return tpls.index.replace('$DATA$', data)
};

router.get('ivasic', async function(req, res) {
  res.end(print('lalka'));
});


router.all('/', function(req, res) {
  res.end(print(JSON.stringify(data)));
});

app.use(router);
app.use(App.static('public'))


app.listen(APP_PORT);

console.log(`LISTEN port :`+APP_PORT);
