Skip to content

How to use with oak? #9

Answered by darrachequesne
arnur-s asked this question in Q&A
Nov 27, 2022 · 1 comments · 3 replies
Discussion options

You must be logged in to vote

Hi! You need to use the .handle() method:

import { serve } from "https://deno.land/[email protected]/http/server.ts";
import { Server } from "https://deno.land/x/[email protected]/mod.ts";
import { Application } from "https://deno.land/x/[email protected]/mod.ts";

const app = new Application();

app.use((ctx) => {
    ctx.response.body = "Hello World!";
});

const io = new Server();

io.on("connection", (socket) => {
    console.log(`socket ${socket.id} connected`);

    socket.emit("hello", "world");

    socket.on("disconnect", (reason) => {
        console.log(`socket ${socket.id} disconnected due to ${reason}`);
    });
});

const handler = io.handler(async (req) => {
    return await app.handle(req)

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@NovqiGarrix
Comment options

@darrachequesne
Comment options

@NovqiGarrix
Comment options

Answer selected by darrachequesne
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants