공부방/Supabase

Supabase edge function Deno oak 사용시 설정

soycrab 2024. 4. 22. 21:43

Supabase edge function 을 사용하여 프로젝트를 설정하였고, 

oak를 사용한다면 

Router prefix를 설정해 주어야 해요.

만약 edge function 이름을 Test 라고 지었다면 

아래처럼 설정 해주세요.

const router = new Router({ prefix: "/Test" })

 

import { Application, Router } from 'https://deno.land/x/oak@v11.1.0/mod.ts'
import { route } from 'https://deno.land/x/oak@v16.0.0/middleware/serve.ts';

const router = new Router({ prefix: "/Test" })
router
  // Note: path should be prefixed with function name
  .get('/oak-server', (context) => {
    context.response.body = 'This is an example Oak server running on Edge Functions!'
  })
  
const app = new Application()
app.use(router.routes())
app.use(router.allowedMethods())

await app.listen({ port: 8000 })
반응형