import { serve } from "bun"

const premissions = "300648825856"
export const startAuthServer = async (port = "3000") => {
  const server = serve({
    port,
    routes: {
      "/*": {
        async GET(req) {
          return new Response(
            `<html>
              <body>
                <h1>Authenticate spike</h1>
                <a href="https://discord.com/oauth2/authorize?client_id=${process.env.DISCORD_CLIENT_ID}&scope=bot&permissions=${premissions}">Authorize</a>
              </body>
            </html>`,
            {
              headers: {
                "Content-Type": "text/html",
              },
            }
          )
        },
      },
    },
  })

  console.log(`Server is running on ${server.url}`)
}
