sites = await resources.get_json('config/sites.json')
mime_types = await resources.get_json('config/mime_types.json')
mime_type_html =
- mime_types.hasOwnProperty('html') ?
+ Object.prototype.hasOwnProperty.call(mime_types, 'html') ?
mime_types.html :
mime_type_default
"build_cache": "file:../build_cache.git/build_cache-1.0.0.tgz",
"commander": "^2.18.0",
"cookie": "^0.3.1",
+ "emailjs": "^2.2.0",
"fs": "^0.0.1-security",
"http": "^0.0.0",
"https": "^1.0.0",
let BuildCache = require('build_cache')
+let emailjs = require('emailjs')
let fs = require('fs')
let JSONCache = require('json_cache')
let jstemplate = require('jstemplate')
let fs_readFile = util.promisify(fs.readFile)
let yauzl_open = util.promisify(yauzl.open)
+let build_cache_email = new BuildCache()
+let get_email = path => build_cache_email.get(
+ path,
+ async result => {
+ console.log('parsing', path)
+ result.value = emailjs.server.connect(
+ JSON.parse(await fs_readFile(path))
+ )
+ }
+)
+
let build_cache_js = new BuildCache()
let get_js = path => build_cache_js.get(
path,
let json_cache = new JSONCache()
json_cache.diag = true
+exports.get_email = get_email
exports.get_js = get_js
exports.get_json = get_json
exports.get_less = get_less
0,
domain_name.length - port_suffix.length
)
- if (!config.sites.hasOwnProperty(domain_name)) {
+ if (!Object.prototype.hasOwnProperty.call(config.sites, domain_name)) {
console.log('nonexistent site', domain_name)
die(res)
return
let assert = require('assert')
let cookie = require('cookie')
-let crypto = require('crypto')
let fs = require('fs')
let config = require('./config')
let resources = require('./resources')
let temp = file_name.lastIndexOf('.')
let file_type = temp === -1 ? '' : file_name.substring(temp + 1)
let mime_type =
- config.mime_types.hasOwnProperty(file_type) ?
+ Object.prototype.hasOwnProperty.call(config.mime_types, file_type) ?
config.mime_types[file_type] :
config.mime_type_default
let env = {
cookies: cookie.parse(req.headers.cookie || ''),
lang: 'en',
+ method: req.method,
page: page,
query: parsed_url.query,
+ read_stream: req,
resources: resources,
set_cookie: (key, value, expires, path) => {
res.setHeader(
switch (type) {
case undefined:
return /*await*/ (await resources.get_js(path))(env, out, get)
+ case 'email':
+ return /*await*/ resources.get_email(path)
case 'js':
return /*await*/ resources.get_js(path)
case 'json':
}
let favicons = await resources.get_zip(site_root + '/favicons.zip')
- if (favicons.hasOwnProperty(page)) {
+ if (Object.prototype.hasOwnProperty.call(favicons, page)) {
let data = favicons[page]
console.log(
site,