Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions apps/elysia/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@

This project demonstrates Aura Auth authentication using [OAuth 2.0 providers](https://aura-stack-auth.vercel.app/docs/) in a [Elysia](https://elysiajs.com/) application.

This integration utilizes the dedicated [`@aura-stack/elysia`](../../packages/elysia) package, which provides standard middlewares and first-class TypeScript support for Elysia applications.

## Features Demo

- **Type-safe Middleware**: Uses `withAuth` to protect routes and infer session shapes.
- **Unified Auth Handler**: Reuses framework-agnostic core logic via `toHandler`.
- **Global Context**: Demonstrates how `session` is automatically populated and typed.

## Getting Started

You can run the documentation site locally for development or contribution.
Expand Down
2 changes: 1 addition & 1 deletion apps/elysia/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"format:check": "oxfmt --check"
},
"dependencies": {
"@aura-stack/auth": "workspace:*",
"@aura-stack/elysia": "workspace:*",
"elysia": "^1.4.28"
},
"devDependencies": {
Expand Down
7 changes: 0 additions & 7 deletions apps/elysia/src/auth.ts

This file was deleted.

7 changes: 3 additions & 4 deletions apps/elysia/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import { Elysia } from "elysia"
import { toElysiaHandler } from "./lib/handler"
import { withAuthPlugin } from "./plugins/with-auth"
import { toHandler, withAuth } from "@/lib/auth"

const app = new Elysia()

app.get("/", () => "Welcome to the Aura Auth Elysia App!")

app.all("/api/auth/*", toElysiaHandler)
app.all("/api/auth/*", toHandler)

app.use(withAuthPlugin).get("/api/protected", (ctx) => {
app.derive(withAuth).get("/api/protected", (ctx) => {
if (!ctx.session) {
return Response.json(
{
Expand Down
8 changes: 8 additions & 0 deletions apps/elysia/src/lib/auth.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { createAuth } from "@aura-stack/elysia"

export const auth = createAuth({
oauth: ["github"],
basePath: "/api/auth",
})

export const { api, jose, toHandler, withAuth } = auth
18 changes: 0 additions & 18 deletions apps/elysia/src/plugins/with-auth.ts

This file was deleted.

5 changes: 5 additions & 0 deletions apps/elysia/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"extends": "@aura-stack/tsconfig/bun.json",
"compilerOptions": {
"paths": {
"@/*": ["./src/*"]
}
},
"include": ["src"],
"exclude": ["dist", "node_modules"]
}
21 changes: 20 additions & 1 deletion bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 1 addition & 11 deletions deno.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
{
"workspace": [
"packages/core",
"packages/jose",
"packages/rate-limiter",
"packages/hono",
"packages/express",
"packages/react",
"apps/oak",
"apps/deno",
"apps/supabase/**"
]
"workspace": ["packages/**", "apps/oak", "apps/deno", "apps/supabase/**"]
}
86 changes: 86 additions & 0 deletions deno.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions packages/elysia/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Changelog - `@aura-stack/elysia`

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

---

## [Unreleased]

### Added

- Introduced seamless Elysia integration package that encapsulates the core authentication logic into plugins and handlers for session management and authentication flows. [#140](https://github.com/aura-stack-ts/auth/pull/140)
Loading
Loading