Skip to content

server: improve error message when client is not present #1242

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

Merged
merged 1 commit into from
Jan 19, 2024
Merged
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
7 changes: 6 additions & 1 deletion server/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,12 @@ export async function main() {
if (fs.existsSync("../client/dist")) {
app.get("*", serveBuiltFiles);
} else {
log.warn("no dist folder found");
log.warn("no dist folder found, run `yarn build` to build the client");
app.get("*", (req, res) => {
res.status(404).send(
"File not found - Client files not found. Run `yarn build` to build the client."
);
});
Comment on lines +204 to +209
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider abstracting the relative path to the client's distribution folder and the error message into configuration settings or constants to improve maintainability and avoid duplication.

- log.warn("no dist folder found, run `yarn build` to build the client");
- res.status(404).send(
-   "File not found - Client files not found. Run `yarn build` to build the client."
- );
+ const clientDistPath = "../client/dist";
+ const buildClientMessage = "File not found - Client files not found. Run `yarn build` to build the client.";
+ log.warn(`no ${clientDistPath} folder found, run \`yarn build\` to build the client`);
+ res.status(404).send(buildClientMessage);

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
log.warn("no dist folder found, run `yarn build` to build the client");
app.get("*", (req, res) => {
res.status(404).send(
"File not found - Client files not found. Run `yarn build` to build the client."
);
});
const clientDistPath = "../client/dist";
const buildClientMessage = "File not found - Client files not found. Run `yarn build` to build the client.";
log.warn(`no ${clientDistPath} folder found, run \`yarn build\` to build the client`);
app.get("*", (req, res) => {
res.status(404).send(buildClientMessage);
});

}

initExtractor();
Expand Down