Security News
Supply Chain Attack Detected in Solana's web3.js Library
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
Lightweight Node.js web application framework on clusters with file server.
npm install orangebox
var app = require('orangebox').app();
app.get('/', function (req, res) {
res.send('Hello World');
});
app.listen(8080);
After run your web server will be working in 3 threads via clusters. To specify the number of threads use:
var count = 8;
var app = require('orangebox').app(count);
// invoked for any requests passed to this router
router.use(function(req, res, next) {
// .. some logic here ..
next();
});
// Will handle all requests that reference a /test
app.get('/test/*', function (req, res) {
//...
});
// Will handle all requests that reference a /test
app.get('/test', function (req, res) {
//...
});
// used named keys
app.get('/user/:id/:method', function (req, res) {
//...
});
// routing with regexp
app.get('/^\/commits\/(\w+)(?:\.\.(\w+))?$/', function (req, res) {
//...
});
Note: if your handler function has 3 parameters (with "next"), you should be use next(); in it body
Mount the middleware function(s) at the path. If path is not specified, it defaults to "*".
// this middleware will be executed for every request to the app
app.use('*', function (req, res, next) {
console.log('Time: %d', Date.now());
next();
})
Middleware functions are executed sequentially, therefore the order of middleware inclusion is important.
// this middleware will not allow the request to go beyond it
app.use(function(req, res, next) {
res.send('Hello World');
})
// requests will never reach this route
app.get('/test', function (req, res) {
res.send('Hello World 2');
})
An orangebox app is a valid middleware.
var orangeBox = require('orangebox');
var app = orangeBox.app();
var subApp = orangeBox.app();
subApp.get('/news', function (req, res, next) {
res.send('This news middleware');
});
app.use(subApp);
For this feature used node-static Server:
var app = require('orangebox').app();
// Creating a file server for serving files under a directory
app.fileServer(__dirname + '/public');
app.get('/', function (req, res) {
res.send('<img src="my.jpg" />');
});
// Transfer the file at the given path.
app.get('/i/send.jpg', function (req, res) {
res.sendFile(__dirname + '/public/send.jpg');
});
// Transfer the file as attachment at the given path.
app.get('/i/attachment.jpg', function (req, res) {
res.attachment(__dirname + '/public/send.jpg', "attachment.jpg");
});
// Serving files as attachments under a directory
app.get('/attach/*.jpg', function (req, res) {
res.attachment(__dirname + '/public/' + req.params[0] +'.jpg', "attachment-" + req.params[0] + ".jpg");
});
app.listen(8080);
Of course you need to put the pictures to the folder ./public
var app = require('orangebox').app();
app.get('/', function (req, res) {
res.send('<form action="/upload" enctype="multipart/form-data" method="post">'+
'<input type="text" name="title"><br>'+
'<input type="file" name="upload" multiple="multiple"><br>'+
'<input type="submit" value="Upload!">'+
'</form>');
});
app.post('/upload', function (req, res) {
res.send([req.files, req.body]);
});
app.listen(8080);
Application settings variable can be set using app.set(), and retrieved using app.get(). The following settings are provided to alter how OrangeBox will behave:
env Environment mode, defaults to process.env.NODE_ENV or "development"
case sensitive routing Enable case sensitivity, disabled by default, treating "/Foo" and "/foo" as the same
strict routing Enable strict routing, by default "/foo" and "/foo/" are treated the same by the router
view cache Enables view template compilation caching, enabled in production by default
view engine The default engine extension to use when omitted
views The view directory path, defaulting to "process.cwd() + '/views'"
app.alias('/favicon.ico', '/favicon-test.ico');
Author and developer of OrangeBox is Oleksiy Chechel
MIT License
Copyright (C) 2014 Oleksiy Chechel (alex.mirrr@gmail.com)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
FAQs
Lightweight Node.js web application framework on clusters with file server
The npm package orangebox receives a total of 1 weekly downloads. As such, orangebox popularity was classified as not popular.
We found that orangebox demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.