Skip to content

Commit

Permalink
feat: Add port option to cli server
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason Healy committed Oct 21, 2020
1 parent 4b4b365 commit 4f66a38
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions packages/daf-cli/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import { getAgent, getConfig } from './setup'
program
.command('server')
.description('Launch OpenAPI server')
.action(async () => {
.option('-p, --port <number>', 'Optionally set port to override config')
.action(async (cmd) => {
const app = express()
const agent = getAgent(program.config)
const { server: options } = getConfig(program.config)
Expand All @@ -28,16 +29,16 @@ program

app.use(apiBasePath, agentRouter)

app.listen(options.port, async () => {
console.log(`🚀 Agent server ready at http://localhost:${options.port}`)
app.listen(cmd.port || options.port, async () => {
console.log(`🚀 Agent server ready at http://localhost:${cmd.port || options.port}`)
console.log('🧩 Available methods', agent.availableMethods().length)
console.log('🛠 Exposed methods', exposedMethods.length)

let baseUrl = options.baseUrl

if (options.ngrok?.connect) {
baseUrl = await ngrok.connect({
addr: options.port,
addr: cmd.port || options.port,
subdomain: options.ngrok.subdomain,
region: options.ngrok.region,
authtoken: options.ngrok.authtoken,
Expand Down

0 comments on commit 4f66a38

Please sign in to comment.