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

Add typebox validator middleware #75

Merged
merged 1 commit into from
Oct 16, 2024
Merged

Add typebox validator middleware #75

merged 1 commit into from
Oct 16, 2024

Conversation

dbartholomae
Copy link
Owner

@dbartholomae dbartholomae commented Oct 16, 2024

First test using Copilot Workspace.

Add a new middleware for validation using typebox.

  • Middleware Implementation

    • Create typeboxValidator middleware in packages/typebox-validator/src/typeboxValidator.ts.
    • Define WithBody type and typeboxValidator function.
    • Implement validation logic using TypeCompiler.Compile and TypeCompiler.Validate.
  • Tests

    • Add unit tests in packages/typebox-validator/src/typeboxValidator.test.ts.
    • Write tests for valid input, invalid input, and superfluous input.
  • Example

    • Create an example usage in packages/typebox-validator/examples/helloWorld.ts.
    • Implement an AWS handler function using typeboxValidator middleware.
    • Add integration tests in packages/typebox-validator/examples/helloWorld.int-test.ts.
  • Configuration and Documentation

    • Add package.json for the new middleware in packages/typebox-validator/package.json.
    • Create README.md with an overview and usage example in packages/typebox-validator/README.md.
    • Add TypeScript configuration files tsconfig.json and tsconfig.build.json.
    • Add Jest configuration files jest.config.js and jest.integration.config.js.
  • Test Setup

    • Add test setup files in packages/typebox-validator/test/ directory.
    • Include .gitignore, handler.ts, serverless.yml, source-map-install.js, tsconfig.json, and webpack.config.js.

For more details, open the Copilot Workspace session.

First test using Copilot Workspace.

Add a new middleware for validation using typebox.

* **Middleware Implementation**
  - Create `typeboxValidator` middleware in `packages/typebox-validator/src/typeboxValidator.ts`.
  - Define `WithBody` type and `typeboxValidator` function.
  - Implement validation logic using `TypeCompiler.Compile` and `TypeCompiler.Validate`.

* **Tests**
  - Add unit tests in `packages/typebox-validator/src/typeboxValidator.test.ts`.
  - Write tests for valid input, invalid input, and superfluous input.

* **Example**
  - Create an example usage in `packages/typebox-validator/examples/helloWorld.ts`.
  - Implement an AWS handler function using `typeboxValidator` middleware.
  - Add integration tests in `packages/typebox-validator/examples/helloWorld.int-test.ts`.

* **Configuration and Documentation**
  - Add `package.json` for the new middleware in `packages/typebox-validator/package.json`.
  - Create `README.md` with an overview and usage example in `packages/typebox-validator/README.md`.
  - Add TypeScript configuration files `tsconfig.json` and `tsconfig.build.json`.
  - Add Jest configuration files `jest.config.js` and `jest.integration.config.js`.

* **Test Setup**
  - Add test setup files in `packages/typebox-validator/test/` directory.
  - Include `.gitignore`, `handler.ts`, `serverless.yml`, `source-map-install.js`, `tsconfig.json`, and `webpack.config.js`.

---

For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/dbartholomae/lambda-middleware?shareId=XXXX-XXXX-XXXX-XXXX).
Copy link

codecov bot commented Oct 16, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (91a7ec5) to head (1ac1d01).
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main       #75   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           56        56           
  Lines          527       527           
  Branches        95        95           
=========================================
  Hits           527       527           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@mergify mergify bot merged commit 7f256b2 into main Oct 16, 2024
6 checks passed
@mergify mergify bot deleted the add-typebox-validator branch October 16, 2024 20:36
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.

1 participant