diff --git a/api/api/api.ts b/api/api/api.ts index f3aacecb..a9ba5358 100644 --- a/api/api/api.ts +++ b/api/api/api.ts @@ -1,4 +1,4 @@ -import { api, APIError } from "encore.dev/api" +import { api } from "encore.dev/api" // import { startWorker } from "jazz-nodejs" // import { ID } from "jazz-tools" import { secret } from "encore.dev/config" @@ -10,9 +10,9 @@ const jazzPublicGlobalGroup = secret("jazzPublicGlobalGroup") export const testRoute = api( { expose: true, method: "GET", path: "/test" }, - async ({}: {}): Promise => { - console.log(jazzPublicGlobalGroup(), "group") + async ({}: {}): Promise<{ message: string }> => { log.info("better logs from encore") + return { message: `Hello from encore` } } ) diff --git a/api/api/links.ts b/api/api/links.ts index 9c17de3d..3b6411f1 100644 --- a/api/api/links.ts +++ b/api/api/links.ts @@ -2,18 +2,27 @@ // it is responsible for adding and getting links into LA from API import { api, APIError } from "encore.dev/api" -// import { startWorker } from "jazz-nodejs" +import { startWorker } from "jazz-nodejs" import { secret } from "encore.dev/config" +import log from "encore.dev/log" const jazzWorkerSecret = secret("jazzWorkerSecret") -export const addPersonalLink = api( +export const saveLink = api( { expose: true, method: "POST", path: "/save-link" }, - async ({ url }: { url: string }): Promise => { + // TODO: perhaps apiKey only is enough? + async ({ url, email, apiKey }: { url: string; email: string; apiKey: string }): Promise => { // const { worker } = await startWorker({ // accountID: "co_zhvp7ryXJzDvQagX61F6RCZFJB9", // accountSecret: JAZZ_WORKER_SECRET // }) + + // log.info(jazzWorkerSecret) + + if (!url.includes("http")) { + throw APIError.invalidArgument("url must include http") + } + log.info("addPersonalLink", { url }) } ) diff --git a/api/bun.lockb b/api/bun.lockb index 6408494b..5f5ec06e 100755 Binary files a/api/bun.lockb and b/api/bun.lockb differ diff --git a/api/readme.md b/api/readme.md index 437b2b1c..f289a28c 100644 --- a/api/readme.md +++ b/api/readme.md @@ -1 +1,7 @@ Using [Encore](https://encore.dev). + +## Run + +``` +encore run +``` diff --git a/bun.lockb b/bun.lockb index 263389b0..8d317c47 100755 Binary files a/bun.lockb and b/bun.lockb differ