-
Notifications
You must be signed in to change notification settings - Fork 0
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
Issue 1018 extract blindly #1
Conversation
fixes #1018
fixes #1018
WalkthroughThis update enhances the project's infrastructure and coding standards across various aspects, including environment configuration, linting, GitHub Actions workflows, and funding options. It introduces new settings for Fastify, ESLint, and Dependabot, along with multiple workflows aimed at improving code quality and project management. Additionally, it provides templates and guidelines for contributions and releases. Changes
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 8
Review Details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files ignored due to path filters (1)
package-lock.json
is excluded by!**/package-lock.json
Files selected for processing (56)
- .env.example (1 hunks)
- .eslintrc.cjs (1 hunks)
- .github/FUNDING.yml (1 hunks)
- .github/dependabot.yml (1 hunks)
- .github/prace.yml (1 hunks)
- .github/pull_request_template.md (1 hunks)
- .github/release.yml (1 hunks)
- .github/workflows/global.commit-message.yml (1 hunks)
- .github/workflows/global.conflibot.yml (1 hunks)
- .github/workflows/global.docker.yml (1 hunks)
- .github/workflows/global.editorconfiglint.yml (1 hunks)
- .github/workflows/global.greetings.yml (1 hunks)
- .github/workflows/global.label.yml (1 hunks)
- .github/workflows/global.milestone.yml (1 hunks)
- .github/workflows/global.prace.yml (1 hunks)
- .github/workflows/global.pull-request-size.yml (1 hunks)
- .github/workflows/global.release.yml (1 hunks)
- .github/workflows/global.spellcheck.yml (1 hunks)
- .github/workflows/history-microservice.codeql.yml (1 hunks)
- .github/workflows/history-microservice.eslint.yml (1 hunks)
- .github/workflows/history-microservice.fta.yml (1 hunks)
- .github/workflows/history-microservice.knip.yml (1 hunks)
- .github/workflows/history-microservice.license-check.yml (1 hunks)
- .github/workflows/history-microservice.mdlint.yml (1 hunks)
- .github/workflows/history-website.codeql.yml (1 hunks)
- .github/workflows/history-website.eslint.yml (1 hunks)
- .github/workflows/history-website.fta.yml (1 hunks)
- .github/workflows/history-website.knip.yml (1 hunks)
- .github/workflows/history-website.language-lint.yml (1 hunks)
- .github/workflows/history-website.license-check.yml (1 hunks)
- .github/workflows/history-website.mdlint.yml (1 hunks)
- .github/workflows/history-website.spellcheck.yml (1 hunks)
- .gitignore (1 hunks)
- .knip.json (1 hunks)
- .markdownlint.yaml (1 hunks)
- .npmrc (1 hunks)
- README.md (1 hunks)
- index.ts (1 hunks)
- package.json (1 hunks)
- src/constants.ts (1 hunks)
- src/routes/home.ts (1 hunks)
- src/routes/home/GetBody.ts (1 hunks)
- src/routes/home/GetHeaders.ts (1 hunks)
- src/routes/home/GetQueryString.ts (1 hunks)
- src/routes/home/GetReply.ts (1 hunks)
- src/routes/login.ts (1 hunks)
- src/routes/login/PostBody.ts (1 hunks)
- src/routes/login/PostHeaders.ts (1 hunks)
- src/routes/login/PostQueryString.ts (1 hunks)
- src/routes/login/PostReply.ts (1 hunks)
- src/routes/project.ts (1 hunks)
- src/routes/project/GetBody.ts (1 hunks)
- src/routes/project/GetHeaders.ts (1 hunks)
- src/routes/project/GetQueryString.ts (1 hunks)
- src/routes/project/GetReply.ts (1 hunks)
- src/routes/projects.ts (1 hunks)
Files not processed due to max files limit (11)
- src/routes/projects/GetBody.ts
- src/routes/projects/GetHeaders.ts
- src/routes/projects/GetQueryString.ts
- src/routes/projects/GetReply.ts
- src/routes/route.ts
- src/routes/route/GetBody.ts
- src/routes/route/GetHeaders.ts
- src/routes/route/GetQueryString.ts
- src/routes/route/GetReply.ts
- src/server.ts
- tsconfig.json
Files skipped from review due to trivial changes (45)
- .env.example
- .eslintrc.cjs
- .github/FUNDING.yml
- .github/dependabot.yml
- .github/prace.yml
- .github/release.yml
- .github/workflows/global.commit-message.yml
- .github/workflows/global.conflibot.yml
- .github/workflows/global.editorconfiglint.yml
- .github/workflows/global.label.yml
- .github/workflows/global.prace.yml
- .github/workflows/global.release.yml
- .github/workflows/global.spellcheck.yml
- .github/workflows/history-microservice.codeql.yml
- .github/workflows/history-microservice.eslint.yml
- .github/workflows/history-microservice.fta.yml
- .github/workflows/history-microservice.knip.yml
- .github/workflows/history-microservice.license-check.yml
- .github/workflows/history-microservice.mdlint.yml
- .github/workflows/history-website.eslint.yml
- .github/workflows/history-website.fta.yml
- .github/workflows/history-website.knip.yml
- .github/workflows/history-website.language-lint.yml
- .github/workflows/history-website.license-check.yml
- .github/workflows/history-website.mdlint.yml
- .github/workflows/history-website.spellcheck.yml
- .gitignore
- .knip.json
- .markdownlint.yaml
- .npmrc
- README.md
- index.ts
- package.json
- src/constants.ts
- src/routes/home/GetBody.ts
- src/routes/home/GetHeaders.ts
- src/routes/home/GetQueryString.ts
- src/routes/home/GetReply.ts
- src/routes/login/PostBody.ts
- src/routes/login/PostHeaders.ts
- src/routes/login/PostQueryString.ts
- src/routes/login/PostReply.ts
- src/routes/project/GetBody.ts
- src/routes/project/GetHeaders.ts
- src/routes/project/GetQueryString.ts
Additional comments not posted (6)
.github/workflows/global.milestone.yml (1)
1-15
: Ensure that the custom GitHub Actionidrinth/milestone-set-action@patch-1
is well-tested and secure since it directly interacts with the GitHub API using a secret token..github/workflows/global.greetings.yml (1)
1-18
: The greeting messages are clear and provide useful information. However, ensure that the links to Slack are up-to-date and that the invitation links have not expired.Verification successful
The Slack invitation link in the greeting messages of the
.github/workflows/global.greetings.yml
file is operational. It redirects correctly within the Slack domain, indicating that the link is still valid and functional.
Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the validity of the Slack invitation links in the greeting messages. # Test: Attempt to access the Slack invitation link and check for a valid response. curl -I "https://join.slack.com/t/idrinth-api-bench/shared_invite/zt-2f4zmw2sz-c3etHzCFq3LtZpkR15xXMA"Length of output: 1080
.github/workflows/global.pull-request-size.yml (1)
1-34
: The workflow is well set up to check the size of pull requests. However, ensure that thecheck-pr-length
tool is reliable and that the thresholds set (--max=350 --total=500
) are appropriate for your project's needs.Verification successful
The
check-pr-length
tool used in the pull request size workflow does not have any open issues or pull requests, suggesting that there are no known problems with its functionality at this time.
Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the functionality and configuration of the `check-pr-length` tool used in the pull request size workflow. # Test: Check the repository of the tool for issues and pull requests related to its functionality. gh repo view Idrinth/check-pr-length --json issues,pullRequestsLength of output: 125
src/routes/projects.ts (1)
22-65
: The JWT verification and error handling logic are correctly implemented, and the response structure is consistent and clear..github/workflows/global.docker.yml (1)
1-52
: The Docker workflow is well-structured with appropriate triggers and steps for building Docker images..github/workflows/history-website.codeql.yml (1)
1-60
: The CodeQL workflow is correctly set up for thehistory-website
project, with appropriate triggers and analysis steps.
}>('/projects', async(request, reply,) => { | ||
try { | ||
await request.jwtVerify(); | ||
} catch (err) { | ||
reply.status(HTTP_NO_AUTH,).send(); | ||
return; | ||
} | ||
reply.send({ | ||
example: { | ||
'2024-03-29': { | ||
mean: 2323324, | ||
average: 1324112, | ||
stdev: 1212, | ||
}, | ||
'2024-03-30': { | ||
mean: 2323324, | ||
average: 1324112, | ||
stdev: 1212, | ||
}, | ||
'2024-03-31': { | ||
mean: 2323324, | ||
average: 1324112, | ||
stdev: 1212, | ||
}, | ||
}, | ||
test: { | ||
'2024-03-29': { | ||
mean: 1323324, | ||
average: 2324112, | ||
stdev: 9212, | ||
}, | ||
'2024-03-30': { | ||
mean: 3323324, | ||
average: 3324112, | ||
stdev: 6212, | ||
}, | ||
'2024-03-31': { | ||
mean: 2323324, | ||
average: 2324112, | ||
stdev: 71212, | ||
}, | ||
}, | ||
},); | ||
},); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider removing unnecessary commas for cleaner syntax.
- async(request, reply,) => {
+ async(request, reply) => {
- },);
+ });
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.
}>('/projects', async(request, reply,) => { | |
try { | |
await request.jwtVerify(); | |
} catch (err) { | |
reply.status(HTTP_NO_AUTH,).send(); | |
return; | |
} | |
reply.send({ | |
example: { | |
'2024-03-29': { | |
mean: 2323324, | |
average: 1324112, | |
stdev: 1212, | |
}, | |
'2024-03-30': { | |
mean: 2323324, | |
average: 1324112, | |
stdev: 1212, | |
}, | |
'2024-03-31': { | |
mean: 2323324, | |
average: 1324112, | |
stdev: 1212, | |
}, | |
}, | |
test: { | |
'2024-03-29': { | |
mean: 1323324, | |
average: 2324112, | |
stdev: 9212, | |
}, | |
'2024-03-30': { | |
mean: 3323324, | |
average: 3324112, | |
stdev: 6212, | |
}, | |
'2024-03-31': { | |
mean: 2323324, | |
average: 2324112, | |
stdev: 71212, | |
}, | |
}, | |
},); | |
},); | |
}>('/projects', async(request, reply) => { | |
try { | |
await request.jwtVerify(); | |
} catch (err) { | |
reply.status(HTTP_NO_AUTH,).send(); | |
return; | |
} | |
reply.send({ | |
example: { | |
'2024-03-29': { | |
mean: 2323324, | |
average: 1324112, | |
stdev: 1212, | |
}, | |
'2024-03-30': { | |
mean: 2323324, | |
average: 1324112, | |
stdev: 1212, | |
}, | |
'2024-03-31': { | |
mean: 2323324, | |
average: 1324112, | |
stdev: 1212, | |
}, | |
}, | |
test: { | |
'2024-03-29': { | |
mean: 1323324, | |
average: 2324112, | |
stdev: 9212, | |
}, | |
'2024-03-30': { | |
mean: 3323324, | |
average: 3324112, | |
stdev: 6212, | |
}, | |
'2024-03-31': { | |
mean: 2323324, | |
average: 2324112, | |
stdev: 71212, | |
}, | |
}, | |
}); | |
}); |
interface GetReply { | ||
[route: string]: { | ||
[date: string]: { | ||
mean: number; | ||
average: number; | ||
stdev: number; | ||
}, | ||
}, | ||
} | ||
export default GetReply; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The interface GetReply
uses both mean
and average
properties which might be redundant as they typically represent the same statistical measure. Consider renaming or removing one to avoid confusion.
key: docker-${{ runner.os }}-${{ hashFiles('containers/api-bench-build/Dockerfile') }} | ||
- run: docker build --build-arg="BUILD_VERSION=$(git describe --tags `git rev-list --tags --max-count=1`)" -t "idrinth/api-bench-build:$(git describe --tags `git rev-list --tags --max-count=1`)" --build-arg="BUILD_TIME=now" containers/api-bench-build | ||
build: | ||
needs: | ||
- builder | ||
strategy: | ||
matrix: | ||
folder: | ||
- 'api-bench-gitlab-runner' | ||
- 'api-bench' | ||
- 'api-bench-gitea-action' | ||
- 'api-bench-history-website' | ||
- 'api-bench-history-microservice' | ||
name: Build ${{ matrix.folder }} | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 360 | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
- run: git fetch --tags | ||
- name: Cache Docker images. | ||
uses: ScribeMD/[email protected] | ||
with: | ||
key: docker-${{ runner.os }}-${{ hashFiles('containers/api-bench-build/Dockerfile') }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider using a more specific cache key to avoid potential cache collisions, especially when building multiple Docker images.
- key: docker-${{ runner.os }}-${{ hashFiles('containers/api-bench-build/Dockerfile') }}
+ key: docker-${{ runner.os }}-${{ matrix.folder }}-${{ hashFiles('containers/${{ matrix.folder }}/Dockerfile') }}
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.
key: docker-${{ runner.os }}-${{ hashFiles('containers/api-bench-build/Dockerfile') }} | |
- run: docker build --build-arg="BUILD_VERSION=$(git describe --tags `git rev-list --tags --max-count=1`)" -t "idrinth/api-bench-build:$(git describe --tags `git rev-list --tags --max-count=1`)" --build-arg="BUILD_TIME=now" containers/api-bench-build | |
build: | |
needs: | |
- builder | |
strategy: | |
matrix: | |
folder: | |
- 'api-bench-gitlab-runner' | |
- 'api-bench' | |
- 'api-bench-gitea-action' | |
- 'api-bench-history-website' | |
- 'api-bench-history-microservice' | |
name: Build ${{ matrix.folder }} | |
runs-on: ubuntu-latest | |
timeout-minutes: 360 | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- run: git fetch --tags | |
- name: Cache Docker images. | |
uses: ScribeMD/[email protected] | |
with: | |
key: docker-${{ runner.os }}-${{ hashFiles('containers/api-bench-build/Dockerfile') }} | |
key: docker-${{ runner.os }}-${{ matrix.folder }}-${{ hashFiles('containers/${{ matrix.folder }}/Dockerfile') }} | |
- run: docker build --build-arg="BUILD_VERSION=$(git describe --tags `git rev-list --tags --max-count=1`)" -t "idrinth/api-bench-build:$(git describe --tags `git rev-list --tags --max-count=1`)" --build-arg="BUILD_TIME=now" containers/api-bench-build | |
build: | |
needs: | |
- builder | |
strategy: | |
matrix: | |
folder: | |
- 'api-bench-gitlab-runner' | |
- 'api-bench' | |
- 'api-bench-gitea-action' | |
- 'api-bench-history-website' | |
- 'api-bench-history-microservice' | |
name: Build ${{ matrix.folder }} | |
runs-on: ubuntu-latest | |
timeout-minutes: 360 | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- run: git fetch --tags | |
- name: Cache Docker images. | |
uses: ScribeMD/[email protected] | |
with: | |
key: docker-${{ runner.os }}-${{ matrix.folder }}-${{ hashFiles('containers/${{ matrix.folder }}/Dockerfile') }} |
cache-dependency-path: | | ||
framework/package-lock.json | ||
documentation-website/package-lock.json | ||
history-microservice/package-lock.json | ||
history-website/package-lock.json | ||
cli/package-lock.json | ||
package-lock.json |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refine the caching strategy to only include relevant package-lock.json
files for the history-website
project.
- framework/package-lock.json
- documentation-website/package-lock.json
- history-microservice/package-lock.json
- history-website/package-lock.json
- cli/package-lock.json
- package-lock.json
+ history-website/package-lock.json
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.
cache-dependency-path: | | |
framework/package-lock.json | |
documentation-website/package-lock.json | |
history-microservice/package-lock.json | |
history-website/package-lock.json | |
cli/package-lock.json | |
package-lock.json | |
cache-dependency-path: | | |
history-website/package-lock.json |
const routes = async( | ||
fastify: Fastify.FastifyInstance, | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
options: Fastify.RouteOptions, | ||
// eslint-disable-next-line require-await | ||
) => { | ||
fastify.post<{ | ||
Querystring: PostQueryString, | ||
Headers: PostHeaders, | ||
Reply: PostReply, | ||
Body: PostBody, | ||
}>('/login', (request, reply,) => { | ||
const token = fastify.jwt.sign({ | ||
username: request.body.username, | ||
},); | ||
reply.send({ | ||
token, | ||
},); | ||
},); | ||
}; | ||
export default routes; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The route handler for /login
correctly signs a JWT with the username. However, consider adding error handling for potential failures in JWT signing or other parts of the request handling.
# The Pull Request is ready | ||
|
||
- [ ] fixes #<!-- YOUR ISSUE ID HERE --> | ||
- [ ] all actions are passing | ||
- [ ] only fixes a single issue | ||
|
||
## Overview | ||
|
||
<!-- Provide a brief description of the changes introduced by this | ||
Pull Request. --> | ||
|
||
## Review points | ||
|
||
<!-- List the points to be reviewed in detail | ||
and the points you are not confident about. --> | ||
<!-- Delete this section if not needed --> | ||
|
||
## History-Microservice | ||
|
||
- [ ] no breaking changes have been added to the api | ||
- [ ] changes have been documented in the open-api.yml | ||
- [ ] tests have been written(if necessary) | ||
- [ ] shared code has been extracted in a different file | ||
|
||
## Notes | ||
|
||
<!-- Write any note or comment. You can share your thoughts or ideas. --> | ||
<!-- Delete this section if not needed --> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider revising the checklist item "all actions are passing" to "ensure all actions have passed" for better clarity and formality.
- [ ] all actions are passing
+ [ ] ensure all actions have passed
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.
# The Pull Request is ready | |
- [ ] fixes #<!-- YOUR ISSUE ID HERE --> | |
- [ ] all actions are passing | |
- [ ] only fixes a single issue | |
## Overview | |
<!-- Provide a brief description of the changes introduced by this | |
Pull Request. --> | |
## Review points | |
<!-- List the points to be reviewed in detail | |
and the points you are not confident about. --> | |
<!-- Delete this section if not needed --> | |
## History-Microservice | |
- [ ] no breaking changes have been added to the api | |
- [ ] changes have been documented in the open-api.yml | |
- [ ] tests have been written(if necessary) | |
- [ ] shared code has been extracted in a different file | |
## Notes | |
<!-- Write any note or comment. You can share your thoughts or ideas. --> | |
<!-- Delete this section if not needed --> | |
# The Pull Request is ready | |
- [ ] fixes #<!-- YOUR ISSUE ID HERE --> | |
- [ ] ensure all actions have passed | |
- [ ] only fixes a single issue | |
## Overview | |
<!-- Provide a brief description of the changes introduced by this | |
Pull Request. --> | |
## Review points | |
<!-- List the points to be reviewed in detail | |
and the points you are not confident about. --> | |
<!-- Delete this section if not needed --> | |
## History-Microservice | |
- [ ] no breaking changes have been added to the api | |
- [ ] changes have been documented in the open-api.yml | |
- [ ] tests have been written(if necessary) | |
- [ ] shared code has been extracted in a different file | |
## Notes | |
<!-- Write any note or comment. You can share your thoughts or ideas. --> | |
<!-- Delete this section if not needed --> |
const routes = async( | ||
fastify: Fastify.FastifyInstance, | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
options: Fastify.RouteOptions, | ||
// eslint-disable-next-line require-await | ||
) => { | ||
fastify.get<{ | ||
Querystring: GetQueryString, | ||
Headers: GetHeaders, | ||
Reply: GetReply, | ||
Body: GetBody, | ||
}>('/', (request, reply,) => { | ||
reply.send({ | ||
version: pkg.version, | ||
name: pkg.name, | ||
documentation: 'https//idrinth-api-ben.ch', | ||
},); | ||
},); | ||
}; | ||
export default routes; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The URL in the documentation
field of the response is missing a colon after https
. This could lead to issues when clients try to access the documentation link.
- documentation: 'https//idrinth-api-ben.ch',
+ documentation: 'https://idrinth-api-ben.ch',
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.
const routes = async( | |
fastify: Fastify.FastifyInstance, | |
// eslint-disable-next-line @typescript-eslint/no-unused-vars | |
options: Fastify.RouteOptions, | |
// eslint-disable-next-line require-await | |
) => { | |
fastify.get<{ | |
Querystring: GetQueryString, | |
Headers: GetHeaders, | |
Reply: GetReply, | |
Body: GetBody, | |
}>('/', (request, reply,) => { | |
reply.send({ | |
version: pkg.version, | |
name: pkg.name, | |
documentation: 'https//idrinth-api-ben.ch', | |
},); | |
},); | |
}; | |
export default routes; | |
const routes = async( | |
fastify: Fastify.FastifyInstance, | |
// eslint-disable-next-line @typescript-eslint/no-unused-vars | |
options: Fastify.RouteOptions, | |
// eslint-disable-next-line require-await | |
) => { | |
fastify.get<{ | |
Querystring: GetQueryString, | |
Headers: GetHeaders, | |
Reply: GetReply, | |
Body: GetBody, | |
}>('/', (request, reply,) => { | |
reply.send({ | |
version: pkg.version, | |
name: pkg.name, | |
documentation: 'https://idrinth-api-ben.ch', | |
},); | |
},); | |
}; | |
export default routes; |
const routes = async( | ||
fastify: Fastify.FastifyInstance, | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
options: Fastify.RouteOptions, | ||
// eslint-disable-next-line require-await | ||
) => { | ||
fastify.get<{ | ||
Querystring: GetQueryString, | ||
Headers: GetHeaders, | ||
Reply: GetReply, | ||
Body: GetBody, | ||
}>('/project/:project', async(request, reply,) => { | ||
try { | ||
await request.jwtVerify(); | ||
} catch (err) { | ||
reply.status(HTTP_NO_AUTH,).send(); | ||
return; | ||
} | ||
reply.send({ | ||
route1: { | ||
'2024-03-29': { | ||
mean: 2323324, | ||
average: 1324112, | ||
stdev: 1212, | ||
}, | ||
'2024-03-30': { | ||
mean: 2323324, | ||
average: 1324112, | ||
stdev: 1212, | ||
}, | ||
'2024-03-31': { | ||
mean: 2323324, | ||
average: 1324112, | ||
stdev: 1212, | ||
}, | ||
}, | ||
route2: { | ||
'2024-03-29': { | ||
mean: 1323324, | ||
average: 2324112, | ||
stdev: 9212, | ||
}, | ||
'2024-03-30': { | ||
mean: 3323324, | ||
average: 3324112, | ||
stdev: 6212, | ||
}, | ||
'2024-03-31': { | ||
mean: 2323324, | ||
average: 2324112, | ||
stdev: 71212, | ||
}, | ||
}, | ||
},); | ||
},); | ||
}; | ||
export default routes; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The route handler for /project/:project
is well-structured with proper JWT verification and error handling. However, consider adding logging for the catch block to help with debugging and monitoring.
- reply.status(HTTP_NO_AUTH,).send();
+ reply.status(HTTP_NO_AUTH,).send();
+ console.error('JWT verification failed:', err);
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.
const routes = async( | |
fastify: Fastify.FastifyInstance, | |
// eslint-disable-next-line @typescript-eslint/no-unused-vars | |
options: Fastify.RouteOptions, | |
// eslint-disable-next-line require-await | |
) => { | |
fastify.get<{ | |
Querystring: GetQueryString, | |
Headers: GetHeaders, | |
Reply: GetReply, | |
Body: GetBody, | |
}>('/project/:project', async(request, reply,) => { | |
try { | |
await request.jwtVerify(); | |
} catch (err) { | |
reply.status(HTTP_NO_AUTH,).send(); | |
return; | |
} | |
reply.send({ | |
route1: { | |
'2024-03-29': { | |
mean: 2323324, | |
average: 1324112, | |
stdev: 1212, | |
}, | |
'2024-03-30': { | |
mean: 2323324, | |
average: 1324112, | |
stdev: 1212, | |
}, | |
'2024-03-31': { | |
mean: 2323324, | |
average: 1324112, | |
stdev: 1212, | |
}, | |
}, | |
route2: { | |
'2024-03-29': { | |
mean: 1323324, | |
average: 2324112, | |
stdev: 9212, | |
}, | |
'2024-03-30': { | |
mean: 3323324, | |
average: 3324112, | |
stdev: 6212, | |
}, | |
'2024-03-31': { | |
mean: 2323324, | |
average: 2324112, | |
stdev: 71212, | |
}, | |
}, | |
},); | |
},); | |
}; | |
export default routes; | |
const routes = async( | |
fastify: Fastify.FastifyInstance, | |
// eslint-disable-next-line @typescript-eslint/no-unused-vars | |
options: Fastify.RouteOptions, | |
// eslint-disable-next-line require-await | |
) => { | |
fastify.get<{ | |
Querystring: GetQueryString, | |
Headers: GetHeaders, | |
Reply: GetReply, | |
Body: GetBody, | |
}>('/project/:project', async(request, reply,) => { | |
try { | |
await request.jwtVerify(); | |
} catch (err) { | |
reply.status(HTTP_NO_AUTH,).send(); | |
console.error('JWT verification failed:', err); | |
return; | |
} | |
reply.send({ | |
route1: { | |
'2024-03-29': { | |
mean: 2323324, | |
average: 1324112, | |
stdev: 1212, | |
}, | |
'2024-03-30': { | |
mean: 2323324, | |
average: 1324112, | |
stdev: 1212, | |
}, | |
'2024-03-31': { | |
mean: 2323324, | |
average: 1324112, | |
stdev: 1212, | |
}, | |
}, | |
route2: { | |
'2024-03-29': { | |
mean: 1323324, | |
average: 2324112, | |
stdev: 9212, | |
}, | |
'2024-03-30': { | |
mean: 3323324, | |
average: 3324112, | |
stdev: 6212, | |
}, | |
'2024-03-31': { | |
mean: 2323324, | |
average: 2324112, | |
stdev: 71212, | |
}, | |
}, | |
},); | |
},); | |
}; | |
export default routes; |
Summary by CodeRabbit
New Features
Documentation
Chores
.gitignore
settings for better management of development files..npmrc
to enforce strict engine version compliance.