Skip to content

Commit

Permalink
Use local auth .txt files in "non-deployed" environments
Browse files Browse the repository at this point in the history
  • Loading branch information
howard-e committed Oct 16, 2024
1 parent 8f522ed commit b15796e
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions server/util/getUsersFromFile.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,22 @@
const path = require('path');
const fs = require('fs/promises');

const getUsersFromFile = async file => {
const response = await fetch(
// This needs to be switched back the commented out path.
// `https://raw.githubusercontent.com/w3c/aria-at-app/main/${file}`
`https://raw.githubusercontent.com/w3c/aria-at-app/development/${file}`
);
const roleGroupTxt = await response.text();
const isDeployed =
process.env.ENVIRONMENT === 'sandbox' ||
process.env.ENVIRONMENT === 'staging' ||
process.env.ENVIRONMENT === 'production';

let roleGroupTxt;
if (isDeployed) {
const response = await fetch(
`https://raw.githubusercontent.com/w3c/aria-at-app/development/${file}`
);
roleGroupTxt = await response.text();
} else {
const filePath = path.join(__dirname, `../../${file}`);
roleGroupTxt = await fs.readFile(filePath, { encoding: 'utf8' });
}
const linesRaw = roleGroupTxt.split('\n');
const noComments = linesRaw.filter(line => line.substr(0, 1) !== '#');
const noEmpties = noComments.filter(line => line.trim().length > 0);
Expand Down

0 comments on commit b15796e

Please sign in to comment.