문서›Edge Functions›Your first function 첫 번째 엣지 기능
함수를 작성하고, 프로젝트에 배포하고, Node.js에서 호출하고, 결과를 읽습니다. 아래의 모든 명령은 실제로 실행되었습니다.
10분 읽기·레벨 초보자·2026. 10. 12.에 개정됨
이 영어 텍스트는 프랑스어 원본에서 자동으로 생성되었으며 아직 검토되지 않았습니다.
이 페이지는 자동으로 번역되었습니다. 영어 버전은 권위가 있습니다.
당신은 다음이 필요합니다
- Node.js 20 이상.
aura CLI. npm install -g @aurabase/cli를 사용하여 설치합니다(다른 플랫폼의 경우 CLI 참조 참조).
- Aurabase 계정.
CLI는 오늘날 프랑스어를 사용합니다.
aura CLI는 메시지를 프랑스어로 인쇄합니다. 아래 출력은 번역되지 않고 실제 실행에서 복사되었습니다.
로그인하여 프로젝트를 생성하고 작업 폴더를 해당 프로젝트에 연결하세요. <org-slug>를 aura orgs list에 표시된 슬러그로 바꿉니다.
terminalbash
aura login --email you@example.com --password '<your-password>'
aura orgs list
aura projects create my-app --org <org-slug>
마지막 명령은 프로젝트 URL과 첫 번째 API 키를 인쇄합니다. 지금 복사하세요. 초기 키는 한 번만 표시됩니다. 누락된 경우 Studio의 설정, API 키 아래에서 새 항목을 만드세요.
outputtext
✔ Projet créé : my-app (e99f2c4f-43e2-4d08-b023-b4f9e687d17c)
import { createClient } from '@aurabase/aurabase-js'
const client = createClient('http://my-app-ajap5iw2.localhost:8080', 'aura_anon_…')
현재 폴더를 프로젝트에 연결합니다.
terminalbash
aura link --project-id e99f2c4f-43e2-4d08-b023-b4f9e687d17c
outputtext
✔ Projet e99f2c4f-… lié dans aurabase.toml.
• URL du projet : http://my-app-ajap5iw2.localhost:8080
그런 다음 데이터 플레인의 위치와 사용할 키를 CLI에 알려줍니다. 코드 배포는 관리 작업이므로 배포하려면 service_role 키가 필요합니다.
.envbash
AURA_PROJECT_URL=http://my-app-ajap5iw2.localhost:8080
AURA_API_KEY=<your service_role key>
컴퓨터에 service_role 키를 유지하세요.
service_role 키는 행 수준 보안을 우회하고 코드를 배포할 수 있습니다. 브라우저 번들에 넣거나 .env을 커밋하지 마세요.
terminalbash
aura functions new hello
outputtext
✔ Nouvelle fonction créée dans aurabase/functions/hello (gabarit TypeScript Deno)
aurabase/functions/hello/index.ts을 열고 내용을 바꿉니다.
aurabase/functions/hello/index.tstypescript
Deno.serve(async (req: Request) => {
const { name = 'world' } = await req.json().catch(() => ({}))
return new Response(JSON.stringify({ greeting: `Hello, ${name}!` }), {
headers: { 'content-type': 'application/json' },
})
})
함수는 Deno.serve를 호출해야 합니다. export default은 호출되지 않습니다.
terminalbash
aura functions deploy hello
outputtext
✔ Détection script TypeScript (runtime: deno)...
• Envoi vers le service (runtime: deno)...
✔ Fonction 'hello' déployée avec succès !
CLI에서 한 번 호출하여 응답하는지 확인합니다.
terminalbash
aura functions invoke hello --data '{"name":"Ada"}'
outputtext
✔ Réponse (200) :
{
"data": {
"body": { "greeting": "Hello, Ada!" },
"duration_ms": 74,
…
terminalbash
mkdir hello-client && cd hello-client
npm init -y
npm install @aurabase/aurabase-js
hello.mjstypescript
import { createClient } from '@aurabase/aurabase-js'
const aura = createClient(process.env.AURA_PROJECT_URL, process.env.AURA_ANON_KEY)
const { data, error } = await aura.functions.invoke('hello', { body: { name: 'Ada' } })
if (error) throw error
console.log(data.greeting)
terminalbash
AURA_PROJECT_URL=http://my-app-ajap5iw2.localhost:8080 AURA_ANON_KEY=aura_anon_… node hello.mjs
You called a function with the public anon key. That is the only call a public key can make: see who can call what.