-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
50 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,39 @@ | ||
import type express from 'express'; | ||
import express from 'express'; | ||
import asyncHandler from 'express-async-handler'; | ||
import { verifyHeaders, refreshCatalog } from './catalog.handlers.js'; | ||
import { authWithEvals } from '../auth/auth.handlers.js'; | ||
import { STATIC_FILE_DIR } from '../config.js'; | ||
|
||
const staticJSON = (path: string) => | ||
express.static(`${STATIC_FILE_DIR}${path}`, { | ||
cacheControl: true, | ||
maxAge: '1h', | ||
lastModified: true, | ||
etag: true, | ||
extensions: ['json'], | ||
}); | ||
|
||
export default (app: express.Express): void => { | ||
// Enable static catalog refresh on demand. | ||
// After the crawler runs, we hit this route to refresh the static files. | ||
app.get('/api/catalog/refresh', verifyHeaders, asyncHandler(refreshCatalog)); | ||
|
||
// Evals data require NetID authentication | ||
app.use( | ||
'/api/catalog/evals', | ||
authWithEvals, | ||
staticJSON('/catalogs-v2/evals'), | ||
); | ||
|
||
// Serve public catalog files without authentication | ||
app.use('/api/catalog/public', staticJSON('/catalogs-v2/public')); | ||
|
||
// Legacy data formats | ||
// TODO: remove | ||
app.use( | ||
'/api/static/catalogs/evals', | ||
authWithEvals, | ||
staticJSON('/catalogs/evals'), | ||
); | ||
app.use('/api/static/catalogs/public', staticJSON('/catalogs/public')); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters