From 4ff49ab90090392d50e1291bf6e61c5f8027f43b Mon Sep 17 00:00:00 2001 From: Tue Nguyen Date: Mon, 4 Apr 2022 18:04:05 -0400 Subject: [PATCH] Changed parser to use supabase --- docker/development.yml | 4 ++++ docker/docker-compose.yml | 2 ++ src/api/parser/src/lib/supabase.js | 14 +++++++++----- src/api/parser/src/parser.js | 1 - 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/docker/development.yml b/docker/development.yml index cc0f3422aa..0a4819ba08 100644 --- a/docker/development.yml +++ b/docker/development.yml @@ -90,6 +90,10 @@ services: context: ../src/api/parser cache_from: - docker.cdot.systems/parser:buildcache + environment: + # In development and testing, the SSO service needs to contact the Supabase + # service directly via Docker vs through the http://localhost/v1/supabase domain. + - SUPABASE_URL=http://kong:8000 depends_on: - elasticsearch - traefik diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 96c3df9116..f30bc51a3f 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -196,6 +196,8 @@ services: - ELASTIC_MAX_RESULTS_PER_PAGE - ELASTIC_URL=http://elasticsearch - ELASTIC_PORT=9200 + - SERVICE_ROLE_KEY + - SUPABASE_URL # Satellite authentication/authorization support - JWT_ISSUER - JWT_AUDIENCE diff --git a/src/api/parser/src/lib/supabase.js b/src/api/parser/src/lib/supabase.js index 6eb9cff05a..7ae42bb175 100644 --- a/src/api/parser/src/lib/supabase.js +++ b/src/api/parser/src/lib/supabase.js @@ -2,18 +2,22 @@ const { logger } = require('@senecacdot/satellite'); const { createClient } = require('@supabase/supabase-js'); const { SERVICE_ROLE_KEY, SUPABASE_URL } = process.env; - +console.log(SERVICE_ROLE_KEY); +console.log(SUPABASE_URL); const supabase = createClient(SUPABASE_URL, SERVICE_ROLE_KEY); module.exports = { getAllFeeds: async () => { - const { data, error } = await supabase - .from('feeds') - .select('wiki_author_name as author, html_url as url'); + const { data: feeds, error } = await supabase.from('feeds').select('wiki_author_name, url'); if (error) { logger.warn({ error }); throw Error(error.message, "can't fetch feeds from supabase"); } - return data; + const formattedFeeds = feeds.map((feed) => ({ + author: feed.wiki_author_name, + url: feed.url, + })); + console.log(formattedFeeds[0]); + return formattedFeeds; }, }; diff --git a/src/api/parser/src/parser.js b/src/api/parser/src/parser.js index 38a5fa4b66..058e0402f0 100644 --- a/src/api/parser/src/parser.js +++ b/src/api/parser/src/parser.js @@ -1,6 +1,5 @@ const { logger } = require('@senecacdot/satellite'); const { feedQueue } = require('./feed/queue'); -const getFeeds = require('./utils/wiki-feed-parser'); const Feed = require('./data/feed'); const { getAllFeeds } = require('./lib/supabase');