2.0.0-rc2 • Published 6 years ago

bigrest v2.0.0-rc2

Weekly downloads
21
License
MIT
Repository
github
Last release
6 years ago

bigrest

NPM Version NPM Downloads

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.

KeyTypeDefaultDescription
debugbooleanfalsedebug mode switch
etagbooleanfalseswitch on ETAG generation
httpsObjectundefinedoptions for HTTPS protocol
compressionboolean or Objectfalseswitch or options for compression
basepathstringprocess.cwd()the base path
servicesXArray(string)servicesthe handlers and routers path
rootworkfunctionundefinedthe all METHOD handler for '/'
r404workfunctionundefinedthe all METHOD handler while response 404
visitorfunctionundefiendthe pre processor the all handler
viewerObject(viewer)undeifnedset html template engine
limitsObject(limits)undeifnedthe limits for request parse
staticsXArray(static)undefiendset static file engine
middlewaresArray(function)[]the middlewares for express

https documents https.createServer
compression as options documents compression

Object(viewer)

KeyTypeDefaultDescription
filepathstringundefinedthe template source file path
renderstring or functionundefiendthe template engine
cachebooleanopposite with opts.debugsystem cache switch
{
    render: swig.renderFile,
    filepath: path.join(__dirname, "server", "views")
}

Object(limits)

KeyTypeDefaultDescription
bodySizenumber4mbthe request body size
uploadSizenumber50mbthe maximum size for file upload
{
    bodySize: 102400,
    uploadSize: 1024000
}

Object(static)

KeyTypeDefaultDescription
urlpathstringundefinedthe url path
filepathstringundefinedthe static file's file path
optionsObjectundefinedthe 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

NamePathExport VariablesExport methods
brcxcommons/UpperCase named, number & stringall
brmxmethod/UpperCase named, number & stringlowercase 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)
KeyTypeDefaultDescription
parametersArray(Parameger)[]the common parameters
interceptorXArray(string)[]the common interceptor names
failurestirngundefinedthe default failure processor name
groupsArray(group)requiredthe router group
Object(group)
KeyTypeDefaultDescription
parametersArray(Parameger)[]the common parameters
interceptorXArray(string)[]the interceptor names
failurestirngundefinedthe failure processor name
processorsArray(processor)requiredthe router parameters
Object(processor)
KeyTypeDefaultDescription
methodXArray(string)requiredMETHOD
urlXArray(string)requiredURL
parametersArray(parameger)[]the common parameters
failurestirngundefinedthe failure processor name
processorstringrequiredthe processor name
workdataObjectundefinedattach to req
workparamObjectundefinedattach 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:

KeyDescription
nameField name specified in the form
typeMime type of the file
sizeSize of the file in bytes
pathThe full path to the temp uploaded file
originalFilenameName of the file on the user's computer

Examples

demo

License

MIT

2.0.0-rc2

6 years ago

2.0.0-rc1

7 years ago

1.5.8

7 years ago

1.5.7

7 years ago

1.5.6

7 years ago

1.5.5

7 years ago

1.5.4

7 years ago

1.5.3

7 years ago

1.5.2

7 years ago

1.5.1

7 years ago

1.4.10

7 years ago

1.4.9

7 years ago

1.4.8

7 years ago

1.4.7

8 years ago

1.4.6

8 years ago

1.4.5

8 years ago

1.4.4

8 years ago

1.4.3

8 years ago

1.4.2

8 years ago

1.4.1

8 years ago

1.4.0

8 years ago

1.3.12

8 years ago

1.3.11

8 years ago

1.3.10

8 years ago

1.3.9

8 years ago

1.3.8

8 years ago

1.3.7

8 years ago

1.3.6

8 years ago

1.3.5

8 years ago

1.3.4

8 years ago

1.3.3

8 years ago

1.3.2

8 years ago

1.3.1

9 years ago

1.3.0

9 years ago

1.2.8

9 years ago

1.2.7

9 years ago

1.2.6

9 years ago

1.2.5

9 years ago

1.2.4

9 years ago

1.2.3

9 years ago

1.2.2

9 years ago

1.2.1

9 years ago

1.2.0

9 years ago

1.1.0

9 years ago

1.0.8

9 years ago

1.0.7

9 years ago

1.0.6

9 years ago

1.0.5

9 years ago

1.0.4

9 years ago

1.0.3

9 years ago

1.0.2

9 years ago

1.0.1

9 years ago

1.0.0

9 years ago