Skip to content

Commit 0424bb5

Browse files
committed
fix: remove err param from .listen() callback;
- Closes #120, #163
1 parent 37bd282 commit 0424bb5

File tree

17 files changed

+17
-36
lines changed

17 files changed

+17
-36
lines changed

examples/async-json/index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ polka()
1717
});
1818
send(res, 200, data);
1919
})
20-
.listen(PORT, err => {
21-
if (err) throw err;
20+
.listen(PORT, () => {
2221
console.log(`> Running on localhost:${PORT}`);
2322
});

examples/sub-app/index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ polka()
1212
.get('/', reply)
1313
.get('/about', reply)
1414
.use('users', users)
15-
.listen(PORT, err => {
16-
if (err) throw err;
15+
.listen(PORT, () => {
1716
console.log(`> Running on localhost:${PORT}`);
1817
});

examples/with-afterjs/src/index.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,7 @@ import app from './server';
22

33
let { handler, server } = app;
44

5-
server.listen(process.env.PORT || 3000, error => {
6-
if (error) {
7-
console.log(error);
8-
}
9-
5+
server.listen(process.env.PORT || 3000, () => {
106
console.log('🚀 started');
117
});
128

examples/with-apollo/index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ polka()
4141
.get('/graphiql', graphiqlExpress({
4242
endpointURL: '/graphql'
4343
}))
44-
.listen(PORT, err => {
45-
if (err) throw err;
44+
.listen(PORT, () => {
4645
console.log(`> Ready on localhost:${PORT}`)
4746
});

examples/with-body-parser/index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ polka()
99
let json = JSON.stringify(req.body);
1010
res.end(json);
1111
})
12-
.listen(PORT, err => {
13-
if (err) throw err;
12+
.listen(PORT, () => {
1413
console.log(`> Running on localhost:${PORT}`);
1514
});

examples/with-firebase-admin/index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ const { PORT=3000 } = process.env;
99
polka()
1010
.use(cors, compress, json(), serve)
1111
.use('api', require('./api'))
12-
.listen(PORT, err => {
13-
if (err) throw err;
12+
.listen(PORT, () => {
1413
console.log(`> Running on localhost:${PORT}`);
1514
});

examples/with-graphql/index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ polka()
3939
send(res, 200, data);
4040
});
4141
})
42-
.listen(PORT, err => {
43-
if (err) throw err;
42+
.listen(PORT, () => {
4443
console.log(`> Ready on localhost:${PORT}`);
4544
});

examples/with-morgan/index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ polka()
1212
.get('/', (req, res) => {
1313
send(res, 'Index');
1414
})
15-
.listen(PORT, err => {
16-
if (err) throw err;
15+
.listen(PORT, () => {
1716
console.log(`> Ready on localhost:${PORT}`);
1817
});

examples/with-nextjs/index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ const handle = app.getRequestHandler();
1010
app.prepare().then(() => {
1111
polka()
1212
.get('*', handle)
13-
.listen(PORT, err => {
14-
if (err) throw err;
13+
.listen(PORT, () => {
1514
console.log(`> Ready on http://localhost:${PORT}`);
1615
});
1716
});

examples/with-nuxtjs/index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ if (dev) {
2323
}
2424

2525
function listen() {
26-
return app.listen(PORT, err => {
27-
if (err) throw err;
26+
return app.listen(PORT, () => {
2827
console.log(`> Ready on localhost:${PORT}`);
2928
});
3029
}

examples/with-sapper/server.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ global.fetch = (url, opts) => {
1414

1515
polka()
1616
.use(compression, static, sapper)
17-
.listen(PORT, err => {
18-
if (err) throw err;
17+
.listen(PORT, () => {
1918
console.log(`> Running on localhost:${PORT}`);
2019
});

examples/with-serve-static/index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ polka()
1010
.get('/health', (req, res) => {
1111
res.end('OK');
1212
})
13-
.listen(PORT, err => {
14-
if (err) throw err;
13+
.listen(PORT, () => {
1514
console.log(`> Running on localhost:${PORT}`);
1615
});

examples/with-sirv/index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ polka()
88
.get('/health', (req, res) => {
99
res.end('OK');
1010
})
11-
.listen(PORT, err => {
12-
if (err) throw err;
11+
.listen(PORT, () => {
1312
console.log(`> Running on localhost:${PORT}`);
1413
});

examples/with-socketio/index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ const { PORT=3000 } = process.env;
88
const files = sirv('public');
99
const server = http.createServer();
1010

11-
polka({ server }).use(files).listen(PORT, err => {
12-
if (err) throw err;
11+
polka({ server }).use(files).listen(PORT, () => {
1312
console.log(`> Running on localhost:${PORT}`);
1413
});
1514

examples/with-uws/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ const { handler } = polka().get('/', (req, res) => {
77
res.end('Hello');
88
});
99

10-
http.createServer(handler).listen(PORT, err => {
10+
http.createServer(handler).listen(PORT, () => {
1111
console.log(`> Running on localhost:${PORT}`);
1212
});

packages/polka/readme.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,7 @@ polka()
6565
console.log(`~> Hello, ${req.hello}`);
6666
res.end(`User: ${req.params.id}`);
6767
})
68-
.listen(3000, err => {
69-
if (err) throw err;
68+
.listen(3000, () => {
7069
console.log(`> Running on localhost:3000`);
7170
});
7271
```

readme.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,7 @@ polka()
6565
console.log(`~> Hello, ${req.hello}`);
6666
res.end(`User: ${req.params.id}`);
6767
})
68-
.listen(3000, err => {
69-
if (err) throw err;
68+
.listen(3000, () => {
7069
console.log(`> Running on localhost:3000`);
7170
});
7271
```

0 commit comments

Comments
 (0)