0.1.28 • Published 7 years ago

wwpp v0.1.28

Weekly downloads
87
License
MIT
Repository
-
Last release
7 years ago

Introduction

usage

npm install wwpm

Hello Word

const wwpp = require('wwpp');
wwpp('./schema/','./webroot/').then(app =>app.start())

Definition Spec


a) Shared Common Class(eg: ./schema/common.js)

//common struct difinition(first char is upper case!)
exports.Product = {
    id: { type: "integer" },//define a integer type
    name: {type: "string" },//define a string type
    provider:{//define a ref object type
        $ref:"common#ProductProvider"
    },
    price: {
        type: "number",//define a float type
        minimum: 0,
        exclusiveMinimum: true
    }
}
exports.ProductProvider = {
    id: { type: "integer" },
    name: { type: "string" },
    tel: { type: "string" },
    email: { type: "string" }
}

b) Resource Interface Define

  • struct
exports.path = "/product/:id"
exports.get = {
	schema:{
		request:{...},//request data json schema definition
		response:{...},//response data json schema definition
	},
	action:function(req,resp){//process action function
		....
	}
}
  • eg:./schema/product.js
//resource interface difinition
//path is required, and any http methods:get ,post,delete....
exports.path = "/product/:id"
exports.get = {
    schema:{
        request:{id:{type:'integer'}},//ignore input define,got from router
        response:{
            value:{
                ref:'common#Product',
            },
            error:{
                type:'integer',
                optional:true
            }
        }
    },
    action:function(req,resp){
        this.value = new Promise(function(resolve,reject){...})
        return '/product.xhtml'
    }
}
exports.post= {
    schema:{
        request:{ref:'common#Product',},
        response:{
            error:{
                type:'integer',
                optional:true
            }
        }
    },
    action:async function(req,resp){
        await saveProduct(req.values)
        //no view returend and model(this) is stringify as json
    }
 }

Codegen


npm install wwpm -g
wwgen -s ./schema/ -o ./output -ns com.example
0.1.28

7 years ago

0.1.27

7 years ago

0.1.26

7 years ago

0.1.25

7 years ago

0.1.24

7 years ago

0.1.23

7 years ago

0.1.22

7 years ago

0.1.21

7 years ago

0.1.20

7 years ago

0.1.19

7 years ago

0.1.16

7 years ago

0.1.15

7 years ago

0.1.14

7 years ago

0.1.13

7 years ago

0.1.12

7 years ago

0.1.11

7 years ago

0.1.10

7 years ago

0.1.9

7 years ago

0.1.8

7 years ago

0.1.7

7 years ago

0.1.6

7 years ago

0.1.5

7 years ago

0.1.4

7 years ago

0.1.3

7 years ago

0.1.2

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago