|
|
@ -1,4 +1,10 @@ |
|
|
class Server { |
|
|
import { Auth } from './auth' |
|
|
|
|
|
|
|
|
|
|
|
export class Server { |
|
|
|
|
|
constructor() { |
|
|
|
|
|
this.auth = new Auth() |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
async getEnv(variables) { |
|
|
async getEnv(variables) { |
|
|
return Object.fromEntries( |
|
|
return Object.fromEntries( |
|
|
await Promise.all( |
|
|
await Promise.all( |
|
|
@ -27,18 +33,15 @@ class Server { |
|
|
async serveRequest(event) { |
|
|
async serveRequest(event) { |
|
|
const {pathname} = new URL(event.request.url) |
|
|
const {pathname} = new URL(event.request.url) |
|
|
if (pathname === `${this.baseUrl}/api/auth`) { |
|
|
if (pathname === `${this.baseUrl}/api/auth`) { |
|
|
event.respondWith(new Response( |
|
|
await this.auth.redirect(event) |
|
|
'extract query and redirect', {status: 200} |
|
|
|
|
|
)) |
|
|
|
|
|
} else { |
|
|
} else { |
|
|
event.respondWith(new Response( |
|
|
event.respondWith(new Response( |
|
|
'here', {status: 404} |
|
|
'Not Found', {status: 404} |
|
|
)) |
|
|
)) |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
async serveConn(conn) { |
|
|
async serveConn(conn) { |
|
|
console.log({conn}) |
|
|
|
|
|
const httpConn = Deno.serveHttp(conn) |
|
|
const httpConn = Deno.serveHttp(conn) |
|
|
for await (const event of httpConn) { |
|
|
for await (const event of httpConn) { |
|
|
this.serveRequest(event) |
|
|
this.serveRequest(event) |
|
|
|