Skip to content

Commit

Permalink
Merge branch 'main' into mixed-content-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
goastler authored Jan 29, 2024
2 parents 4eb2217 + b39ff46 commit 6937608
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
1 change: 1 addition & 0 deletions packages/cli/src/argv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export function processArgs(args: string[], pair: KeyringPair, config: ProsopoCo
return yargs(hideBin(args))
.usage('Usage: $0 [global options] <command> [options]')
.option('api', { demand: false, default: false, type: 'boolean' } as const)
.option('adminApi', { demand: false, default: false, type: 'boolean' } as const)
.command(commandProviderRegister(pair, config, { logger }))
.command(commandProviderUpdate(pair, config, { logger }))
.command(commandProviderDeregister(pair, config, { logger }))
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/reloader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export default class ReloadingAPI {
this._envWatcher = await this._watchEnv()
const env = new ProviderEnvironment(this._config, this._pair)
await env.isReady()
this.api = await start(env)
this.api = await start(env, !!this._processedArgs.adminApi)
}

public async stop() {
Expand Down
10 changes: 6 additions & 4 deletions packages/cli/src/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export const handleErrors = (
})
}

function startApi(env: ProviderEnvironment): Server {
function startApi(env: ProviderEnvironment, admin = false): Server {
env.logger.info(`Starting Prosopo API`)
const apiApp = express()
const apiPort = env.config.server.port
Expand All @@ -51,15 +51,17 @@ function startApi(env: ProviderEnvironment): Server {
apiApp.use(express.json({ limit: '50mb' }))
apiApp.use(i18nMiddleware({}))
apiApp.use(prosopoRouter(env))
apiApp.use(prosopoAdminRouter(env))
if (admin) {
apiApp.use(prosopoAdminRouter(env))
}

apiApp.use(handleErrors)
return apiApp.listen(apiPort, () => {
env.logger.info(`Prosopo app listening at http://localhost:${apiPort}`)
})
}

export async function start(env?: ProviderEnvironment) {
export async function start(env?: ProviderEnvironment, admin?: boolean) {
if (!env) {
loadEnv()

Expand All @@ -75,5 +77,5 @@ export async function start(env?: ProviderEnvironment) {
env = new ProviderEnvironment(config, pair)
}
await env.isReady()
return startApi(env)
return startApi(env, admin)
}

0 comments on commit 6937608

Please sign in to comment.