๐Ÿš€ DAY 5 OF LAUNCH WEEK: Introducing Socket Firewall Enterprise.Learn more โ†’
Socket
Book a DemoInstallSign in
Socket

@tryloop/oats

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tryloop/oats

๐ŸŒพ OATS - OpenAPI TypeScript Sync. The missing link between your OpenAPI specs and TypeScript applications. Automatically watch, generate, and sync TypeScript clients from your API definitions.

latest
Source
npmnpm
Version
2.2.47
Version published
Maintainers
1
Created
Source

๐ŸŒพ OATS - OpenAPI TypeScript Sync

Automatically sync OpenAPI specs to TypeScript clients. No manual steps, just real-time updates.

npm version License: MIT Node.js Version

๐Ÿš€ Quick Start

# Install
npm install -D @tryloop/oats

# Initialize config
npx oats init

# Start development
npx oats start

๐ŸŽฏ What is OATS?

OATS eliminates the manual 6-step workflow of syncing OpenAPI changes:

  • Wait for backend to regenerate OpenAPI spec
  • Copy spec to client generator
  • Run generator
  • Build client
  • Link to frontend
  • Restart frontend

With OATS: Change your API โ†’ Everything syncs automatically โœจ

๐Ÿ“‹ Configuration

OATS supports multiple configuration formats:

JSON Configuration

{
  "$schema": "node_modules/@tryloop/oats/schema/oats.schema.json",
  "services": {
    "backend": {
      "path": "./backend",
      "port": 8000,
      "startCommand": "npm run dev",
      "apiSpec": {
        "path": "/api/openapi.json"
      }
    },
    "client": {
      "path": "./api-client",
      "packageName": "@myorg/api-client",
      "generator": "@hey-api/openapi-ts"
    },
    "frontend": {
      "path": "./frontend",
      "port": 3000,
      "startCommand": "npm run dev"
    }
  }
}

TypeScript Configuration

import { defineConfig } from '@tryloop/oats'

export default defineConfig({
  services: {
    backend: {
      path: './backend',
      port: 8000,
      startCommand: 'npm run dev',
      apiSpec: {
        path: '/api/openapi.json'
      }
    },
    client: {
      path: './api-client',
      packageName: '@myorg/api-client',
      generator: '@hey-api/openapi-ts'
    },
    frontend: {
      path: './frontend',
      port: 3000,
      startCommand: 'npm run dev'
    }
  }
})

Note: TypeScript configs are fully supported. OATS includes esbuild for consistent transpilation across all environments.

JavaScript Configuration

const { defineConfig } = require('@tryloop/oats')

module.exports = defineConfig({
  // Same structure as TypeScript config
})

๐ŸŒ Supported Technologies

Backend Frameworks

LanguageFrameworksOpenAPI Support
Node.jsExpress, Fastify, NestJS, Koa, HapiStatic files or runtime generation
PythonFastAPI, Flask, Django RESTRuntime endpoints (e.g., /openapi.json)

Frontend Frameworks

All major frameworks: React, Vue, Angular, Svelte, Next.js, Nuxt, Remix

TypeScript Client Generators

๐Ÿ”ง CLI Commands

CommandDescriptionOptions
oats startStart all services with auto-sync--config, --quiet, --init-gen
oats initCreate configuration interactively--force, --yes
oats validateValidate configuration file--config
oats detectAuto-detect project structure-

๐ŸŽจ Key Features

๐Ÿ”„ Real-time Synchronization

  • File watching with intelligent debouncing
  • Smart change detection - ignores formatting changes
  • Hash-based caching - skip unnecessary regeneration
  • Concurrent sync prevention - no duplicate operations

๐Ÿ› ๏ธ Developer Experience

  • Auto port management - kills conflicting processes
  • Cross-platform support - Windows, macOS, Linux
  • Config hot-reload - changes restart services automatically
  • IntelliSense support - JSON schema for autocompletion
  • Multiple config formats - JSON, JS, or TypeScript (with built-in transpilation)
  • Automatic backend URL injection - Frontend uses local API in dev, production in prod

