Skip to content

Commit

Permalink
Changed parser to use supabase
Browse files Browse the repository at this point in the history
  • Loading branch information
TueeNguyen committed Apr 4, 2022
1 parent 30751aa commit 4ff49ab
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
4 changes: 4 additions & 0 deletions docker/development.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 9 additions & 5 deletions src/api/parser/src/lib/supabase.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
},
};
1 change: 0 additions & 1 deletion src/api/parser/src/parser.js
Original file line number Diff line number Diff line change
@@ -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');

Expand Down

0 comments on commit 4ff49ab

Please sign in to comment.