forked from midwayjs/midway
-
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.
feat(boilerplate): update midway-ts-strict
- split modal to config/config.modal.ts - add ApiMiddleware demo used by HomeController - ApiMiddleware use new exported type Middleware according to midwayjs#269
- Loading branch information
1 parent
a016e9b
commit c8388f0
Showing
4 changed files
with
27 additions
and
5 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
6 changes: 3 additions & 3 deletions
6
...ay-init/boilerplate/midway-ts-strict-boilerplate/boilerplate/src/config/config.default.ts
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
6 changes: 6 additions & 0 deletions
6
...dway-init/boilerplate/midway-ts-strict-boilerplate/boilerplate/src/config/config.modal.ts
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,6 @@ | ||
import { EggAppConfig, PowerPartial } from 'midway' | ||
|
||
|
||
export interface DefaultConfig extends PowerPartial<EggAppConfig> { | ||
welcomeMsg: string | ||
} |
16 changes: 16 additions & 0 deletions
16
...es/midway-init/boilerplate/midway-ts-strict-boilerplate/boilerplate/src/middleware/api.ts
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,16 @@ | ||
import { WebMiddleware, Middleware, provide } from 'midway' | ||
|
||
|
||
@provide() | ||
export class ApiMiddleware implements WebMiddleware { | ||
|
||
public resolve(): Middleware { | ||
return async (ctx, next) => { | ||
ctx.api = { | ||
reqTimeStr: new Date().toLocaleString(), | ||
} | ||
await next() | ||
} | ||
} | ||
|
||
} |