mirror of
https://github.com/openstf/stf
synced 2025-10-04 10:19:30 +02:00
Add basic api unit. This unit will be responsible for providing all stf restful apis.
This commit is contained in:
parent
7ea7871ec0
commit
41f306a7f0
7 changed files with 172 additions and 0 deletions
41
lib/cli.js
41
lib/cli.js
|
@ -758,6 +758,9 @@ program
|
|||
.option('-u, --app-url <url>'
|
||||
, 'URL to app'
|
||||
, String)
|
||||
.option('-u, --api-url <url>'
|
||||
, 'URL to api'
|
||||
, String)
|
||||
.option('-a, --auth-url <url>'
|
||||
, 'URL to auth client'
|
||||
, String)
|
||||
|
@ -780,6 +783,9 @@ program
|
|||
if (!options.authUrl) {
|
||||
this.missingArgument('--auth-url')
|
||||
}
|
||||
if (!options.apiUrl) {
|
||||
this.missingArgument('--api-url')
|
||||
}
|
||||
if (!options.websocketUrl) {
|
||||
this.missingArgument('--websocket-url')
|
||||
}
|
||||
|
@ -796,6 +802,7 @@ program
|
|||
require('./units/poorxy')({
|
||||
port: options.port
|
||||
, appUrl: options.appUrl
|
||||
, apiUrl: options.apiUrl
|
||||
, authUrl: options.authUrl
|
||||
, websocketUrl: options.websocketUrl
|
||||
, storageUrl: options.storageUrl
|
||||
|
@ -849,6 +856,28 @@ program
|
|||
})
|
||||
})
|
||||
|
||||
program
|
||||
.command('api')
|
||||
.description('start api')
|
||||
.option('-p, --port <port>'
|
||||
, 'port (or $PORT)'
|
||||
, Number
|
||||
, process.env.PORT || 7106)
|
||||
.option('-s, --secret <secret>'
|
||||
, 'secret (or $SECRET)'
|
||||
, String
|
||||
, process.env.SECRET)
|
||||
.action(function(options) {
|
||||
if (!options.secret) {
|
||||
this.missingArgument('--secret')
|
||||
}
|
||||
|
||||
require('./units/api')({
|
||||
port: options.port
|
||||
, secret: options.secret
|
||||
})
|
||||
})
|
||||
|
||||
program
|
||||
.command('websocket')
|
||||
.description('start websocket')
|
||||
|
@ -1110,6 +1139,10 @@ program
|
|||
, 'app port'
|
||||
, Number
|
||||
, 7105)
|
||||
.option('--api-port <port>'
|
||||
, 'api port'
|
||||
, Number
|
||||
, 7106)
|
||||
.option('--websocket-port <port>'
|
||||
, 'websocket port'
|
||||
, Number
|
||||
|
@ -1285,6 +1318,12 @@ program
|
|||
return extra
|
||||
})()))
|
||||
|
||||
// api
|
||||
, procutil.fork(__filename, [
|
||||
'api'
|
||||
, '--port', options.apiPort
|
||||
, '--secret', options.authSecret
|
||||
])
|
||||
// websocket
|
||||
, procutil.fork(__filename, [
|
||||
'websocket'
|
||||
|
@ -1326,6 +1365,8 @@ program
|
|||
, util.format('http://localhost:%d/', options.appPort)
|
||||
, '--auth-url'
|
||||
, util.format('http://localhost:%d/', options.authPort)
|
||||
, '--api-url'
|
||||
, util.format('http://localhost:%d/', options.apiPort)
|
||||
, '--websocket-url'
|
||||
, util.format('http://localhost:%d/', options.websocketPort)
|
||||
, '--storage-url'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue