New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

http-markup-server

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

http-markup-server - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3

.editorconfig

109

bin/http-markup-server.js

@@ -5,4 +5,4 @@ #!/usr/bin/env node

*
* Author: Viacheslav Lotsmanov
* License: GNU/GPLv3 by Free Software Foundation
* Author: Viacheslav Lotsmanov <lotsmanov89@gmail.com>
* License: GPLv3
* https://github.com/unclechu/node-http-markup-server/blob/master/LICENSE

@@ -19,3 +19,3 @@ */

var config = JSON.parse( fs.readFileSync('http-markup-server.config.json') );
var config = JSON.parse(fs.readFileSync('http-markup-server.config.json'));

@@ -28,52 +28,31 @@ var port = config.port;

// parsing command-line arguments
process.argv.slice(2).forEach(function (arg) {
if (/^--port=/.test(arg)) {
port = arg.substr('--port='.length);
} else if (/^--host=/.test(arg)) {
host = arg.substr('--host='.length);
} else if (/^--browse=/.test(arg)) {
openInBrowser = arg.substr('--browse='.length).toLowerCase();
if (openInBrowser == 'yes' || openInBrowser == 'y' || openInBrowser == '1') {
if (~['yes', 'y', '1'].indexOf(openInBrowser)) {
openInBrowser = true;
} else if (openInBrowser == 'no' || openInBrowser == 'n' || openInBrowser == '0') {
} else if (~['no', 'n', '0'].indexOf(openInBrowser)) {
openInBrowser = false;
}
} else {
throw new Error('Unknown argument "'+ arg +'"');
}
});
app.configure(function () {
config.static.forEach(function (val) {
config.static.forEach(function (val) {
app.use('/' + val, express.static(val));
app.use('/' + val, express.static(val));
if (config.favicon && config.favicon === 'string') {
app.use(express.favicon( config.favicon ));
} else if (config.favicon) {
app.use(express.favicon('favicon.ico'));
}
});
if (config.favicon && config.favicon === 'string') {
app.use(express.favicon( config.favicon ));
} else if (config.favicon) {
app.use(express.favicon('favicon.ico'));
}
});

@@ -87,3 +66,2 @@

app.get('*', function (req, res) {
var fullUrl = url.resolve('http://' + req.headers.host, req.url);

@@ -99,3 +77,2 @@ var location = url.parse(fullUrl);

if (pathname.substr(-1) === '/') {
curTplFilename = indexFiles.shift();

@@ -105,19 +82,12 @@ tpl = path.join(pathname, curTplFilename);

dir = true;
} else {
if (path.extname(pathname) === '') {
res.send('403 Forbidden', 403);
res.status(403).send('403 Forbidden');
if (config.security_log) console.warn('Hacking attempt!', req);
return;
} else {
var found = false;
config.allowable_extensions.forEach(function (ext) {
if (path.extname(pathname) === ext) {
found = true;

@@ -127,17 +97,11 @@ curTplFilename = path.basename(pathname);

if (tpl.charAt(0) === '/') tpl = tpl.substr(1);
}
});
if (!found) {
res.send('403 Forbidden', 403);
res.status(403).send('403 Forbidden');
if (config.security_log) console.warn('Hacking attempt!', req);
return;
}
}
}

@@ -159,5 +123,3 @@

function tryRender() {
app.render(tpl, {
RELATIVE_ROOT: relativeRoot, // relative path to root

@@ -167,3 +129,2 @@ location: location,

curNavPos: function curNavPos(withIndexPage) {
if (withIndexPage === undefined) withIndexPage = true;

@@ -176,18 +137,11 @@ withIndexPage = withIndexPage ? true : false;

if (res.substr(-filename.length) === filename) {
res = res.slice(0, -filename.length);
}
return res;
},
}, function (err, html) {
if (err) {
if (err.toString().search(/failed to lookup view/i) !== -1) {
if (dir && indexFiles.length > 0) {
curTplFilename = indexFiles.shift();

@@ -198,17 +152,18 @@ tpl = path.join(pathname, curTplFilename);

return;
} else {
res.status(404).send('404 Not Found');
res.send('404 Not Found', 404);
if (config.security_log) console.warn('404 status.', req);
if (config.security_log) {
console.warn('404 status.', req);
}
return;
}
} else {
res
.status(500)
.send('500 Internal Server Error\n' + err.toString());
res.send('500 Internal Server Error\n' + err.toString(), 500);
console.error(err);
return;
}

@@ -218,28 +173,22 @@ }

res.send(html);
});
}
} tryRender();
tryRender();
});
app.listen(port, host, function () {
var URL = 'http://';
if (host) {
console.log('Listening on %s:%d', host, port);
URL += host;
} else {
console.log('Listening on *:%d', port);
URL += '127.0.0.1';
}
if (port !== 80) URL += ':' + port;
if (openInBrowser) {
spawn('xdg-open', [URL], { stdio: 'ignore' })

@@ -249,7 +198,3 @@ .on('error', function (err) {

});
}
});
// vim: set ts=4 sw=4 et :
{
"name": "http-markup-server",
"version": "0.0.2",
"version": "0.0.3",
"description": "HTTP-server for markup (using express framework and ejs template engine)",
"dependencies": {
"express": "~3.5.1",
"ejs": "~1.0.0"
"express": "^4.16.3",
"ejs": "^2.6.1"
},

@@ -12,5 +12,2 @@ "engines": {

},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {

@@ -38,9 +35,7 @@ "type": "git",

"main": "bin/http-markup-server.js",
"author": {
"name": "Viacheslav Lotsmanov"
},
"author": "Viacheslav Lotsmanov <lotsmanov89@gmail.com>",
"homepage": "https://github.com/unclechu/node-http-markup-server",
"licenses": [
{
"type": "GNU/GPLv3 by Free Software Foundation",
"type": "GPLv3",
"url": "https://github.com/unclechu/node-http-markup-server/blob/master/LICENSE"

@@ -47,0 +42,0 @@ }

Node.JS HTTP Markup Server
==========================
HTTP-server for markup (using [express](http://expressjs.com/) framework and [ejs](http://embeddedjs.com/) template engine)
HTTP-server for markup (using [express](http://expressjs.com/) framework and
[ejs](http://embeddedjs.com/) template engine)
[![NPM](https://nodei.co/npm/http-markup-server.png)](https://nodei.co/npm/http-markup-server/)
**WARNING!** This is a dead project.
Any updates usually is just for supressing vulnerability alerts.
Install
=======
```shell
# npm install -g http-markup-server
```bash
npm install -g http-markup-server
```

@@ -18,5 +22,8 @@

Copy [config file (http-markup-server.config.json)](./http-markup-server.config.json) to your markup directory and start the server:
```shell
$ http-markup-server
Copy
[config file (http-markup-server.config.json)](http-markup-server.config.json)
to your markup directory and start the server:
```bash
http-markup-server
```

@@ -27,2 +34,2 @@

[GNU/GPLv3 by Free Software Foundation](./LICENSE)
[GPLv3](LICENSE)

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc