Skip to content

Trex-Hub/jobs-metaservice

Repository files navigation

Jobs Service

A TypeScript-based jobs service designed to run scheduled tasks and cron jobs, deployable to Kubernetes.

Overview

This service provides a foundation for running scheduled jobs and cron tasks. It's built with TypeScript and can be deployed as Kubernetes CronJobs using the included Helm chart.

Features

  • 🚀 TypeScript with ES2022 target
  • 📦 Dual format builds (CommonJS & ESM)
  • 🔧 tsup for fast bundling
  • ☸️ Kubernetes CronJob deployment via Helm
  • 🔐 Environment variable support
  • 📝 TypeScript path aliases (@/*src/*)

Prerequisites

  • Node.js (v18+ recommended)
  • pnpm (package manager)
  • Kubernetes cluster (for deployment)
  • Helm 3.x (for deployment)

Installation

# Install dependencies
pnpm install

Development

# Run in development mode with watch
pnpm dev

# Build the project
pnpm build

# Run the built application
pnpm start

Project Structure

.
├── src/
│   └── index.ts          # Main entry point
├── ci-cd/                # Kubernetes deployment files
│   ├── Chart.yaml        # Helm chart metadata
│   ├── values.yaml       # Helm chart values
│   └── templates/
│       └── cron-jobs.yml # CronJob template
├── package.json
├── tsconfig.json         # TypeScript configuration
└── tsup.config.ts        # Build configuration

Configuration

Environment Variables

Copy .env.example to .env and configure:

cp .env.example .env

Available environment variables:

  • ENV - Environment mode (development/production)

Building

The project uses tsup for bundling:

  • Output formats: CommonJS and ESM
  • Output directory: build/
  • Source maps: Enabled
  • Type definitions: Generated (.d.ts files)
pnpm build

Deployment

Kubernetes Deployment

The service can be deployed to Kubernetes using the included Helm chart:

# Navigate to the ci-cd directory
cd ci-cd

# Install/upgrade the chart
helm upgrade --install jobs . -f values.yaml

Configuring CronJobs

Edit ci-cd/values.yaml to configure your cron jobs:

cronjob:
  enabled: true
  jobs:
    - name: my-job
      schedule: "0 0 * * *"  # Cron schedule
      command:
        - node
        - build/index.js
      # ... additional configuration

Scripts

  • pnpm dev - Start development mode with watch
  • pnpm build - Build the project
  • pnpm start - Run the built application
  • pnpm test - Run tests (placeholder)

About

A TypeScript-based jobs service designed to run scheduled tasks and cron jobs, deployable to Kubernetes.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors