-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
130 additions
and
14 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
/node_modules | ||
node_modules | ||
coverage | ||
*.log | ||
npm-debug.log | ||
|
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,34 @@ | ||
import { ILifecycleBoot, Application } from 'egg'; | ||
|
||
export default class AppBootHook implements ILifecycleBoot { | ||
private readonly app: Application; | ||
|
||
constructor(app: Application) { | ||
this.app = app; | ||
} | ||
|
||
async didLoad() { | ||
console.error('didLoad'); | ||
// Ready to call configDidLoad, | ||
// Config, plugin files are referred, | ||
// this is the last chance to modify the config. | ||
// throw new Error('Method not implemented.'); | ||
} | ||
|
||
async willReady() { | ||
// All plugins have started, can do some thing before app ready | ||
} | ||
|
||
async didReady() { | ||
// Worker is ready, can do some things | ||
// don't need to block the app boot process | ||
} | ||
|
||
async serverDidReady() { | ||
// Server is listening. | ||
} | ||
|
||
async beforeClose() { | ||
// Do some thing before app close. | ||
} | ||
} |
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,7 @@ | ||
import { Controller } from 'egg'; | ||
|
||
export default class HomeController extends Controller { | ||
async index() { | ||
this.ctx.body = 'Hello EggJS 🥚🥚🥚🥚'; | ||
} | ||
} |
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,5 @@ | ||
import { Application } from 'egg'; | ||
|
||
export default (app: Application) => { | ||
app.get('/', 'home.index'); | ||
}; |
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,7 @@ | ||
import { EggAppConfig } from 'egg'; | ||
|
||
export default () => { | ||
return { | ||
keys: '123456', | ||
} as Partial<EggAppConfig>; | ||
}; |
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,10 @@ | ||
{ | ||
"name": "helloworld-typescript", | ||
"type": "module", | ||
"egg": { | ||
"typescript": true | ||
}, | ||
"dependencies": { | ||
"egg": "beta" | ||
} | ||
} |
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,10 @@ | ||
{ | ||
"extends": "@eggjs/tsconfig", | ||
"compilerOptions": { | ||
"strict": true, | ||
"noImplicitAny": true, | ||
"target": "ES2022", | ||
"module": "NodeNext", | ||
"moduleResolution": "NodeNext" | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import type { | ||
Router, | ||
} from '@eggjs/core'; | ||
import type { | ||
HttpClientRequestURL, HttpClientRequestOptions, HttpClient, | ||
} from '../../lib/core/httpclient.js'; | ||
import type { | ||
ContextHttpClient, | ||
} from '../../lib/core/context_httpclient.js'; | ||
import type Helper from './helper.js'; | ||
import type { EggLogger } from 'egg-logger'; | ||
|
||
declare module '@eggjs/core' { | ||
// add Context overrides types | ||
interface Context { | ||
curl(url: HttpClientRequestURL, options?: HttpClientRequestOptions): ReturnType<HttpClient['request']>; | ||
get router(): Router; | ||
set router(val: Router); | ||
get helper(): Helper; | ||
get httpclient(): ContextHttpClient; | ||
get httpClient(): ContextHttpClient; | ||
getLogger(name: string): EggLogger; | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
declare module '@eggjs/core' { | ||
// add EggApplicationCore overrides types | ||
interface EggCore { | ||
inspect(): any; | ||
} | ||
} |
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