This is a GitHub template repository for creating Cloops microservices. You must run the setup script after cloning to bootstrap your project.
To learn more about
cloops.microservices, please checkout our docs on GitHub
Before doing anything else, you MUST run the setup script to bootstrap your project:
chmod +x setup.sh
./setup.shThe script will prompt you for your namespace (e.g., my.service or MyService) and automatically:
- Replace all
{{NAMESPACE}}placeholders in your code - Rename project folders from
{{NAMESPACE}}to your namespace - Rename
.csprojfiles to match your namespace - Update all configuration files (Dockerfile, scripts, etc.)
Note: If you used GitHub Actions to set up the template, the script will detect this and exit as a NO-OP (no operation needed).
When you clone this template, the repository contains placeholder folders and files:
{{NAMESPACE}}/- Main project folder (will be renamed to your namespace){{NAMESPACE}}.Tests/- Test project folder (will be renamed to your namespace)- All code files contain
{{NAMESPACE}}placeholders that need to be replaced
The setup process (./setup.sh) performs the following transformations:
- Replaces placeholders in all
.cs,.csproj,.sh,Dockerfile, and other config files - Renames project files:
{{NAMESPACE}}.csproj→{YourNamespace}.csproj - Renames folders:
{{NAMESPACE}}/→{YourNamespace}/ - Updates paths in scripts and configuration files
After running ./setup.sh, your project structure will be ready to use with your chosen namespace.
chmod +x setup.sh
./setup.sh
# Enter your namespace when prompted (e.g., my.service)- Go to the Actions tab in your repository
- Select Setup Template workflow
- Click Run workflow
- Enter your namespace when prompted
- The workflow will automatically replace placeholders and commit the changes
Note: If GitHub Actions has already run, the
./setup.shscript will detect this and exit gracefully (NO-OP).
If you prefer to set up manually (not recommended):
- Replace all occurrences of
{{NAMESPACE}}with your actual namespace - Rename the
{{NAMESPACE}}folder to your namespace - Rename the
{{NAMESPACE}}.Testsfolder to{YourNamespace}.Tests - Rename
{{NAMESPACE}}/{{NAMESPACE}}.csprojto{YourNamespace}/{YourNamespace}.csproj - Rename
{{NAMESPACE}}.Tests/{{NAMESPACE}}.Tests.csprojto{YourNamespace}.Tests/{YourNamespace}.Tests.csproj - Update
DockerfileENTRYPOINT with your executable name - Update NATS subjects in controllers and scripts
After setup, your project will have the following structure:
{YourNamespace}/
├── {YourNamespace}.csproj
├── Program.cs
├── controllers/
├── services/
├── schema/
├── util/
└── Dockerfile
{YourNamespace}.Tests/
├── {YourNamespace}.Tests.csproj
└── Controllers/
The repo needs the following local setup infrastructure dependencies:
- NATS Server - For messaging
- .NET 9.0 SDK - For building and running
First, make sure you've run ./setup.sh to bootstrap your project!
It is assumed that your environment variables are loaded from .env file. Please use a dedicated config and secret management solution. Please see our docs around config for more info.
# After running ./setup.sh, run the app
chmod +x run.sh
./run.sh
# That's it, you are set, use nats requests in {YourNamespace}/nats/ to test the service
# e.g.
cd {YourNamespace}/nats
./health.sh- ✅ NATS Integration - Built-in NATS client with consumer attributes
- ✅ Dependency Injection - Full DI support with Microsoft.Extensions
- ✅ Background Services - Scheduled tasks with cron expressions
- ✅ HTTP Client - Example HTTP service integration
- ✅ Metrics - Application metrics with System.Diagnostics.Metrics
- ✅ Testing - XUnit test project with Moq
- ✅ Docker - Ready-to-use Dockerfile
The repo out of the box ships with an AliveNudge background service that just logs service executing nudge every 30 seconds. This is just to demonstrate how to do scheduled tasks in background. Please remove the file services/background/alive.nudge.cs to get rid of it.
- Update README.md - Add your project-specific information
- Configure Services - Update
AppSettings.cswith your configuration - Add Your Controllers - Create NATS consumers in the
controllers/folder - Write Tests - Add tests in the
{YourNamespace}.Tests/project - Update Schema - Customize NATS message types in the
schema/folder
To learn more about cloops.microservices, please checkout our docs on GitHub
For issues and questions, please open an issue in the cloops.microservices repository.