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

Feature/issue 1007 api routes #1017

Merged
merged 20 commits into from
Dec 17, 2022
Merged
Changes from 1 commit
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
Prev Previous commit
app exists check for API routes
thescientist13 committed Dec 17, 2022
commit 87216d71c2a02dd9e37959e6f92f1c7ff4a44a06
6 changes: 4 additions & 2 deletions packages/cli/src/plugins/resource/plugin-api-routes.js
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@
* Manages routing to API routes.
*
*/
import fs from 'fs';
import { ResourceInterface } from '../../lib/resource-interface.js';

class ApiRoutesResource extends ResourceInterface {
@@ -11,8 +12,9 @@ class ApiRoutesResource extends ResourceInterface {
}

async shouldServe(url) {
// TODO check it exists first. Could this come from the graph?
return url.startsWith('/api');
// TODO Could this existance check be derived from the graph instead?
// https://github.com/ProjectEvergreen/greenwood/issues/946
return url.startsWith('/api') && fs.existsSync(this.compilation.context.apisDir, url);
}

async serve(url) {