Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update and add dependencies #240

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions api/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
},
"rules": {
"no-console": "off",
"no-underscore-dangle": "off",
"import/prefer-default-export": "off",
"max-len": [
"warn",
{
Expand Down
9 changes: 5 additions & 4 deletions api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@
"@babel/core": "^7.16.0",
"@babel/preset-env": "^7.16.0",
"babel-jest": "^27.3.1",
"eslint": "^7.32.0",
"eslint-config-airbnb-base": "14.2.1",
"eslint": "^8.5.0",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-import": "^2.25.3",
"eslint-plugin-prettier": "^3.4.1",
"prettier": "^2.4.1"
"eslint-plugin-prettier": "^4.0.0",
"jest": "^27.4.5",
"prettier": "^2.5.1"
},
"scripts": {
"start": "node -r esm server.js",
Expand Down
5 changes: 2 additions & 3 deletions api/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,18 @@ app.use(cors());

app.use('/api', createRoutes(app));

if (process.env.REDIRECT_TO_DOMAIN != undefined) {
if (process.env.REDIRECT_TO_DOMAIN) {
// If we are in heroku environment, force SSL / domain redirect
// given appropriate env
app.all(/.*/, function (req, res, next) {
const host = req.header('host');
if (host != process.env.REDIRECT_TO_DOMAIN) {
if (host !== process.env.REDIRECT_TO_DOMAIN) {
res.redirect(301, `https://${process.env.REDIRECT_TO_DOMAIN}`);
} else {
next();
}
});
app.use(enforce.HTTPS({ trustProtoHeader: true }));
} else {
}

app.use(express.static(`${__dirname}/dist`));
Expand Down
2 changes: 0 additions & 2 deletions api/setupTests.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
const jest = require('jest');

afterEach(() => {
jest.clearAllMocks();
});
1 change: 0 additions & 1 deletion api/src/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ export async function getTaxonomy() {
await indexZip.loadAsync(downloadedRepos.data);

// Iterate through all the .toml files
const orgs = [];
const issues = [];
const promises = [];
indexZip.folder('').forEach((path) => {
Expand Down
7 changes: 3 additions & 4 deletions api/src/routes.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { Router } from 'express';
import apicache from 'apicache';

import { getProjectIndex } from './api';
import { getTaxonomy } from './api';
import { getProjectIndex, getTaxonomy } from './api';

export function createRoutes(app) {
const router = Router();
Expand All @@ -12,7 +11,7 @@ export function createRoutes(app) {
});

router.get(['/', '/data.json'], app.cache('90 minutes'), (_, res) => {
getProjectIndex()
getProjectIndex()
.then((result) => {
res.json(result);
})
Expand Down Expand Up @@ -42,6 +41,6 @@ export function createRoutes(app) {
apicache.clear('/api/taxonomy.json');
res.redirect('/api/taxonomy.json');
});

return router;
}
Loading