Skip to content

Commit

Permalink
chore(boilerplate): update
Browse files Browse the repository at this point in the history
  • Loading branch information
waitingsong committed Jan 28, 2024
1 parent 649df7c commit 582101c
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 11 deletions.
1 change: 1 addition & 0 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ rules:
"@typescript-eslint/no-unused-vars": 0
"node/no-unpublished-import": 0
"@typescript-eslint/prefer-ts-expect-error": 0
"@typescript-eslint/no-extraneous-class": 0
"unicorn/filename-case": 0

23 changes: 23 additions & 0 deletions .scripts/set-env-local.sh.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash


export MIDWAY_SERVER_ENV=local
export NODE_ENV=local
export OTEL_EXPORTER_OTLP_ENDPOINT="http://127.0.0.1:4317"
export TS_NODE_PROJECT="test/tsconfig.json"
export POSTGRES_HOST="127.0.0.1"
export POSTGRES_PORT="5432"
export POSTGRES_DB=""
export POSTGRES_USER="postgres"
export POSTGRES_PASSWORD="postgres"
export ALI_ALB_IPS="120.55"
export ALI_ALB_GROUPID="sgp-7z"
export ALI_ECS_AID="LTAI5"
export ALI_ECS_ASECRET="Dr"
export ALI_ECS_IDS=""
export ALI_ECS_IPS=""
export ALI_OSS_AID="LTAI4"
export ALI_OSS_ASECRET="FRK"
export ALI_OSS_ENDPOINT="https://oss-cn-hangzhou.aliyuncs.com"
export ALI_OSS_BUCKET=""

23 changes: 23 additions & 0 deletions .scripts/set-env-test.sh.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash


export MIDWAY_SERVER_ENV=unittest
export NODE_ENV=unittest
export OTEL_EXPORTER_OTLP_ENDPOINT="http://127.0.0.1:4317"
export TS_NODE_PROJECT="test/tsconfig.json"
export POSTGRES_HOST="127.0.0.1"
export POSTGRES_PORT="5432"
export POSTGRES_DB=""
export POSTGRES_USER="postgres"
export POSTGRES_PASSWORD="postgres"
export ALI_ALB_IPS="120.55"
export ALI_ALB_GROUPID="sgp-7z"
export ALI_ECS_AID="LTAI5"
export ALI_ECS_ASECRET="Dr"
export ALI_ECS_IDS=""
export ALI_ECS_IPS=""
export ALI_OSS_AID="LTAI4"
export ALI_OSS_ASECRET="FRK"
export ALI_OSS_ENDPOINT="https://oss-cn-hangzhou.aliyuncs.com"
export ALI_OSS_BUCKET=""

1 change: 0 additions & 1 deletion .vscode/launch.json.example
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@
],
"runtimeExecutable": "npm",
"skipFiles": [
"**/node_modules/**",
"**/node_modules/rxjs/**",
"<node_internals>/**",
"<node_internals>/**/*.js"
Expand Down
4 changes: 2 additions & 2 deletions packages/mw-demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
},
"license": "MIT",
"dependencies": {
"@midwayjs/info": "^3.14.0",
"@mwcp/share": "*"
"@mwcp/otel": "20 -22",
"@mwcp/share": "20 - 22"
},
"devDependencies": {
},
Expand Down
2 changes: 2 additions & 0 deletions packages/mw-demo/src/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
MidwayInformationService,
MidwayWebRouterService,
} from '@midwayjs/core'
import { TraceInit } from '@mwcp/otel'
import {
Application,
IMidwayContainer,
Expand Down Expand Up @@ -65,6 +66,7 @@ export class AutoConfiguration implements ILifeCycle {
}
}

@TraceInit({ namespace: ConfigKey.namespace })
async onReady(container: IMidwayContainer): Promise<void> {
void container
assert(
Expand Down
13 changes: 5 additions & 8 deletions packages/mw-demo/src/imports.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as info from '@midwayjs/info'
import * as koa from '@midwayjs/koa'
import * as swagger from '@midwayjs/swagger'
import * as otel from '@mwcp/otel'


/* c8 ignore next 4 */
Expand All @@ -10,15 +11,11 @@ const CI = !! (process.env['MIDWAY_SERVER_ENV'] === 'unittest'
|| process.env['NODE_ENV'] === 'local'
)

export const useComponents: IComponentInfo[] = []
export const useComponents: IComponentInfo[] = [otel]
if (CI) {
if ( ! useComponents.includes(koa)) {
useComponents.push(koa)
useComponents.push(info)
}
if ( ! useComponents.includes(swagger)) {
useComponents.push(swagger)
}
useComponents.push(koa)
useComponents.push(info)
useComponents.push(swagger)
}

export interface IComponentInfo {
Expand Down

0 comments on commit 582101c

Please sign in to comment.