๐Ÿš€ Performance

  • 45% faster sync than manual process
  • Incremental builds when possible
  • Parallel service startup
  • Efficient polling for runtime API specs

๐Ÿ“š Examples

Python FastAPI + React

{
  "services": {
    "backend": {
      "path": "../backend",
      "port": 8000,
      "runtime": "python",
      "python": {
        "virtualEnv": ".venv"
      },
      "startCommand": ".venv/bin/uvicorn main:app --reload",
      "apiSpec": {
        "path": "/openapi.json"
      }
    },
    "client": {
      "path": "../api-client",
      "packageName": "@myapp/api",
      "generator": "@hey-api/openapi-ts"
    },
    "frontend": {
      "path": "./",
      "port": 3000,
      "startCommand": "npm start"
    }
  }
}

NestJS + Next.js Monorepo

{
  "services": {
    "backend": {
      "path": "./apps/api",
      "port": 3333,
      "startCommand": "nx serve api",
      "apiSpec": {
        "path": "swagger.json"
      }
    },
    "client": {
      "path": "./packages/api-client",
      "packageName": "@myapp/api-client",
      "generator": "custom",
      "generateCommand": "yarn openapi-ts"
    },
    "frontend": {
      "path": "./apps/web",
      "port": 4200,
      "startCommand": "nx serve web"
    }
  }
}

๐Ÿ“– Configuration Reference

Service Configuration

PropertyDescriptionRequired
pathPath to service directoryโœ…
portPort number (backend/frontend)โš ๏ธ
startCommandCommand to start serviceโœ…
runtime"node" or "python"โŒ
apiSpec.pathPath to OpenAPI specโœ…

โš ๏ธ Port is required for backend/frontend services, but not for client

Sync Options

OptionDefaultDescription
strategy"smart""smart" or "aggressive"
debounceMs1000Delay before regenerating
autoLinktrueAuto-link packages
pollingInterval5000For runtime API specs

Log Options

OptionDefaultDescription
level"info""debug", "info", "warn", "error"
colorstrueEnable colored output
timestampsfalseShow timestamps in logs
showServiceOutputtrueDisplay output from services

๐Ÿ›ก๏ธ Troubleshooting

Port conflicts

OATS automatically handles port conflicts. To disable:

{
  "services": {
    "backend": {
      "env": {
        "OATS_AUTO_KILL_PORTS": "false"
      }
    }
  }
}

Client not updating

  • Check package is linked: npm ls @myorg/api-client
  • For Vite: Exclude from optimization in vite.config.ts
  • Ensure packageName matches your client's package.json

Automatic Backend URL Injection

OATS automatically injects your backend URL into your frontend environment:

// Your frontend code
const API_URL = import.meta.env.VITE_OATS_BACKEND_BASE_URL || 'https://api.production.com'

How it works:

  • OATS detects your frontend framework (Vite, CRA, Next.js, etc.)
  • Injects the backend URL with the correct prefix:
    • Vite: VITE_OATS_BACKEND_BASE_URL
    • Create React App: REACT_APP_OATS_BACKEND_BASE_URL
    • Next.js: NEXT_PUBLIC_OATS_BACKEND_BASE_URL
    • Vue CLI: VUE_APP_OATS_BACKEND_BASE_URL
  • Your app uses local backend when running with OATS, production otherwise

No configuration needed - it just works!

TypeScript config issues

OATS fully supports TypeScript configs (.ts files) with built-in transpilation:

  • Configs work consistently across all environments
  • No additional setup or dependencies required
  • Use ESM syntax: export default defineConfig({...})

Command not found

Use npx or add to scripts:

{
  "scripts": {
    "dev:sync": "oats start"
  }
}

๐Ÿค Contributing

Contributions welcome! See CONTRIBUTING.md for details.

# Clone repo
git clone https://github.com/loopkitchen/oats.git

# Install dependencies
yarn install

# Run tests
yarn test

# Start development
yarn dev

๐Ÿ“„ License

MIT ยฉ Hari Shekhar

GitHub โ€ข npm โ€ข Issues

Keywords

oats

FAQs

Package last updated on 15 Oct 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts