Skip to content

Commit

Permalink
fix: port binding and multiple endpoint (vercel#480)
Browse files Browse the repository at this point in the history
  • Loading branch information
oklas committed Feb 17, 2023
1 parent 73dd475 commit fa2e14c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/micro/src/bin/micro.ts
Expand Up @@ -20,7 +20,7 @@ import type { RequestHandler } from '../lib';

// Check if the user defined any options
const args = arg({
'--listen': parseEndpoint,
'--listen': [parseEndpoint],
'-l': '--listen',
'--help': Boolean,
'--version': Boolean,
Expand Down Expand Up @@ -142,15 +142,15 @@ function registerShutdown(fn: () => void) {
process.on('exit', wrapper);
}

function startEndpoint(module: RequestHandler, endpoint: string) {
function startEndpoint(module: RequestHandler, endpoint: string[]) {
const server = new http.Server(serve(module));

server.on('error', (err) => {
console.error('micro:', err.stack);
process.exit(1);
});

server.listen(endpoint, () => {
server.listen(...endpoint, () => {
const details = server.address();
registerShutdown(() => {
console.log('micro: Gracefully shutting down. Please wait...');
Expand Down

0 comments on commit fa2e14c

Please sign in to comment.