Skip to content

Commit

Permalink
fix: prepend
Browse files Browse the repository at this point in the history
  • Loading branch information
kaivean committed Mar 11, 2023
1 parent e4440c5 commit cde98e4
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions packages/cli/src/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ async function runFastify(opts: Args) {
});

const routes: RouteOptions[] = [];

fastifyInstance.decorate('$addedRoutes', routes);
fastifyInstance.addHook('onRoute', routeOptions => {
routes.push(routeOptions);
});
Expand Down Expand Up @@ -192,19 +192,12 @@ async function runFastify(opts: Args) {
address = await fastifyInstance.listen(opts.port);
}

const showAddress = address === `0.0.0.0:${opts.port}` ? `${getOuterIP()}:${opts.port}` : address;

const showAddress = address.replace('0.0.0.0', getOuterIP());
console.log(`Server listening on ${showAddress}.`);
for (const route of routes) {
console.log('——', `${showAddress}${route.url} (${route.method})`);
}

console.log(`Server listening on ${address}.`);
for (const route of routes) {
console.log('——', `${address}${route.url} (${route.method})`);
}

fastifyInstance.decorate('$addedRoutes', routes);

// for pm2 graceful start
if (process.send) {
process.send('ready');
Expand Down

0 comments on commit cde98e4

Please sign in to comment.