-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build(mwcp): breaking change ESM only
- Loading branch information
1 parent
a887dbc
commit f747789
Showing
32 changed files
with
387 additions
and
239 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,2 @@ | ||
// process.env.MIDWAY_SERVER_ENV = 'unittest' | ||
// process.env['NODE_ENV'] = 'unittest' | ||
const { Bootstrap } = require('@midwayjs/bootstrap'); | ||
Bootstrap.run(); | ||
import { Bootstrap } from '@midwayjs/bootstrap'; | ||
await Bootstrap.run(); |
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
28 changes: 28 additions & 0 deletions
28
packages/midway-component-fetch/src/app/default.controller.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,28 @@ | ||
import { | ||
Config as _Config, | ||
Controller, | ||
Get, | ||
} from '@midwayjs/core' | ||
|
||
import { Config, ConfigKey, Msg } from '##/lib/types.js' | ||
|
||
|
||
@Controller(`/_${ConfigKey.namespace}`) | ||
export class DefaultComponentController { | ||
|
||
@_Config(ConfigKey.config) readonly config: Config | ||
|
||
@Get('/hello') | ||
hello(): string { | ||
// this.valiateRoute() | ||
return Msg.hello | ||
} | ||
|
||
// valiateRoute(): void { | ||
// if (! this.config.enableDefaultRoute) { | ||
// throw new Error('route is not enabled') | ||
// } | ||
// } | ||
|
||
} | ||
|
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,3 @@ | ||
|
||
export * from './default.controller.js' | ||
|
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
23 changes: 23 additions & 0 deletions
23
packages/midway-component-fetch/src/config/config.unittest.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,23 @@ | ||
import { Config, MiddlewareConfig } from '../index.js' | ||
import { | ||
initialConfig, | ||
initialMiddlewareConfig, | ||
initMiddlewareOptions, | ||
} from '../lib/config.js' | ||
|
||
|
||
export const fetchConfig: Config = { | ||
...initialConfig, | ||
captureRequestHeaders: [...initialConfig.captureRequestHeaders], | ||
captureResponseHeaders: [...initialConfig.captureResponseHeaders], | ||
enableTrace: true, | ||
} | ||
|
||
export const fetchMiddlewareConfig: Readonly<Omit<MiddlewareConfig, 'match'>> = { | ||
...initialMiddlewareConfig, | ||
ignore: [], | ||
options: { | ||
...initMiddlewareOptions, | ||
}, | ||
} | ||
|
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,28 +1,42 @@ | ||
/* eslint-disable @typescript-eslint/no-extraneous-class */ | ||
import 'tsconfig-paths/register' | ||
|
||
import { join } from 'path' | ||
|
||
import { Configuration, ILifeCycle } from '@midwayjs/core' | ||
|
||
import { useComponents } from './imports' | ||
import { ConfigKey } from './lib/index' | ||
/* eslint-disable import/max-dependencies */ | ||
// import assert from 'node:assert' | ||
|
||
import { | ||
Configuration, | ||
ILifeCycle, | ||
ILogger, | ||
Logger, | ||
} from '@midwayjs/core' | ||
|
||
import * as DefulatConfig from './config/config.default.js' | ||
// import * as LocalConfig from './config/config.local.js' | ||
import * as UnittestConfig from './config/config.unittest.js' | ||
import { useComponents } from './imports.js' | ||
import { | ||
// Config as Conf, | ||
ConfigKey, | ||
// MiddlewareConfig, | ||
} from './lib/types.js' | ||
|
||
|
||
@Configuration({ | ||
namespace: ConfigKey.namespace, | ||
importConfigs: [join(__dirname, 'config')], | ||
importConfigs: [ | ||
{ | ||
default: DefulatConfig, | ||
// local: LocalConfig, | ||
unittest: UnittestConfig, | ||
}, | ||
], | ||
imports: useComponents, | ||
}) | ||
export class AutoConfiguration implements ILifeCycle { | ||
|
||
// @App() protected readonly app: Application | ||
@Logger() protected readonly logger: ILogger | ||
|
||
// async onReady(): Promise<void> { | ||
// assert(this.app, 'this.app must be set') | ||
// const fetch = await this.app.getApplicationContext().getAsync(FetchComponent) | ||
// assert(fetch) | ||
// } | ||
async onReady(): Promise<void> { | ||
|
||
this.logger.info(`[${ConfigKey.componentName}] onReady`) | ||
} | ||
} | ||
|
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
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
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,10 +1,10 @@ | ||
|
||
export * from './config' | ||
export * from './types' | ||
export { FetchComponent } from './fetch.component' | ||
export { FetchService } from './fetch.service' | ||
export * from './config.js' | ||
export * from './types.js' | ||
export { FetchComponent } from './fetch.component.js' | ||
export { FetchService } from './fetch.service.js' | ||
export { | ||
defaultfetchConfigCallbacks, | ||
genRequestHeaders, | ||
} from './helper' | ||
} from './helper.js' | ||
|
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 was deleted.
Oops, something went wrong.
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,17 @@ | ||
import assert from 'node:assert/strict' | ||
|
||
import { fileShortPath } from '@waiting/shared-core' | ||
|
||
import { testConfig } from './root.config.js' | ||
|
||
|
||
describe(fileShortPath(import.meta.url), () => { | ||
|
||
describe('should work', () => { | ||
it('always passed', () => { | ||
assert(testConfig) | ||
}) | ||
}) | ||
|
||
}) | ||
|
Oops, something went wrong.