mirror of
https://github.com/cool-team-official/cool-admin-midway.git
synced 2024-11-01 14:10:29 +08:00
修改启动方式
This commit is contained in:
parent
d926285766
commit
af8790537a
@ -38,6 +38,7 @@
|
||||
"ws": "^8.16.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@midwayjs/cli": "^2.1.1",
|
||||
"@midwayjs/mock": "^3.15.2",
|
||||
"@types/jest": "^29.5.12",
|
||||
"@types/koa": "^2.15.0",
|
||||
@ -54,13 +55,13 @@
|
||||
},
|
||||
"scripts": {
|
||||
"start": "NODE_ENV=production node ./bootstrap.js",
|
||||
"dev": "cross-env NODE_ENV=local mwtsc --watch --run @midwayjs/mock/app.js",
|
||||
"cov": "jest --coverage",
|
||||
"dev": "cross-env && cross-env NODE_ENV=local TS_NODE_TYPE_CHECK=false TS_NODE_TRANSPILE_ONLY=true midway-bin dev --ts",
|
||||
"cov": "midway-bin cov --ts",
|
||||
"lint": "mwts check",
|
||||
"lint:fix": "mwts fix",
|
||||
"ci": "npm run cov",
|
||||
"build": "mwtsc --cleanOutDir",
|
||||
"pm2:start": "pm2 start ./bootstrap.js -i 2 --name cool-admin",
|
||||
"build": "midway-bin build -c",
|
||||
"pm2:start": "pm2 start ./bootstrap.js -i max --name cool-admin",
|
||||
"pm2:stop": "pm2 stop cool-admin & pm2 delete cool-admin"
|
||||
},
|
||||
"midway-bin-clean": [
|
||||
|
@ -31,30 +31,17 @@ export class BaseAppEvent {
|
||||
this.checkKeys();
|
||||
}
|
||||
|
||||
@Event('onServerReady')
|
||||
async onServerReady() {
|
||||
setTimeout(() => {
|
||||
this.coreLogger.info(
|
||||
`
|
||||
项目启动成功,欢迎使用 cool-admin 框架! 官网: https://cool-js.com
|
||||
服务访问地址: http://127.0.0.1:${this.port}`
|
||||
);
|
||||
}, 2000);
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查配置
|
||||
*/
|
||||
async checkConfig() {
|
||||
if (this.config.base.jwt.secret == 'cool-admin-xxxxxx') {
|
||||
this.coreLogger.warn(
|
||||
'检测到模块[base] jwt.secret 配置是默认值,请不要关闭!即将自动修改...'
|
||||
'\x1B[36m 检测到模块[base] jwt.secret 配置是默认值,请不要关闭!即将自动修改... \x1B[0m'
|
||||
);
|
||||
setTimeout(() => {
|
||||
const filePath = path.join(
|
||||
this.app.getBaseDir(),
|
||||
'..',
|
||||
'src',
|
||||
'modules',
|
||||
'base',
|
||||
'config.ts'
|
||||
@ -70,7 +57,7 @@ export class BaseAppEvent {
|
||||
this.coreLogger.info(
|
||||
'\x1B[36m [cool:module:base] midwayjs cool module base auto modify jwt.secret\x1B[0m'
|
||||
);
|
||||
}, 15000);
|
||||
}, 6000);
|
||||
}
|
||||
}
|
||||
|
||||
@ -80,13 +67,11 @@ export class BaseAppEvent {
|
||||
async checkKeys() {
|
||||
if (this.configKeys == 'cool-admin-keys-xxxxxx') {
|
||||
this.coreLogger.warn(
|
||||
'检测到配置Keys是默认值,请不要关闭!即将自动修改...'
|
||||
'\x1B[36m 检测到基础配置[Keys] 是默认值,请不要关闭!即将自动修改... \x1B[0m'
|
||||
);
|
||||
setTimeout(() => {
|
||||
const filePath = path.join(
|
||||
this.app.getBaseDir(),
|
||||
'..',
|
||||
'src',
|
||||
'config',
|
||||
'config.default.ts'
|
||||
);
|
||||
@ -101,7 +86,7 @@ export class BaseAppEvent {
|
||||
this.coreLogger.info(
|
||||
'\x1B[36m [cool:module:base] midwayjs cool keys auto modify \x1B[0m'
|
||||
);
|
||||
}, 15000);
|
||||
}, 6000);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { DemoGoodsService } from '../../service/goods';
|
||||
import { DemoGoodsEntity } from '../../entity/goods';
|
||||
import { Body, Inject, Post, Provide } from '@midwayjs/decorator';
|
||||
import { Body, Config, Inject, Post, Provide } from '@midwayjs/decorator';
|
||||
import { CoolController, BaseController } from '@cool-midway/core';
|
||||
import { InjectEntityModel } from '@midwayjs/typeorm';
|
||||
import { Repository } from 'typeorm';
|
||||
|
@ -18,10 +18,10 @@ export class DemoGoodsService extends BaseService {
|
||||
async sqlPage(query) {
|
||||
await this.demoGoodsEntity.save({
|
||||
id: 11,
|
||||
title: '11',
|
||||
price: 11,
|
||||
description: '11',
|
||||
mainImage: '11',
|
||||
title: '标题',
|
||||
price: 99.0,
|
||||
description: '商品描述',
|
||||
mainImage: 'https://cool-js.com/logo.png',
|
||||
});
|
||||
await this.demoGoodsEntity.delete({ id: 11 });
|
||||
return this.sqlRenderPage(
|
||||
|
@ -30,13 +30,11 @@ export class UserAppEvent {
|
||||
async checkConfig() {
|
||||
if (this.config.user.jwt.secret == 'cool-app-xxxxxx') {
|
||||
this.coreLogger.warn(
|
||||
'检测到模块[user] jwt.secret 配置是默认值,请不要关闭!即将自动修改...'
|
||||
'\x1B[36m 检测到模块[user] jwt.secret 配置是默认值,请不要关闭!即将自动修改... \x1B[0m'
|
||||
);
|
||||
setTimeout(() => {
|
||||
const filePath = path.join(
|
||||
this.app.getBaseDir(),
|
||||
'..',
|
||||
'src',
|
||||
'modules',
|
||||
'user',
|
||||
'config.ts'
|
||||
@ -49,7 +47,7 @@ export class UserAppEvent {
|
||||
this.coreLogger.info(
|
||||
'\x1B[36m [cool:module:user] midwayjs cool module user auto modify jwt.secret\x1B[0m'
|
||||
);
|
||||
}, 15000);
|
||||
}, 6000);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user