Skip to content
This repository was archived by the owner on Jul 6, 2025. It is now read-only.

Commit e8d8638

Browse files
committed
Add oak middleware
1 parent 5145dea commit e8d8638

File tree

5 files changed

+20
-3
lines changed

5 files changed

+20
-3
lines changed

cli/build.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Application } from '../server/mod.ts'
1+
import { Application } from '../server/app.ts'
22

33
export const helpMessage = `
44
Usage:

cli/dev.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { getFlag, parsePortNumber } from '../server/helper.ts'
2-
import { Application, serve } from '../server/mod.ts'
2+
import { Application } from '../server/app.ts'
3+
import { serve } from '../server/stdserver.ts'
34

45
export const helpMessage = `
56
Usage:

cli/start.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { getFlag, parsePortNumber } from '../server/helper.ts'
2-
import { Application, serve } from '../server/mod.ts'
2+
import { Application } from '../server/app.ts'
3+
import { serve } from '../server/stdserver.ts'
34
import log from '../shared/log.ts'
45

56
export const helpMessage = `

server/mod.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
export * from './app.ts'
22
export * from './server.ts'
33
export * from './stdserver.ts'
4+
export * from './oak.ts'

server/oak.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import type { Middleware, Context } from 'https://deno.land/x/oak/mod.ts'
2+
import { Application } from './app.ts'
3+
import { Server } from './server.ts'
4+
5+
/** Create an oak middleware for Aleph server. */
6+
export function alephOak(app: Application): Middleware {
7+
const server = new Server(app)
8+
9+
return (ctx: Context) => {
10+
const req = ctx.request as any
11+
server.handle(req.originalRequest || req.serverRequest)
12+
ctx.respond = false
13+
}
14+
}

0 commit comments

Comments
 (0)