Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

boar-server

Package Overview
Dependencies
Maintainers
6
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

boar-server - npm Package Compare versions

Comparing version 2.3.2 to 2.4.0

30

app/index.js
'use strict';
var fs = require('fs');
var http = require('http');
var https = require('https');
var serve = require('koa-static');

@@ -12,2 +14,3 @@ var cors = require('koa-cors');

var requestId = require('koa-request-id');
var sslify = require('koa-sslify');

@@ -92,4 +95,29 @@

listen: function(port, env) {
this.koaApp.listen(port);
var httpPort = parseInt(port);
this._startHTTPServer(httpPort, env);
if (process.env.SERVE_HTTPS === 'true') {
var httpsPort = httpPort + 10000;
this._startHTTPSServer(httpsPort, env);
}
},
_startHTTPServer: function(port, env) {
http.createServer(this.koaApp.callback()).listen(port);
console.log('Application started:', { port: port, env: env });
},
_startHTTPSServer: function(port, env) {
var httpsOptions = {};
if (process.env.HTTPS_KEY && process.env.HTTPS_CERT) {
httpsOptions.key = fs.readFileSync(process.env.HTTPS_KEY);
httpsOptions.cert = fs.readFileSync(process.env.HTTPS_CERT);
}
this.addMiddleware(sslify({ port: port }));
https.createServer(httpsOptions, this.koaApp.callback()).listen(port);
console.log('Application started (with SSL):', { port: port, env: env });
}

@@ -96,0 +124,0 @@

3

package.json

@@ -39,2 +39,3 @@ {

"koa-router": "5.4.0",
"koa-sslify": "1.0.1",
"koa-static": "2.0.0",

@@ -44,3 +45,3 @@ "lodash": "4.6.0",

},
"version": "2.3.2"
"version": "2.4.0"
}

@@ -54,1 +54,17 @@ # Boar Server

```
## HTTPS support
To enable HTTPS support, simple create `SERVE_HTTPS` environment variable with value `true`.
The port for https will be the port of the application increased with 10000 (10k).
If you want to serve the requests with your own SSL certification, create `HTTPS_KEY` and `HTTPS_CERT`
environment variables with path of the files as values.
### Example
```
export SERVE_HTTPS=true
export HTTPS_KEY="path/to/cert.key"
export HTTPS_CERT="path/to/cert.crt"
node server.js
```
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