Skip to content
This repository has been archived by the owner on Dec 30, 2022. It is now read-only.

Commit

Permalink
chore: relese v1.8.0 (#13)
Browse files Browse the repository at this point in the history
* fix: mock logic

* feat: add exception tips

* chore: update docker compose

* fix: node up path error

* fix: migrations path

* chore: change entity column simple-json to json

* chore: add migration generate script

* fix: import project data should be serialization

* fix: apiTestHistory some field allow null
  • Loading branch information
buqiyuan authored Oct 12, 2022
1 parent 38a69b2 commit 5c73c6b
Show file tree
Hide file tree
Showing 23 changed files with 523 additions and 438 deletions.
2 changes: 1 addition & 1 deletion docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ services:
eoapi-remote-server:
# build: 从当前路径构建镜像
build: .
image: eoapi-remote-server
image: eoapi/eoapi-remote-server:1.8.0
container_name: eoapi-remote-server
restart: always
env_file:
Expand Down
2 changes: 1 addition & 1 deletion ecosystem.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// https://pm2.keymetrics.io/docs/usage/docker-pm2-nodejs/
module.exports = [
{
script: 'dist/main.js',
script: 'dist/src/main.js',
name: 'eoapi-remote-server',
exec_mode: 'cluster',
instances: 2,
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
"start": "cross-env NODE_ENV=development nest start",
"start:dev": "rimraf dist && cross-env NODE_ENV=development nest start --watch",
"start:debug": "nest start --debug --watch",
"start:prod": "cross-env NODE_ENV=production node dist/main.js",
"start:prod": "cross-env NODE_ENV=production node dist/src/main.js",
"migration:create": "npx typeorm-ts-node-commonjs migration:create ./src/migrations/create-table",
"migration:generate": "npx typeorm-ts-node-commonjs migration:generate ./src/migrations/update-table -d ./src/config/data-source.ts",
"migration:generate": "node ./scripts/migration-generate.js",
"migration:run": "npm run build&&npx typeorm-ts-node-commonjs migration:run -d ./src/config/data-source.ts",
"migration:revert": "npm run typeorm migration:revert",
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
Expand Down
22 changes: 22 additions & 0 deletions scripts/migration-generate.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
const { exec } = require('child_process');

const runMigrationGenerate = async function () {
const npm_package_version = process.env.npm_package_version.replaceAll(
'.',
'_',
);
console.log('npm_package_version', npm_package_version);
exec(
`npx typeorm-ts-node-commonjs migration:generate ./src/migrations/update-table_${npm_package_version} -d ./src/config/data-source.ts`,
(error, stdout, stderr) => {
if (!error) {
// 成功
console.log('更新成功', error);
} else {
// 失败
console.log('更新失败', error);
}
},
);
};
runMigrationGenerate();
3 changes: 3 additions & 0 deletions src/common/class/res.class.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { version } from '../../../package.json';

export class ResOp {
readonly data: any;
readonly statusCode: number;
readonly message: string;
readonly version = version;

constructor(code: number, data?: any, message = 'success') {
this.statusCode = code;
Expand Down
5 changes: 5 additions & 0 deletions src/common/filters/api-exception.filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ import { ApiException } from '../exceptions/api.exception';
import { ResOp } from '../class/res.class';
import { isDev } from '@/utils';

const errorTips = {
401: '未登录',
403: '拒绝访问',
} as const;

/**
* 异常接管,统一异常返回数据
*/
Expand Down
4 changes: 2 additions & 2 deletions src/config/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ export const getConfiguration = () => ({
entities: [__dirname + '/../**/entities/*.entity.{ts,js}'],
autoLoadEntities: true,
synchronize: false,
logging: false,
logging: ['error'],
timezone: '+08:00', // 东八区
migrations: ['dist/migrations/**/*.js'],
migrations: ['dist/src/migrations/**/*.js'],
migrationsRun: true,
cli: {
migrationsDir: 'src/migrations',
Expand Down
10 changes: 5 additions & 5 deletions src/entities/apiTestHistory.entity.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import { Column, Entity, TableColumnOptions } from 'typeorm';
import { Column, Entity } from 'typeorm';
import { FictitiousBase } from './base.entity';

@Entity({ name: 'api_test_history' })
export class ApiTestHistory extends FictitiousBase {
@Column({ default: 0 })
projectID: number;

@Column()
@Column({ nullable: true })
apiDataID: number;

@Column({ type: 'simple-json' })
@Column({ type: 'json' })
general: string;

@Column({ type: 'simple-json' })
@Column({ type: 'json' })
request: string;

@Column({ type: 'simple-json' })
@Column({ type: 'json' })
response: string;
}
2 changes: 1 addition & 1 deletion src/entities/mock.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export class Mock extends Base {
@Column()
apiDataID: number;

@Column({ type: 'longtext' })
@Column({ type: 'json' })
response: string;

@Column()
Expand Down
Loading

0 comments on commit 5c73c6b

Please sign in to comment.