forked from web-infra-dev/modern.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(generator): fix bff and server generator (web-infra-dev#160)
- Loading branch information
Showing
14 changed files
with
82 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...r/generators/bff-generator/templates/framework/app/egg/app/middleware/trace.js.handlebars
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
export default function traceMiddleware() { | ||
return async (ctx, next) => { | ||
await next(); | ||
console.info(`access url: ${ctx.req.url}`); | ||
console.info(`access url: ${ctx.url}`); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
13 changes: 13 additions & 0 deletions
13
packages/generator/generators/bff-generator/templates/framework/app/koa/app.ts.handlebars
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import Koa, { Context } from 'koa' | ||
import koaBody from 'koa-body' | ||
|
||
const app = new Koa(); | ||
app.use(async (ctx: Context, next) => { | ||
console.info(`access url: ${ctx.url}`); | ||
await next(); | ||
}); | ||
|
||
// ensure use koa | ||
app.use(koaBody()); | ||
|
||
export default app; |
8 changes: 8 additions & 0 deletions
8
packages/generator/generators/bff-generator/templates/function/app/js/egg.js.handlebars
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { hook } from "@modern-js/runtime/server"; | ||
|
||
export default hook(({ addMiddleware }) => { | ||
addMiddleware(() => async (ctx, next) => { | ||
console.info(`access url: ${ctx.url}`); | ||
await next(); | ||
}); | ||
}); |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
packages/generator/generators/bff-generator/templates/function/app/ts/express.ts.handlebars
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { hook } from '@modern-js/runtime/server'; | ||
import { Request, Response, NextFunction } from 'express'; | ||
|
||
export default hook(({ addMiddleware }) => { | ||
addMiddleware(async (req: Request, res: Response, next: NextFunction) => { | ||
console.info(`access url: ${req.url}`); | ||
next(); | ||
}); | ||
}); |
9 changes: 9 additions & 0 deletions
9
packages/generator/generators/bff-generator/templates/function/app/ts/koa.ts.handlebars
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { hook } from '@modern-js/runtime/server'; | ||
import { Context, Next } from 'koa'; | ||
|
||
export default hook(({ addMiddleware }) => { | ||
addMiddleware(async (ctx: Context, next: Next) => { | ||
console.info(`access url: ${ctx.url}`); | ||
await next(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters