mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-23 12:56:46 +08:00
15 lines
318 B
TypeScript
15 lines
318 B
TypeScript
import * as Koa from 'koa';
|
|
import * as websocket from 'koa-websocket';
|
|
|
|
const app = websocket(new Koa());
|
|
|
|
app.ws.use(async function(context, next) {
|
|
this.websocket.on('message', (message) => {
|
|
console.log(message);
|
|
});
|
|
this.websocket.send('Hello world');
|
|
await next();
|
|
});
|
|
|
|
app.listen(3000);
|