Co-Pilot
Updated 24 days ago

bun-elysia-skill

Yymc182
0.0k
ymc182/bun-elysia-skill
80
Agent Score

💡 Summary

This skill enables building full-stack applications using Bun.js and Elysia.js with various native APIs.

🎯 Target Audience

Full-stack developersBackend engineers migrating from FastifyDevelopers using Bun.jsSoftware architectsTech educators

🤖 AI Roast:Powerful, but the setup might scare off the impatient.

Security AnalysisMedium Risk

Risk: Medium. Review: shell/CLI command execution; outbound network access (SSRF, data egress); API keys/tokens handling and storage. Run with least privilege and audit before enabling in production.


name: bun-elysia description: Build full-stack applications with Bun.js and Elysia.js. Use this skill when working with Bun runtime, Bun native APIs (SQL databases, Redis, S3), Bun workspaces/monorepos, Elysia.js web framework, or migrating from Fastify to Elysia. Covers setup, routing, validation, authentication, WebSocket, and end-to-end type safety with Eden.

Bun + Elysia.js Development

Build high-performance full-stack applications with Bun runtime and Elysia.js framework.

Quick Start

New Elysia Project

bun create elysia my-app cd my-app bun run dev

Basic Server

import { Elysia, t } from "elysia"; const app = new Elysia() .get("/", () => "Hello, World!") .get("/users/:id", ({ params }) => ({ id: params.id }), { params: t.Object({ id: t.Number() }) }) .post("/users", ({ body }) => ({ created: body }), { body: t.Object({ name: t.String(), email: t.String({ format: "email" }) }) }) .listen(3000);

With Bun Native APIs

import { Elysia } from "elysia"; import { sql } from "bun"; import { redis } from "bun"; const app = new Elysia() .decorate("sql", sql) .decorate("redis", redis) .get("/users", async ({ sql }) => { return sql`SELECT * FROM users`; }) .get("/cache/:key", async ({ redis, params }) => { return redis.get(params.key); }) .listen(3000);

Reference Navigation

What do you want to do?

Set up a project:

Use Bun native APIs:

Build with Elysia:

Migrate from Fastify:


Common Patterns

Authentication Middleware

import { Elysia } from "elysia"; import { jwt } from "@elysiajs/jwt"; const app = new Elysia() .use(jwt({ secret: process.env.JWT_SECRET! })) .derive(async ({ headers, jwt }) => { const token = headers.authorization?.replace("Bearer ", ""); const user = token ? await jwt.verify(token) : null; return { user }; }) .get("/profile", ({ user, error }) => { if (!user) return error(401); return user; });

Database with Validation

import { Elysia, t } from "elysia"; import { sql } from "bun"; const app = new Elysia() .post("/users", async ({ body }) => { const [user] = await sql` INSERT INTO users (name, email) VALUES (${body.name}, ${body.email}) RETURNING * `; return user; }, { body: t.Object({ name: t.String({ minLength: 1 }), email: t.String({ format: "email" }) }) });

Grouped Routes with Guard

app.group("/api", (app) => app .guard({ headers: t.Object({ authorization: t.String() }), beforeHandle: ({ headers, error }) => { if (!isValidToken(headers.authorization)) { return error(401); } } }, (app) => app .get("/users", getUsers) .post("/users", createUser) ) );

WebSocket Chat

app.ws("/chat", { body: t.Object({ room: t.String(), message: t.String() }), open(ws) { ws.subscribe("general"); }, message(ws, { room, message }) { ws.publish(room, { from: ws.id, message }); } });

Key Differences: Fastify vs Elysia

| Fastify | Elysia | |---------|--------| | request.params | { params } | | request.query | { query } | | request.body | { body } | | reply.code(n).send(x) | set.status = n; return x | | reply.header(k, v) | set.headers[k] = v | | JSON Schema | TypeBox (t.*) | | preHandler hook | beforeHandle | | fastify.decorate() | .decorate() | | fastify.register(plugin) | .use(plugin) |


Installation

# Elysia and plugins bun add elysia @elysiajs/swagger @elysiajs/jwt @elysiajs/cors @elysiajs/static @elysiajs/eden # Types bun add -d @types/bun typescript
5-Dim Analysis
Clarity8/10
Novelty8/10
Utility9/10
Completeness8/10
Maintainability7/10
Pros & Cons

Pros

  • Supports high-performance applications
  • Integrates seamlessly with Bun native APIs
  • Type-safe development with Eden

Cons

  • Limited community support compared to more established frameworks
  • Learning curve for those unfamiliar with Bun.js
  • Potential issues with plugin compatibility

Related Skills

nuxt-skills

S
toolCo-Pilot
90/ 100

“It's essentially a well-organized cheat sheet that turns your AI assistant into a Nuxt framework parrot.”

mcp-builder

S
toolCode Lib
90/ 100

“This guide is so comprehensive it might just teach the AI to write its own MCP servers and put you out of a job.”

claude-mods

A
toolCo-Pilot
86/ 100

“Powerful, but the setup might scare off the impatient.”

Disclaimer: This content is sourced from GitHub open source projects for display and rating purposes only.

Copyright belongs to the original author ymc182.