Skip to content

Commit

Permalink
FCC Integration updates
Browse files Browse the repository at this point in the history
  • Loading branch information
lwjameson committed Oct 25, 2023
1 parent 2f2f2f2 commit bc52fb0
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 57 deletions.
26 changes: 0 additions & 26 deletions .github/workflows/production.yaml

This file was deleted.

26 changes: 0 additions & 26 deletions .github/workflows/staging.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion supabase/config.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# A string used to distinguish different Supabase projects on the same host. Defaults to the working
# directory name when running `supabase init`.
project_id = "recogito-bonn"
project_id = "recogito-server"

[api]
# Port to use for the API URL.
Expand Down
2 changes: 1 addition & 1 deletion supabase/functions/.env.example
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
FCC_URL=
FCC_API_URL=
FCC_SERVICE_KEY=
17 changes: 17 additions & 0 deletions supabase/functions/fcc-get-document-url/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Follow this setup guide to integrate the Deno language server with your editor:
// https://deno.land/manual/getting_started/setup_your_environment
// This enables autocomplete, go to definition, etc.

import { serve } from 'server';

serve(async (req) => {
const { xml_id } = await req.json();

const data = {
xml_id: xml_id,
fcc_url: `${Deno.env.get('FCC_URL')}/documents/${xml_id}/tei`,
};
return new Response(JSON.stringify(data), {
headers: { 'Content-Type': 'application/json' },
});
});
31 changes: 31 additions & 0 deletions supabase/functions/fcc-get-project-documents/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Follow this setup guide to integrate the Deno language server with your editor:
// https://deno.land/manual/getting_started/setup_your_environment
// This enables autocomplete, go to definition, etc.

import { serve } from 'server';
import { createClient } from 'supabase';

serve(async (req) => {
const { project_id } = await req.json();

const supabase = createClient(
Deno.env.get('FCC_API_URL'),
Deno.env.get('FCC_SERVICE_KEY'),
{
auth: {
persistSession: true,
autoRefreshToken: true,
detectSessionInUrl: false,
},
}
);

const projectsResp = await supabase
.from('tei_documents')
.select('id, xml_id, name')
.eq('project_id', project_id);

return new Response(JSON.stringify(projectsResp.data), {
headers: { 'Content-Type': 'application/json' },
});
});
4 changes: 2 additions & 2 deletions supabase/functions/fcc-list-projects/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
// https://deno.land/manual/getting_started/setup_your_environment
// This enables autocomplete, go to definition, etc.

import { serve } from 'https://deno.land/[email protected]/http/server.ts';
import { serve } from 'server';
import { createClient } from 'supabase';

serve(async (req) => {
const supabase = createClient(
Deno.env.get('FCC_URL'),
Deno.env.get('FCC_API_URL'),
Deno.env.get('FCC_SERVICE_KEY'),
{
auth: {
Expand Down
3 changes: 2 additions & 1 deletion supabase/functions/import_map.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"imports": {
"supabase": "https://esm.sh/@supabase/supabase-js@2"
"supabase": "https://esm.sh/@supabase/supabase-js@2",
"server": "https://deno.land/[email protected]/http/server.ts"
}
}

0 comments on commit bc52fb0

Please sign in to comment.