I have just two files list below, after Deno.env.get got 8083 from .env. But got an error. What can I do?
Edited: when I comment out all the dotenv related code, still got this error. Maybe it is not deno-dotenv problem, but I asked here to see if anyone knows what can I do.
Edited final: I know why is going wrong here... it must need to code: parseInt(Deno.env.get('PORT') so the new App(PORT) can be worked... I will close this issue later, Sorry to bother you!
server.ts
import { Application } from "https://deno.land/x/oak/mod.ts"
import 'https://deno.land/x/dotenv/load.ts'
const PORT = Deno.env.get('PORT')
console.log(PORT)
export class App {
public app: Application
public port: number
public logger: any
constructor(port: any) {
this.app = new Application()
this.port = port
this.initializeMiddleware()
}
private initializeMiddleware() {
this.app.use(async (ctx, next) => {
await next()
const rt = ctx.response.headers.get("X-Response-Time")
console.log(`${ctx.request.method} ${ctx.request.url} - ${rt}`)
})
}
public async listen() {
console.log("Server is listening at http://localhost:", this.port)
return await this.app.listen({ port: this.port })
}
}
const app = new App(PORT)
app.listen()
.env
PORT=8083
error message
Server is listening at http://localhost: 8083
error: Uncaught InvalidData: data did not match any variant of untagged enum ArgsEnum
at unwrapResponse ($deno$/ops/dispatch_json.ts:42:11)
at Object.sendSync ($deno$/ops/dispatch_json.ts:69:10)
at Object.listen ($deno$/ops/net.ts:51:10)
at Object.listen ($deno$/net.ts:155:22)
at listen ($deno$/net_unstable.ts:36:12)
at Application.serve (https://deno.land/std@0.56.0/http/server.ts:252:20)
at Application.listen (https://deno.land/x/oak/application.ts:295:20)
at App.listen (app.ts:40:27)
at server.ts:12:5
I have just two files list below, after
Deno.env.get
got8083
from.env
. But got an error. What can I do?Edited: when I comment out all the
dotenv
related code, still got this error. Maybe it is notdeno-dotenv
problem, but I asked here to see if anyone knows what can I do.Edited final: I know why is going wrong here... it must need to code:
parseInt(Deno.env.get('PORT')
so thenew App(PORT)
can be worked... I will close this issue later, Sorry to bother you!server.ts
.env
error message
Deno Version