bigrest v2.0.0-rc2
bigrest
Smart web and restful framework for NodeJS. current core is express.
Installation
$ npm install bigrest
Usage
var bigrest = require('bigrest')
API
listen(port, opts)
Binds and listens for connections on the port.
var path = require('path');
var bigrest = require('../index');
var http = bigrest.listen(18080, {
basepath: __dirname,
statics: [{
urlpath: '/files',
filepath: path.join(__dirname, 'files')
}],
compression: {
threshold: 16 * 1024
}
});
XArray(string) was a Array(string) or a Array splited by ",".
XArray(object) was a Array(object) or a Object(object) ",".
Parameter: opts
The options for bigrest framework.
Key | Type | Default | Description |
---|---|---|---|
debug | boolean | false | debug mode switch |
etag | boolean | false | switch on ETAG generation |
https | Object | undefined | options for HTTPS protocol |
compression | boolean or Object | false | switch or options for compression |
basepath | string | process.cwd() | the base path |
services | XArray(string) | services | the handlers and routers path |
rootwork | function | undefined | the all METHOD handler for '/' |
r404work | function | undefined | the all METHOD handler while response 404 |
visitor | function | undefiend | the pre processor the all handler |
viewer | Object(viewer) | undeifned | set html template engine |
limits | Object(limits) | undeifned | the limits for request parse |
statics | XArray(static) | undefiend | set static file engine |
middlewares | Array(function) | [] | the middlewares for express |
https documents https.createServer
compression as options documents compression
Object(viewer)
Key | Type | Default | Description |
---|---|---|---|
filepath | string | undefined | the template source file path |
render | string or function | undefiend | the template engine |
cache | boolean | opposite with opts.debug | system cache switch |
{
render: swig.renderFile,
filepath: path.join(__dirname, "server", "views")
}
Object(limits)
Key | Type | Default | Description |
---|---|---|---|
bodySize | number | 4mb | the request body size |
uploadSize | number | 50mb | the maximum size for file upload |
{
bodySize: 102400,
uploadSize: 1024000
}
Object(static)
Key | Type | Default | Description |
---|---|---|---|
urlpath | string | undefined | the url path |
filepath | string | undefined | the static file's file path |
options | Object | undefined | the static options |
options means in the express.static
{
urlpath: '/static',
filepath: path.join(__dirname, "static")
}
Directory
|--{basepath}
| |--commons
| | |--test.js
| |--methods
| | |--test.js
| |--services
| | |--test-router.json
| | |--test.js
|--server.js
Global variables
Name | Path | Export Variables | Export methods |
---|---|---|---|
brcx | commons/ | UpperCase named, number & string | all |
brmx | method/ | UpperCase named, number & string | lowercase named |
Router And Processor
services/test-router.json
{
"processors": [
{
"url": "/benchmark",
"method": "GET",
"processor": "benchmark_empty",
"parameters": []
}
]
}
services/test.js
exports.benchmark_empty = function(req, res) {
brmx.benchmark(function() {
res.send('OK');
});
};
methods/test.js
exports.benchmark = function(callback) {
callback(null);
};
Router File Format
it has three style, Object(container), Array(group), Object(group).
Object(container)
Key | Type | Default | Description |
---|---|---|---|
parameters | Array(Parameger) | [] | the common parameters |
interceptor | XArray(string) | [] | the common interceptor names |
failure | stirng | undefined | the default failure processor name |
groups | Array(group) | required | the router group |
Object(group)
Key | Type | Default | Description |
---|---|---|---|
parameters | Array(Parameger) | [] | the common parameters |
interceptor | XArray(string) | [] | the interceptor names |
failure | stirng | undefined | the failure processor name |
processors | Array(processor) | required | the router parameters |
Object(processor)
Key | Type | Default | Description |
---|---|---|---|
method | XArray(string) | required | METHOD |
url | XArray(string) | required | URL |
parameters | Array(parameger) | [] | the common parameters |
failure | stirng | undefined | the failure processor name |
processor | string | required | the processor name |
workdata | Object | undefined | attach to req |
workparam | Object | undefined | attach to req |
Object(parameter)
This is a Array type model definition in field-inspector, click it for more detail.
req.files Information
It's array of file, And each file contains the following information:
Key | Description |
---|---|
name | Field name specified in the form |
type | Mime type of the file |
size | Size of the file in bytes |
path | The full path to the temp uploaded file |
originalFilename | Name of the file on the user's computer |
Examples
License
6 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago