Skip to content

hirakchhatbar/te.js

Repository files navigation

Tejas Logo

Tejas

A Node.js Framework for Powerful Backend Services

npm version npm downloads license

DocumentationAI Setup (MCP)Quick StartFeaturesFull Docs


What is Tejas?

Tejas (meaning "radiance" in Hindi) is a modern, lightweight Node.js framework designed for building robust backend services. It offers an intuitive API with aviation-inspired naming conventions, making your code both expressive and enjoyable to write.

import Tejas, { Target } from 'te.js';

const app = new Tejas();
const api = new Target('/api');

api.register('/hello/:name', (ammo) => {
  ammo.fire({ message: `Hello, ${ammo.payload.name}!` });
});

app.takeoff();

Features

  • AI-Native (MCP) — Ship with an MCP server so AI assistants can scaffold projects, generate routes, and write correct code with full framework knowledge
  • Simple Routing — Clean, method-agnostic URL structures with parameterized routes
  • Express Compatible — Use existing Express middleware alongside Tejas middleware
  • Zero-Config Error Handling — No try-catch needed! Tejas catches all errors automatically. Opt in to have an LLM determine error code and message when you don't specify them (see Error Handling)
  • Built-in Rate Limiting — Three algorithms (Token Bucket, Sliding Window, Fixed Window) with memory or Redis storage
  • Method Safety & CORS — Opt-in method restriction per route (register(path, { methods }, handler) or ammo.only('GET')), global allowed-methods filter, and app.withCORS() for cross-origin requests
  • File Uploads — Easy file handling with size limits and type validation
  • Auto-Documentation — Generate OpenAPI specs from your code with LLM-powered analysis (tejas generate:docs)
  • Interactive API Docs — Serve a Scalar API reference UI with app.serveDocs()
  • Auto-Discovery — Automatic route registration from .target.js files
  • Request Logging — Built-in HTTP request and exception logging

AI-Assisted Setup (MCP)

Recommended — The best way to get started with Tejas in the age of AI.

The Tejas MCP server gives your IDE's AI assistant full knowledge of the framework — documentation, code examples, and purpose-built tools to scaffold projects and generate correct code. No more hallucinated APIs.

Cursor — add this to .cursor/mcp.json:

{
  "mcpServers": {
    "tejas": {
      "command": "npx",
      "args": ["-y", "tejas-mcp"]
    }
  }
}

Other MCP-compatible IDEs — run npx tejas-mcp as the server command (stdio transport, no config needed).

Once connected, prompt your AI with things like "Scaffold a new te.js project called my-api" or "Create a REST API with user CRUD routes" — the assistant will generate framework-correct code using real te.js patterns.

Quick Start

Install

npm install te.js

Create Your App

// index.js
import Tejas from 'te.js';

const app = new Tejas({ port: 3000 });
app.takeoff();

Define Routes

// targets/user.target.js
import { Target } from 'te.js';

const users = new Target('/users');

users.register('/', (ammo) => {
  if (ammo.GET) {
    ammo.fire([{ id: 1, name: 'John' }]);
  } else if (ammo.POST) {
    const { name, email } = ammo.payload;
    ammo.fire(201, { id: 2, name, email });
  } else {
    ammo.notAllowed();
  }
});

users.register('/:id', (ammo) => {
  const { id } = ammo.payload;
  ammo.fire({ id, name: 'John Doe' });
});

Run

node index.js
# Server running at http://localhost:3000

Core Concepts

Tejas Term Purpose Express Equivalent
Tejas Application instance express()
Target Route group/router Router()
Ammo Request/response context req + res
fire() Send response res.send()
midair() Register middleware use()
takeoff() Start server listen()

CLI

tejas fly [file]             # Start the server
tejas generate:docs [--ci]   # Generate OpenAPI docs (interactive or CI mode)
tejas docs:on-push           # Auto-generate docs when pushing to production branch

API Documentation

Generate and serve interactive API docs:

npx tejas generate:docs
app.serveDocs({ specPath: './openapi.json' });
app.takeoff();
// Visit http://localhost:1403/docs

Docs are disabled in production by default. Set DOCS_PASSWORD to enable protected access:

DOCS_PASSWORD=my-secret

Documentation

For comprehensive documentation, see the docs folder or visit tejas-documentation.vercel.app.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

ISC © Hirak Chhatbar

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors