public
/
jst_server.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
b72a937
)
Change var to let and use arrow functions everywhere
author
Nick Downing
<downing.nick@gmail.com>
Sun, 7 Oct 2018 09:22:35 +0000
(20:22 +1100)
committer
Nick Downing
<downing.nick@gmail.com>
Sun, 7 Oct 2018 09:22:35 +0000
(20:22 +1100)
ndserver.js
patch
|
blob
|
history
diff --git
a/ndserver.js
b/ndserver.js
index
6355c8c
..
da129a0
100755
(executable)
--- a/
ndserver.js
+++ b/
ndserver.js
@@
-48,7
+48,7
@@
let build_cache_less = new BuildCache()
let build_cache_text = new BuildCache()
let build_cache_zet = new BuildCache()
let build_cache_text = new BuildCache()
let build_cache_zet = new BuildCache()
-let serve =
function(res, status, mime_type, data)
{
+let serve =
(res, status, mime_type, data) =>
{
res.statusCode = status
// html files will be direct recipient of links/bookmarks so can't have
// a long lifetime, other files like css or images are often large files
res.statusCode = status
// html files will be direct recipient of links/bookmarks so can't have
// a long lifetime, other files like css or images are often large files
@@
-60,18
+60,18
@@
let serve = function(res, status, mime_type, data) {
res.end(data)
}
res.end(data)
}
-let die =
function(res)
{
+let die =
res =>
{
let body = '<html><body>Page not found</body></html>'
serve(res, 404, 'text/html; charset=utf-8', new Buffer(body, 'utf8'))
}
let body = '<html><body>Page not found</body></html>'
serve(res, 404, 'text/html; charset=utf-8', new Buffer(body, 'utf8'))
}
-let redirect =
function(res, location)
{
+let redirect =
(res, location) =>
{
res.statusCode = 301
res.setHeader('Location', location)
res.end('Redirecting to ' + location)
}
res.statusCode = 301
res.setHeader('Location', location)
res.end('Redirecting to ' + location)
}
-let app = async
function(req, res, protocol)
{
+let app = async
(req, res, protocol) =>
{
let site = req.headers.host || 'localhost'
let temp = site.indexOf(':')
let port_suffix = temp === -1 ? '' : site.substring(temp)
let site = req.headers.host || 'localhost'
let temp = site.indexOf(':')
let port_suffix = temp === -1 ? '' : site.substring(temp)
@@
-337,7
+337,7
@@
let app = async function(req, res, protocol) {
return die(res)
}
return die(res)
}
-let tryApp =
function(req, res, protocol)
{
+let tryApp =
(req, res, protocol) =>
{
app(req, res, protocol).catch(
err => {
console.log(err.stack || err.message)
app(req, res, protocol).catch(
err => {
console.log(err.stack || err.message)
@@
-354,9
+354,7
@@
let tryApp = function(req, res, protocol) {
if (commander.httpPort !== -1) {
http.createServer(
if (commander.httpPort !== -1) {
http.createServer(
- function(req, res) {
- return tryApp(req, res, 'http')
- }
+ (req, res) => tryApp(req, res, 'http')
).listen(commander.httpPort)
console.log('HTTP server listening on port', commander.httpPort)
}
).listen(commander.httpPort)
console.log('HTTP server listening on port', commander.httpPort)
}
@@
-366,9
+364,7
@@
if (commander.httpsPort !== -1) {
'cert': fs.readFileSync(commander.sslCert),
'key': fs.readFileSync(commander.sslKey)
},
'cert': fs.readFileSync(commander.sslCert),
'key': fs.readFileSync(commander.sslKey)
},
- function(req, res) {
- return tryApp(req, res, 'https')
- }
+ (req, res) => tryApp(req, res, 'https')
).listen(commander.httpsPort)
console.log('HTTPS server listening on port', commander.httpsPort)
}
).listen(commander.httpsPort)
console.log('HTTPS server listening on port', commander.httpsPort)
}