move auth endpoint to separate file

shared-server
bat 3 years ago
parent 5bfc5bbb22
commit dcaf72e700

@ -0,0 +1,7 @@
export class Auth {
async redirect(event) {
event.respondWith(new Response(
'extract query and redirect', {status: 200}
))
}
}

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

Loading…
Cancel
Save