-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix: deep merge config * chore: format code
- Loading branch information
1 parent
a677bd6
commit 41cab61
Showing
7 changed files
with
116 additions
and
1 deletion.
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
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,29 @@ | ||
import path from "path"; | ||
// import fs from 'fs'; | ||
import 'reflect-metadata'; | ||
import { ArtusApplication } from "../../../src"; | ||
|
||
const rootDir = path.resolve(__dirname, "./"); | ||
|
||
async function main() { | ||
const app = new ArtusApplication(); | ||
const metaFilePath = path.resolve(rootDir, 'manifest.json'); | ||
// let manifest; | ||
// if (fs.existsSync(metaFilePath)) { | ||
const manifest = require((metaFilePath)); | ||
// } else { | ||
// const scanner = new ArtusScanner({ | ||
// configDir: 'config', | ||
// needWriteFile: true, | ||
// useRelativePath: true, | ||
// extensions: ['.ts', '.js', '.json'], | ||
// app, | ||
// }); | ||
// manifest = await scanner.scan(rootDir); | ||
// } | ||
await app.load(manifest, rootDir); | ||
await app.run(); | ||
return app; | ||
|
||
} | ||
export { main }; |
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 @@ | ||
|
||
export default { | ||
httpConfig: { | ||
port: 3000, | ||
}, | ||
}; |
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 { Injectable } from '../../../../src/'; | ||
|
||
@Injectable() | ||
export default class DemoController { | ||
public async index() { | ||
return { code: 0, message: 'ok', data: {} }; | ||
} | ||
} |
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 { LifecycleHookUnit, ApplicationLifecycle, LifecycleHook, Inject, ArtusApplication, ArtusInjectEnum } from '../../../src'; | ||
|
||
@LifecycleHookUnit() | ||
export default class MyLifecycle implements ApplicationLifecycle { | ||
@Inject(ArtusInjectEnum.Application) | ||
private app: ArtusApplication; | ||
|
||
@LifecycleHook() | ||
public async configWillLoad() { | ||
this.app.config.httpConfig = this.app.config.httpConfig ?? {}; | ||
this.app.config.httpConfig.key1 = 'value1'; | ||
} | ||
} |
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,49 @@ | ||
{ | ||
"version": "2", | ||
"refMap": { | ||
"_app": { | ||
"relativedPath": "", | ||
"pluginConfig": {}, | ||
"items": [ | ||
{ | ||
"path": "config/config.default", | ||
"extname": ".ts", | ||
"filename": "config.default.ts", | ||
"loader": "config", | ||
"source": "app", | ||
"unitName": "_app", | ||
"loaderState": { | ||
"exportNames": [] | ||
} | ||
}, | ||
{ | ||
"path": "controller/home", | ||
"extname": ".ts", | ||
"filename": "home.ts", | ||
"loader": "module", | ||
"source": "app", | ||
"unitName": "_app", | ||
"loaderState": { | ||
"exportNames": [ | ||
"default" | ||
] | ||
} | ||
}, | ||
{ | ||
"path": "lifecycle", | ||
"extname": ".ts", | ||
"filename": "lifecycle.ts", | ||
"loader": "lifecycle-hook-unit", | ||
"source": "app", | ||
"unitName": "_app", | ||
"loaderState": { | ||
"exportNames": [ | ||
"default" | ||
] | ||
} | ||
} | ||
] | ||
} | ||
}, | ||
"extraPluginConfig": {} | ||
} |