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

Issue 1018 extract blindly #1

Merged
merged 2 commits into from
May 7, 2024
Merged

Conversation

Idrinth
Copy link
Member

@Idrinth Idrinth commented May 6, 2024

Summary by CodeRabbit

  • New Features

    • Introduced a pull request template to streamline contribution processes.
    • Added automated workflows for Docker image building, code linting, spell checking, and more to enhance development practices.
    • Implemented a GitHub Actions workflow for automatic dependency updates.
  • Documentation

    • Updated README.md to reflect the new project name and focus.
  • Chores

    • Added .gitignore settings for better management of development files.
    • Set up .npmrc to enforce strict engine version compliance.

@Idrinth Idrinth requested a review from marikadeveloper May 6, 2024 23:26
Copy link

coderabbitai bot commented May 6, 2024

Walkthrough

This 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

Files Summary
.env.example Introduced new Fastify, MySQL, JWT, and rate limiting configurations.
.eslintrc.cjs, src/routes/home.ts Updated ESLint settings and added new route handlers.
.github/... (multiple files) Added various GitHub Actions workflows for linting, spellchecking, Docker operations, and more.
.github/FUNDING.yml, .github/dependabot.yml Added funding links and Dependabot configuration.
.gitignore, .knip.json, .markdownlint.yaml, .npmrc Introduced new configurations for Git, Knip tool, Markdown linting, and npm.
README.md, index.ts, package.json, src/constants.ts Updated project description, main entry point, package dependencies, and constants.

🐇✨
In the code's garden, fresh changes bloom,
With workflows woven in each room.
Fastify breezes, linting tunes,
A rabbit hops beneath the moon.
Celebrate the craft, as updates loom!
🌟📜🌙


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?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a 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

Commits Files that changed from the base of the PR and between ba8dd9f and 738b132.
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 Action idrinth/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 the check-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,pullRequests

Length 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 the history-website project, with appropriate triggers and analysis steps.

Comment on lines +22 to +65
}>('/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,
},
},
},);
},);
Copy link

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.

Suggested change
}>('/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,
},
},
});
});

Comment on lines +1 to +10
interface GetReply {
[route: string]: {
[date: string]: {
mean: number;
average: number;
stdev: number;
},
},
}
export default GetReply;
Copy link

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.

Comment on lines +27 to +50
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') }}
Copy link

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.

Suggested change
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') }}

Comment on lines +48 to +54
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
Copy link

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.

Suggested change
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

Comment on lines +7 to +27
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;
Copy link

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.

Comment on lines +1 to +28
# 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 -->
Copy link

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.

Suggested change
# 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 -->

Comment on lines +10 to +29
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;
Copy link

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.

Suggested change
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;

Comment on lines +10 to +66
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;
Copy link

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.

Suggested change
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;

@Idrinth Idrinth merged commit 75f763a into the-one May 7, 2024
2 of 20 checks passed
@Idrinth Idrinth deleted the issue-1018-extract-blindly branch May 7, 2024 15:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants