{"id":18600820,"url":"https://github.com/octet-stream/qwik-mikro-orm-template","last_synced_at":"2026-04-16T18:06:29.375Z","repository":{"id":223891872,"uuid":"760930961","full_name":"octet-stream/qwik-mikro-orm-template","owner":"octet-stream","description":"Qwik template w/ Mikro ORM and MySQL","archived":false,"fork":false,"pushed_at":"2024-02-22T14:23:20.000Z","size":199,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-18T01:27:11.763Z","etag":null,"topics":["mikro-orm","mysql","qwik","qwik-city","tailwindcss","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/octet-stream.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2024-02-20T23:22:44.000Z","updated_at":"2024-02-22T14:27:43.000Z","dependencies_parsed_at":"2024-02-22T16:47:02.225Z","dependency_job_id":null,"html_url":"https://github.com/octet-stream/qwik-mikro-orm-template","commit_stats":null,"previous_names":["octet-stream/qwik-mikro-orm-template"],"tags_count":0,"template":true,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/octet-stream%2Fqwik-mikro-orm-template","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/octet-stream%2Fqwik-mikro-orm-template/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/octet-stream%2Fqwik-mikro-orm-template/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/octet-stream%2Fqwik-mikro-orm-template/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/octet-stream","download_url":"https://codeload.github.com/octet-stream/qwik-mikro-orm-template/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254573589,"owners_count":22093731,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["mikro-orm","mysql","qwik","qwik-city","tailwindcss","typescript"],"created_at":"2024-11-07T02:05:44.923Z","updated_at":"2026-04-16T18:06:29.347Z","avatar_url":"https://github.com/octet-stream.png","language":"TypeScript","readme":"# qwik-mikro-orm-template\n\nQwik template w/ Mikro ORM and MySQL\n\n## Commands\n\n| ID              | Description                                                                                                                                                    |\n|-----------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `build`         | Runs `qwik build`                                                                                                                                              |\n| `build.client`  | Creates client-side bundle                                                                                                                                     |\n| `build.preview` | Creates `preview` build of the app with                                                                                                                        |\n| `build.node`    | Creates `production` build with `node:http` server as backend                                                                                                  |\n| `build.types`   | Runs TypeScript types validation via `tsc`                                                                                                                     |\n| `dev`           | Runs application with dev server                                                                                                                               |\n| `dev.open`      | Same as `dev`, but opens a browser                                                                                                                             |\n| `dev.debug`     | Runs `dev` server in debug mode                                                                                                                                |\n| `lint`          | Rns `eslint` on project's source filed                                                                                                                         |\n| `preview`       | Creates `preview` build using `build.preview` command, then starts preview server                                                                              |\n| `preview.open`  | Same as `preview` command, but opens a browser                                                                                                                 |\n| `serve.node`    | Creates `production` build, then starts Node.js server. Note: This command references `.env.local` file via node CLI using `--env-file` to apply configuration |\n| `start`         | Starts production server. This command is used when you build the app via `docker` or `docker compose`                                                         |\n\n## Configuration\n\n| Name        | Required | Default value | Description                                   |\n|-------------|:--------:|:-------------:|-----------------------------------------------|\n| DB_NAME     | Yes      | –             | Database name                                 |\n| DB_HOST     | No       | `\"localhost\"` | Database server hostname                      |\n| DB_PORT     | No       | `3306`        | Database server port                          |\n| DB_USER     | Yes      | –             | Database user name                            |\n| DB_PASSWORD | Yes      | –             | Password for the user specified via `DB_USER` |\n\n## Deployment\n\nThis template is using `node:http` as the server adapter and comes with `Dockerfile` to build an image and `compose.yaml` to run the app demo.\nI would now suggest using this adapter in production, as it is not mentioned anywhere in the docs, so it can be unstable at this time.\nTo choose different adapter and more detailed deployment instructions, please, refer to the [Deployment](https://qwik.dev/docs/deployments/) secion of Qwik documentaion.\n\nFollowing steps describe how to deploy the app demo for this template.\n\n1. Create an `.env.local` file and fill it with your database connection information. Do not change the DB_USER value, because MySQL is configured to use root as a user, since it's just a demo.\n2. Run `docker compose --env-file .env.local up`. It will build the app using `Dockerfile` and run it along configured MySQL server.\n3. Open [http://127.0.0.1:3000](http://127.0.0.1:3000) and you'll see simple To-Do app in which you can add new todos and remove existing ones.\n\nNote that docker compose is configured to store the MySQL data in `tmpfs`, which means the data will be purged once containers are stopped.\n\n## Pitfalls\n\n1. Because the whole server-side code is bundled in a few files,\nand most of it is in just one of them, you may encounter the error when MySQL complains\nthat you're trying to access a table that doesn't exists.\nThis is because bundler is trying to deduplicate identifiers within this single bundle.\nso you might get names like `Todo` and `Todo2` for an antity and this is the cause of the error.\nMikro ORM will use that name by default, because it is associated with the entity class.\nTo work around this problem, you should always use `tableName` option of the `Entity` decorator:\n\n```ts\nimport {Entity} from \"@mikro-orm/mysql\"\n\n@Entity({tableName: \"my_entity\"}) // Mikro ORM will use this name to make queries to the database\nexport class MyEntity { }\n```\n\nor you can just use `EntitySchema` to define your entities:\n\n```ts\nexport interface IMyEntity { }\n\nexport const MyEntity = new EntitySchema\u003cIMyEntity\u003e({\n  name: \"MyEntity\" // Mikro ORM will use this name to make queries to the database,\n  properties: { }\n})\n```\n\n2. If you enable minification for server-side bundle, `esbuild` will mess up class names too and this will also lead to previous error. The workaround would be the same.\n\n3. Since the project is using `type: \"module\"` option in `package.json`, you have to add `.js` extension in modules paths, because this is how Node.js resolves ESM paths.\nThis is necessary to run migrations via `mikro-orm-esm` CLI, because it is relying on `ts-node` to load ORM config.\nAt the same time `Qwik` (this is either Vite or Rollup issue) cannot load and build with `.js` extension,\nbut this happens for client-side code only, so in order to work around this issue,\nyou can either use `.js` extension in your server-side, but keep avoiding it on the client.\nThis way you will get both `mikro-orm-esm` and `Qwik` work as expected, or you can try and add `--experimental-specifier-resolution=node` flag for `mikro-orm-esm` via `NODE_OPTIONS` environment variable.\nI haven't tried the second solution yet, but it may as well work, because it was suppose to emulate an old (CJS) Node.js resolutaion algorithm for ESM files.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foctet-stream%2Fqwik-mikro-orm-template","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foctet-stream%2Fqwik-mikro-orm-template","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foctet-stream%2Fqwik-mikro-orm-template/lists"}