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
6 changes: 3 additions & 3 deletions apps/express/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
"dependencies": {
"@aura-stack/auth": "workspace:*",
"@aura-stack/express": "workspace:*",
"express": "^4.18.2"
"express": "catalog:express"
},
"devDependencies": {
"@aura-stack/tsconfig": "workspace:*",
"@types/express": "^4.17.21",
"@types/node": "^20.10.6",
"@types/express": "catalog:express",
"@types/node": "catalog:node",
"tsx": "^4.7.0",
"typescript": "^5.3.3"
},
Expand Down
12 changes: 10 additions & 2 deletions apps/hono/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<h1>Aura Auth + Hono</h1>

**Demonstration app**
**Integration Example App**

[Official Docs](https://aura-stack-auth.vercel.app/docs) · [Hono](https://hono.dev/)

Expand All @@ -12,7 +12,15 @@

## Overview

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

This integration utilizes the dedicated [`@aura-stack/hono`](../../packages/hono) package, which provides standard middlewares and first-class TypeScript support for Hono 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 `ctx.get("session")` is automatically populated and typed.

## Getting Started

Expand Down
7 changes: 3 additions & 4 deletions apps/hono/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@
"format:check": "oxfmt --check"
},
"dependencies": {
"@aura-stack/auth": "workspace:*",
"@aura-stack/jose": "workspace:*",
"hono": "^4.12.8"
"@aura-stack/hono": "workspace:*",
"hono": "catalog:hono"
},
"devDependencies": {
"@aura-stack/tsconfig": "workspace:*",
"@types/bun": "^1.3.9"
"@types/bun": "catalog:bun"
}
}
7 changes: 0 additions & 7 deletions apps/hono/src/auth.ts

This file was deleted.

11 changes: 7 additions & 4 deletions apps/hono/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
import { Hono } from "hono"
import { toHonoHandler } from "./lib/handler"
import { type AuthVariables, withAuth } from "./middleware/with-auth"
import { toHandler, withAuth } from "@/lib/auth"

const app = new Hono<{ Variables: AuthVariables }>()
const app = new Hono()

app.get("/", (ctx) => {
return ctx.text("Welcome to the Aura Auth Hono App!")
})

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

app.get("/api/protected", withAuth, (ctx) => {
const session = ctx.get("session")
if (!session) {
return ctx.json({ message: "Unauthorized" }, 401)
}

return ctx.json({
message: "You have access to this protected resource.",
session,
Expand Down
8 changes: 8 additions & 0 deletions apps/hono/src/lib/auth.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { createAuth } from "@aura-stack/hono"

export const auth = createAuth({
oauth: ["github"],
basePath: "/api/auth",
})
Comment thread
halvaradop marked this conversation as resolved.

export const { jose, api, toHandler, withAuth } = auth
10 changes: 0 additions & 10 deletions apps/hono/src/lib/handler.ts

This file was deleted.

25 changes: 0 additions & 25 deletions apps/hono/src/middleware/with-auth.ts

This file was deleted.

5 changes: 4 additions & 1 deletion apps/hono/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
{
"extends": "@aura-stack/tsconfig/bun.json",
"compilerOptions": {
"jsxImportSource": "hono/jsx"
"jsxImportSource": "hono/jsx",
"paths": {
"@/*": ["./src/*"]
}
},
"include": ["src"],
"exclude": ["dist", "node_modules"]
Expand Down
Loading
Loading