File tree Expand file tree Collapse file tree 3 files changed +15
-2
lines changed
Expand file tree Collapse file tree 3 files changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ import { Application, Router } from '@oak/oak';
55import { cors , runtimeError , cluster } from './middleware/index.ts' ;
66import v1Router from './routes/v1/index.ts' ;
77import { fromEnv } from './utils/fromEnv.ts' ;
8+ import logger from './middleware/logger.ts' ;
89
910const inCluster = fromEnv ( 'CLUSTER' , {
1011 defaultValue : false ,
@@ -16,14 +17,15 @@ const app = new Application();
1617
1718const router = new Router ( ) ;
1819
20+ app . use ( runtimeError ) ;
21+ app . use ( logger ( ) ) ;
1922app . use (
2023 cors ( {
2124 origin : 'http://localhost:5173' ,
2225 allowCredentials : true ,
2326 allowHeaders : [ 'Content-Type' ] ,
2427 } )
2528) ;
26- app . use ( runtimeError ) ;
2729if ( inCluster ) app . use ( cluster ( ) ) ;
2830
2931router . use ( '/api/v1' , v1Router . routes ( ) ) ;
Original file line number Diff line number Diff line change 11export { default as auth } from './auth.ts' ;
22export { default as body } from './body.ts' ;
3+ export { default as cluster } from './cluster.ts' ;
34export { default as compress } from './compress.ts' ;
45export { default as cors } from './cors.ts' ;
6+ export { default as logger } from './logger.ts' ;
57export { default as runtimeError } from './runtimeError.ts' ;
68export { default as validate } from './validate.ts' ;
7- export { default as cluster } from './cluster.ts' ;
Original file line number Diff line number Diff line change 1+ import { Middleware } from '@oak/oak' ;
2+
3+ export default function ( ) : Middleware {
4+ return async ( ctx , next ) => {
5+ const { method, url } = ctx . request ;
6+ console . log ( `${ method } ${ new URL ( url ) . pathname } ` ) ;
7+
8+ await next ( ) ;
9+ } ;
10+ }
You can’t perform that action at this time.
0 commit comments