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

oils

Package Overview
Dependencies
Maintainers
1
Versions
117
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

oils - npm Package Compare versions

Comparing version 1.0.11 to 1.0.12

core/utils/routeutils.js

19

core/utils/stringUtils.js
exports.endsWith = function(str, suffix) {
return str.indexOf(suffix, str.length - suffix.length) !== -1;
}
exports.escapeRegexp = function(str) {
return str.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
}
exports.trim = function(aStr) {
if (!aStr) {
return "";
}
return aStr.replace(/^\s+|\s+$/g, '');
}
exports.capitalize = function(aStr) {
return aStr[0].toUpperCase() + aStr.slice(1);
}
exports.isEmpty = function(str) {
return str == null || str.length == 0;
}

92

core/Web.js

@@ -9,2 +9,4 @@ var Obj = require('./Obj.js');

var flash = require('connect-flash');
var path = require('path');
var fs = require('fs');
var routeUtils = require('./utils/routeUtils');

@@ -72,2 +74,3 @@ log4js.replaceConsole();

fileUtils: require('./utils/fileUtils.js'),
stringUtils: require('./utils/stringUtils.js'),

@@ -297,4 +300,8 @@ //web.Plugin.extend..

this.loadPlugins(function() {
var routesFromConf = self.include(web.conf.routesFile);
self.applyRoutes(routesFromConf);
var confRoutes = self.conf.routes || {};
confRoutes = extend(self.include(self.conf.routesFile), confRoutes);
self.conf.routes = confRoutes;
self.applyRoutes(self.conf.routes);
self.callEvent('initServer');

@@ -306,6 +313,9 @@ });

app.use(function(err, req, res, next){
// logic
res.status(500);
if (web.conf.handle500) {
web.conf.handle500(err, req, res, next);
} else {
res.send("This is embarrassing.");
}
console.error("General error", err);
res.status(500).send("This is embarrassing.");
//TODO: tweet / email
});

@@ -333,12 +343,72 @@

web.initServer();
// Start the app on the specific interface (and port).
web.app.listen(web.conf.port, web.conf.ipAddress, function(err, result) {
console.log('%s: Node server started on %s:%d ...',
Date(Date.now()), web.conf.ipAddress, web.conf.port);
var http = require('http');
var alwaysSecure = null;
if (web.conf.https) {
var https = require('https');
var privateKey = fs.readFileSync(web.conf.https.privateKey, 'utf8');
var certificate = fs.readFileSync(web.conf.https.certificate, 'utf8');
var credentials = {key: privateKey, cert: certificate};
var httpsServer = https.createServer(credentials, web.app);
httpsServer.listen(web.conf.https.port, web.conf.ipAddress, function(err, result) {
if (err) {
console.error(err);
}
console.log('%s: Node https server started on %s:%d ...',
Date(Date.now()), web.conf.ipAddress, web.conf.https.port);
if (cb) {
cb(err, result);
}
});
});
alwaysSecure = web.conf.https.alwaysSecure;
}
if (alwaysSecure && alwaysSecure.enabled) {
var httpRedirecter = http.createServer(function(req, res) {
if (alwaysSecure.redirectHandler) {
alwaysSecure.redirectHandler(req, res);
} else {
var url = require('url');
var nonStandardPort = '';
if (web.conf.https.port != 443) {
nonStandardPort = ':' + web.conf.https.port;
}
res.writeHead(302, {'Location': 'https://' + req.headers.host.split(':')[0] + nonStandardPort});
res.end();
}
});
httpRedirecter.listen(web.conf.port, web.conf.ipAddress, function(err, result) {
if (err) {
console.error(err);
}
console.log('%s: http redirecter server started on %s:%d ...',
Date(Date.now()), web.conf.ipAddress, web.conf.port);
if (cb) {
cb(err, result);
}
});
} else {
var httpServer = http.createServer(web.app);
// Start the app on the specific interface (and port).
httpServer.listen(web.conf.port, web.conf.ipAddress, function(err, result) {
if (err) {
console.error(err);
}
console.log('%s: Node server started on %s:%d ...',
Date(Date.now()), web.conf.ipAddress, web.conf.port);
if (cb) {
cb(err, result);
}
});
}
});

@@ -345,0 +415,0 @@ }

2

package.json
{
"name": "oils",
"version": "1.0.11",
"version": "1.0.12",
"description": "A slightly opinionated web framework built on top of Express 4.",

@@ -5,0 +5,0 @@ "keywords": [

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