babakfpB
Denoβ€’2y agoβ€’
7 replies
babakfp

Deno Oak doesnt work when compiled to `.exe`

Hi πŸ‘‹

I have this example from Deno site and when compile it to .exe and run it, I get the longs in the console of the .exe.

const port = 8080

const handler = (request: Request): Response => {
    const body = `Your user-agent is:\n\n${
        request.headers.get("user-agent") ?? "Unknown"
    }`

    return new Response(body, { status: 200 })
}

console.log(`HTTP server running. Access it at: http://localhost:8080/`)
Deno.serve({ port }, handler)


I have something similar with Oak:

import { Application, Router } from "oak"
import { operation } from "../utilities/operation.ts"
import { join } from "std/path/join.ts"

const PORT = 8000

const ROUTER = new Router()

ROUTER.get("/", (ctx) => {
    ctx.response.type = "text/html"
    ctx.response.body = Deno.readTextFileSync("./src/pages/index.html")
})

ROUTER.post("/", async (ctx) => {
    const FORM_DATA = await ctx.request.body.formData()

    try {
        await operation({
            "font-family": (FORM_DATA.get("font-family") ?? "") as string,
            "css-content": (FORM_DATA.get("custom-css") ?? "") as string,
            "restore-backup": FORM_DATA.has("restore-backup") as boolean,
        })

        ctx.response.redirect("/")
    } catch (error: unknown) {
        if (!(error instanceof Error)) throw error
        ctx.response.body = error.message
    }
})

const APP = new Application()

APP.use(ROUTER.routes())

APP.use(async (ctx, next) => {
    try {
        await ctx.send({
            root: join(Deno.cwd(), "/src/static"),
        })
    } catch {
        next()
    }
})

console.log("Open the URL in your browser:")
console.log(`http://localhost:${PORT}`)

await APP.listen({ port: PORT })


The problem is that I don't get the longs in the console of the .exe when I run it. I don't get any errors, it's just a blank terminal.

Does Oak does something behind the seen that breaks this? I can't use other frameworks if they don't have the same issue.
Was this page helpful?