{"id":25615207,"url":"https://github.com/wednesday-solutions/cloudnative-template","last_synced_at":"2025-04-13T21:13:14.457Z","repository":{"id":165856785,"uuid":"591939657","full_name":"wednesday-solutions/cloudnative-template","owner":"wednesday-solutions","description":"K8s template that is fully cloudnative!","archived":false,"fork":false,"pushed_at":"2023-05-16T06:55:33.000Z","size":369,"stargazers_count":14,"open_issues_count":10,"forks_count":0,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-04-13T21:13:10.918Z","etag":null,"topics":["cloudnative","fastifyjs","k8s","k8s-monorepo-template","k8s-template","kubernetes","monorepo","monorepo-template","node","postgres","template","turborepo"],"latest_commit_sha":null,"homepage":"https://wednesday.is/building-products/?utm_source=github\u0026utm_medium=cloudnative_template","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/wednesday-solutions.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":"2023-01-22T12:24:12.000Z","updated_at":"2024-06-28T12:47:16.000Z","dependencies_parsed_at":"2024-03-15T14:23:12.627Z","dependency_job_id":"4cf57800-8f79-48a5-ad19-f3837b357a51","html_url":"https://github.com/wednesday-solutions/cloudnative-template","commit_stats":null,"previous_names":["wednesday-solutions/cloudnative-template"],"tags_count":0,"template":true,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wednesday-solutions%2Fcloudnative-template","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wednesday-solutions%2Fcloudnative-template/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wednesday-solutions%2Fcloudnative-template/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wednesday-solutions%2Fcloudnative-template/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wednesday-solutions","download_url":"https://codeload.github.com/wednesday-solutions/cloudnative-template/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248782260,"owners_count":21160717,"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":["cloudnative","fastifyjs","k8s","k8s-monorepo-template","k8s-template","kubernetes","monorepo","monorepo-template","node","postgres","template","turborepo"],"created_at":"2025-02-22T03:18:54.408Z","updated_at":"2025-04-13T21:13:14.414Z","avatar_url":"https://github.com/wednesday-solutions.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Wednesday Solution's CloudNative Template! 🚀\n\nThis is a monorepo template built using TurboRepo. Under the hood we have Fastify Service which is running with a Postgres instance.\n\n# Guides\n\nThe monorepo works on K8s for local development and also is deployable on K8s and is fully cloudnative follow the guides below for quick and easy setup.\n\n- [Deployment Flow Guide](https://github.com/wednesday-solutions/fastify-postgres/blob/main/DEPLOYMENT_FLOW_GUIDE.md)\n- [Development Guide](https://github.com/wednesday-solutions/fastify-postgres/blob/main/DEVELOPERS_GUIDE.md)\n\n# Philosophy\n\nNo code is a bad code. The code you start with is always good code because you and your team (even if you're the only team 🙃) agreed upon it. What we have in this repository is also good code. Well not exactly good, but in our *opinion* good code.\n\nGood code because it follows what we wanted it to follow. Then what is bad code? No code repository becomes bad code repository in a day or two. It becomes *bad/unmaintainable/unscalable/sluggish* with time. Call it whatever you want bad code is easily recognizable. And it falls down to you to fix and then maintain it.\n\nThere are several things in this repository that help catch what a human eye might miss. Linters, Type Checkers, Editor configurations, pre-commit hooks, and much more. But they can be avoided because they are bypassable. And that is exactly what makes the good code bad.\n\nSo rules to live by:\n\n1. Linter is your friend *NOT* your enemy; don't bypass it (feel free to change the initial rules)\n2. Follow the code style that you decide upon (establish it with your team)\n3. Use comments to let the other devs know what the code does\n4. Don't bypass the pre-commit hooks, it starts as \"just this one time\" and becomes a \"let's do it who cares\"\n5. Write tests that actually test the logic that you're trying to implement, make sure to write tests first and then write logic accordingly\n\n# Technology Used 👨‍💻\n\nThe following are the technology that this template utilizes.\n\n- [TurboRepo](https://turbo.build/repo/docs)\n- [Fastify](https://www.fastify.io/)\n- [Postgres](https://www.postgresql.org/)\n- [Sequelize](https://sequelize.org/)\n- [TypeScript](https://www.typescriptlang.org/)\n- [Kubernetes](https://kubernetes.io/)\n\n# Architecture of the template 🏗\n\nThe template is a monorepo where the main applications are in the `/apps` directory.\nAside that we also have several `packages` that we store in the `packages` directory that provided shared config and code.\n\nWe use [`dotenv-cli`](https://www.npmjs.com/package/dotenv-cli) to pass the `environment` files based on what `NODE_ENV` we wanna use. The monorepo utilizes K8s for development too, please refer the developer's guide to know more.\n\n# Testing 👨‍🔬\n\nWe use `Jest` test-runner for testing out the application.\nThe `alpha` application has both `Unit tests` and `Integration tests` done. We'd suggest you to have a look at how they are implemented and feel free to augment them to your liking.\n\nFor running unit tests across all your applications the following need to be done. Do note Turbo and Jest are already hooked up for Unit and Integration testing across all the application(s) present in the `apps` directory.\n\nHowever the TurboRepo pipeline specified in `turbo.json` requires you to have same names across the applications only then your application would be included in the pipeline.\n\n## Unit Testing 🧪\n\nYou can create Jest patterns by specifying a `jest.config.js` file in your application and change your config as you wish. However for testing create an npm script with the name `test:unit` and this will automatically hook it in your TurboRepo pipeline. And then just run `pnpm run test:unit` from the root directory. That will automatically run all the unit tests across each of your applications.\n\n**Steps for reference**\n\n1. Create a `jest.config.js` file at the base directory of your application.\n2. Extend the common `jest.config.js` by importing it in `jest.config.js` by doing `require('../../jest.config.js')`\n3. Define your unit test patterns and write a bunch of unit tests.\n4. Create an npm script with the following name `test:unit` and it should execute unit testing.\n5. Do `pnpm run test:unit` at your root directory and watch your unit tests run!\n\n## Integration Testing 🤖\n\nWe also support Integration tests. To be honest Integration testing simply means that you just normally run your application in a test environment. The test runner provides you with features to handle opening and closing your application. For testing the backend we run our integration tests against a real database and a redis instance both of which will be running inside their own docker containers.\n\nThe process of creating integration tests is quite similar to how we created Unit tests above. However there is a subtle catch. For testing be it Unit or Integration testing we generally create setup file(s) that help us do stuff after, before, or in between with any logic we want. Maybe you wanna create your database instance before you even start testing! In such a case prefer using Jest CLI flags to pass the `setupFilesAfterEnv` with the file path you wanna initialize.\n\nThis has been done in the `alpha` service which shows a good example of how to use different support files based upon if we're running unit tests or integration tests.\n\n### **Setting up postgres and redis for testing**\n\nWe have a bash script and a `docker-compose` that will automatically spin up a postgres and a redis instance (you require [`docker`](https://www.docker.com/) and [`docker-compose`](https://docs.docker.com/compose/)). The postgres and the redis instance also define their required envs in `docker-compose.yml` itself.\n\nYou can start the postgres and redis instance on docker using:\n\n```shell\npnpm start:svc\n```\n\nFor teardown you can use:\n\n```shell\npnpm stop:svc\n```\n\n*IMPORTANT* - Don't forget to close your connection to your database in your setup file in the `afterAll` block or this will leave it hanging and jest will report for open handles.\n\n### **Steps for reference**\n\n1. Create your `setup-jest` file depending upon if you're using TypeScript or JavaScript\n  - Setup `beforeAll` and `afterAll` logic in this file\n  - Its a good idea to connect to your `db` here and close connection to it in the `afterAll` block\n  - You can also clear your database in the `beforeEach` block which will run before each and every test\n2. Create integration tests directory and write integration tests\n3. Create an npm script with the following name `test:integration` and it should execute integration tests.\n  - PS: You can use `testPathPattern` CLI flag to specify in which directory your integration tests reside in\n4. Do `pnpm run test:integration` at your root directory and watch your integration tests run!\n\n## Development Scripts 📝\n\nDevelopment scripts are there to you help you out with a bunch of stuff. Few are listed below!\n\n| **Purpose**                     | **Script**                  |\n|---------------------------------|-----------------------------|\n| Install dependencies            | pnpm i                      |\n| Start development server        | pnpm start:dev              |\n| Create and run qa build         | pnpm start:qa               |\n| Create and run prod build       | pnpm start:prod             |\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwednesday-solutions%2Fcloudnative-template","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwednesday-solutions%2Fcloudnative-template","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwednesday-solutions%2Fcloudnative-template/lists"}