Methods
WRestapi(opt)
- Description:
建立http API伺服器
- Source:
Parameters:
Name | Type | Description | |||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opt |
Object | 輸入設定參數物件 Properties
|
routesToAPI(routesopt, apiParentopt, procopt) → {Array}
- Description:
由Routes陣列資料轉hapi的API資料陣列
- Source:
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
routes |
Array |
<optional> |
[]
|
輸入需自動產製的routes資料陣列,每個元素需有'apiName'欄位,其值給予表名字串,'props'欄位,其值給予欄位物件,預設[] |
apiParent |
String |
<optional> |
'api'
|
輸入api上層路徑字串,預設'api' |
proc |
function |
<optional> |
() => {}
|
輸入各api處理函數,prop會傳入method(API method),apiName(表名),propName(指定欄位名稱),propValue(指定欄位值),payload(post時數據),req(hapi的req),res(hapi的res),pm(回傳用Promise),處理完畢後成功時呼叫pm.resolve回傳,失敗時呼叫pm.reject回傳,預設()=>{} |
Returns:
回傳hapi的API資料陣列
- Type
- Array
routesToSwagger(hostopt, apiParentopt, routesopt) → {Object}
- Description:
由Routes陣列資料轉Swagger的設定物件
- Source:
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
host |
String |
<optional> |
'localhost:8080'
|
輸入伺服器所在host字串,預設'localhost:8080' |
apiParent |
String |
<optional> |
'api'
|
輸入api上層路徑字串,預設'api' |
routes |
Array |
<optional> |
[]
|
輸入Routes陣列,每個物件皆需要有表名字串'apiName'、主鍵名字串'pk'、物件所屬欄位物件'props',預設[] |
Returns:
回傳Swagger的設定物件
- Type
- Object