0.0.3 • Published 8 years ago

brest-jayschema v0.0.3

Weekly downloads
14
License
-
Repository
github
Last release
8 years ago

Brest-Jayschema

About

Brest-Jayschema is Brest extension for posted json data validation, using JaySchema

How do I use it?

1. Install from package manager

If your project uses package.json, simply include

"dependencies": {
    ...
    "brest-jayschema": "*",
    ...
}

and then in the shell, in project root folder execute:

$ npm install

Otherwise, you can install brest globally with npm and have it available from anywhere on your machine:

$ npm install -g brest-jayschema

2 Setup

2.1 Application file

In your application file:

    var Brest = require('brest'),
    var BrestJaySchema = require('./brest-jayschema/');

    brest.use(BrestJaySchema);    

2.2 Settings

You can setup custom folder for the schema files in brest settings file:

{
    jayschema: {
        url: "%schema_url%"; //Schema url (see jsonSchema manuals)
        path: "%path_to_schema_files%; //Path to schema files. Default is "schema"
        schemaLoader: "%loader%"; //Custom schema loader. NOT TESTED
    }
}   

2.3 API description

{
    schema: "%schema_name%" 
}   

Example:

    {
        method: "POST",
        noAuth: true,
        schema: "person",
        handler: function(req,callback){
            person.create(req.body, callback);
        }
    }

3 Changes

0.0.3

Updated to comply with changes in brest method description

0.0.2

Async init