Skip to content

Commit

Permalink
feat: 通用模块化,使用 happy-node-utils 集成
Browse files Browse the repository at this point in the history
  • Loading branch information
ddzyan committed Nov 10, 2022
1 parent 09360f3 commit 28f195a
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 146 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,7 @@ additional.json
```

具体请参考 [sequelize-auto-midway](https://github.com/happyNode/sequelize-auto-midway)

# 更新记录

- [2022-11-10] 通用模块化,使用 happy-node-utils 集成
51 changes: 39 additions & 12 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"chalk": "^5.0.1",
"dayjs": "^1.11.5",
"dotenv": "^16.0.1",
"happy-node-utils": "^1.0.3",
"ipip-ipdb": "^0.6.0",
"joi": "^17.6.0",
"lodash": "^4.17.21",
Expand Down
123 changes: 0 additions & 123 deletions src/app/comm/utils.ts

This file was deleted.

3 changes: 2 additions & 1 deletion src/app/service/sysReqLog.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Provide, Inject } from '@midwayjs/core';
import * as utils from 'happy-node-utils';

import { BaseService } from '../../core/baseService';
import { SysReqLogMapping } from '../mapping/sysReqLog';
Expand All @@ -16,7 +17,7 @@ export class SysReqLogService extends BaseService {
method: string | undefined,
adminId: number | null
): Promise<void> {
const ip = this.utils.getReqIP(this.ctx);
const ip = utils.getReqIP(this.ctx);
await this.mapping.saveNew({
action: url,
param: JSON.stringify(params),
Expand Down
15 changes: 9 additions & 6 deletions src/config/config.unittest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,15 @@ export default (appInfo: MidwayAppInfo): MidwayConfig => {
password: process.env.REDIS_CLIENT_PASSWORD,
},
};
config.task = {
redis: {
port: +process.env.REDIS_CLIENT_PORT,
host: process.env.REDIS_CLIENT_HOST,
db: +process.env.REDIS_CLIENT_DB,
password: process.env.REDIS_CLIENT_PASSWORD,

config.bull = {
defaultQueueOptions: {
redis: {
port: +process.env.REDIS_CLIENT_PORT,
host: process.env.REDIS_CLIENT_HOST,
db: +process.env.REDIS_CLIENT_DB,
password: process.env.REDIS_CLIENT_PASSWORD,
},
},
};

Expand Down
4 changes: 0 additions & 4 deletions src/core/baseService.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { App, Inject } from '@midwayjs/core';
import { Application, Context } from '@midwayjs/koa';
import Utils from '../app/comm/utils';

export abstract class BaseService {
@App()
Expand All @@ -9,9 +8,6 @@ export abstract class BaseService {
@Inject()
protected ctx: Context;

@Inject()
protected utils: Utils;

protected mapping;

async findAndCountAll(page: number, limit: number, where = {}) {
Expand Down

0 comments on commit 28f195a

Please sign in to comment.