+47
| // Copyright (C) 2014-2015 Free Software Foundation, Inc. | ||
| // This program is free software; you can redistribute it and/or modify | ||
| // it under the terms of the GNU General Public License as published by | ||
| // the Free Software Foundation, either version 3 of the License, or | ||
| // (at your option) any later version. | ||
| // This program is distributed in the hope that it will be useful, | ||
| // but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| // GNU General Public License for more details. | ||
| // You should have received a copy of the GNU General Public License | ||
| // along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 'use strict'; | ||
| var http = require('http'), | ||
| scopifier = require('./scopifier'); | ||
| // Start a scopifier HTTP server. | ||
| function server(options) { | ||
| var httpServer = http.createServer(function (request, response) { | ||
| var whole = ''; | ||
| request.setEncoding('utf8'); | ||
| request.on('data', function (data) { | ||
| whole += data; | ||
| }); | ||
| request.on('end', function () { | ||
| var tokens = []; | ||
| try { | ||
| tokens = scopifier(whole); | ||
| } catch (error) { | ||
| // Gracefully handle parse errors by sending nothing. | ||
| tokens = []; | ||
| } | ||
| response.end(JSON.stringify(tokens)); | ||
| }); | ||
| }), | ||
| port = options.port, | ||
| host = options.host; | ||
| httpServer.listen(port, host, function () { | ||
| console.log('Scopifier listening at ' + host + ':' + port); | ||
| }); | ||
| } | ||
| module.exports = server; |
+1
-1
| { | ||
| "name": "scopifier", | ||
| "version": "1.2.0", | ||
| "version": "1.2.1", | ||
| "description": "Scopifier CLI for Context Coloring", | ||
@@ -5,0 +5,0 @@ "main": "scopifier.js", |
Sorry, the diff of this file is not supported yet
Network access
Supply chain riskThis module accesses the network.
9633
19.32%218
22.47%1
Infinity%