turbo icon indicating copy to clipboard operation
turbo copied to clipboard

feat(examples): add example-with-typeorm

Open cgoinglove opened this issue 1 year ago • 4 comments

This pull request introduces a new typeorm-service package to the official TurboRepo examples. The aim is to demonstrate the implementation of a robust service layer using TypeORM with a custom dependency injection (DI) mechanism. This example is designed to help developers integrate a more structured backend architecture with their existing Next.js applications, leveraging TypeORM for ORM capabilities.

turborepo-orm

cgoinglove avatar May 15 '24 09:05 cgoinglove

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
examples-basic-web ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 27, 2024 2:17pm
examples-designsystem-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 27, 2024 2:17pm
examples-gatsby-web ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 27, 2024 2:17pm
examples-kitchensink-blog ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 27, 2024 2:17pm
examples-native-web ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 27, 2024 2:17pm
examples-nonmonorepo ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 27, 2024 2:17pm
examples-svelte-web ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 27, 2024 2:17pm
examples-tailwind-web ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 27, 2024 2:17pm
examples-vite-web ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 27, 2024 2:17pm
rust-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 27, 2024 2:17pm

vercel[bot] avatar May 15 '24 09:05 vercel[bot]

Deployment failed with the following error:

Creating the Deployment Timed Out.

vercel[bot] avatar May 15 '24 09:05 vercel[bot]

@cgoinglove is attempting to deploy a commit to the Vercel Team on Vercel.

A member of the Team first needs to authorize it.

vercel[bot] avatar May 15 '24 11:05 vercel[bot]

Hi,

Thank you for your feedback. I have addressed the issues you mentioned:

Fixed the build, test, and lint commands so they now work out of the box. Upgraded Turborepo to version 2 using npx @turbo/codemod upgrade. Please let me know if there are any other changes or improvements needed.

Thank you! @anthonyshew

cgoinglove avatar Jun 18 '24 04:06 cgoinglove

I'm still seeing a lot of errors when I run turbo test.

anthonyshew avatar Jul 13 '24 13:07 anthonyshew

I'm still seeing a lot of errors when I run turbo test.

This issue occurs because the example user might not have verified the database connection configuration before running the test code.

To address this, I added a comment in the test code:

/**
 *
 * If you have correctly configured the database connection information in 'packages/typeorm-service/src/orm-config.ts',
 * remove this skipIf statement and run the tests.
 */

const todoService = inject(TodoService);

suite.skipIf(true)("Todo", () => {
  let id: Todo["id"];

  test("Insert", async () => {
    const newTodo = await todoService.add("Hello World");

    id = newTodo.id;

    expect(newTodo.complete).toBeFalsy();
  });
});

Additionally, for example users, I have updated the README to include instructions on entering database connection information and provided a MySQL Dockerfile and execution script.

Thank you for your(@anthonyshew ) comment. I have been waiting for your feedback and appreciate you reaching out.

cgoinglove avatar Jul 14 '24 15:07 cgoinglove

I'd prefer to have these be unit tests, mocking the database call. Is that something you could do?

anthonyshew avatar Jul 23 '24 12:07 anthonyshew

Refactor tests to include both unit tests and integration tests for TodoService

  • Added unit tests for TodoService using Vitest and mocking TodoRepository
  • Ensured each method in TodoService is tested with mocked database calls
  • Included integration tests for TodoRepository using TypeORM with SQL.js
  • Verified CRUD operations on Todo entity with in-memory SQL.js database

cgoinglove avatar Jul 23 '24 14:07 cgoinglove

Allow CI Workflow Run

  • [x] approve CI run for commit: 3160ecd72e422f745f74bca058f8688ec6169101

Note: this should only be enabled once the PR is ready to go and can only be enabled by a maintainer

ijjk avatar Jul 23 '24 14:07 ijjk