Skip to content

Commit

Permalink
commit
Browse files Browse the repository at this point in the history
  • Loading branch information
ttsimon committed Apr 3, 2024
0 parents commit da09071
Show file tree
Hide file tree
Showing 59 changed files with 9,507 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# 🎨 editorconfig.org

root = true

[*]
charset = utf-8
end_of_line = lf
indent_style = space
indent_size = 2
trim_trailing_whitespace = true
insert_final_newline = true
7 changes: 7 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "./node_modules/mwts/",
"ignorePatterns": ["node_modules", "dist", "test", "jest.config.js", "typings"],
"env": {
"jest": true
}
}
18 changes: 18 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
logs/
npm-debug.log
yarn-error.log
node_modules/
package-lock.json
yarn.lock
coverage/
dist/
.idea/
run/
.DS_Store
*.sw*
*.un~
.tsbuildinfo
.tsbuildinfo.*
#src/
#./src/**/*.local.ts
config.local.ts
3 changes: 3 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
...require('mwts/.prettierrc.json')
}
30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# my-midway-project

## QuickStart

<!-- add docs here for user -->

see [midway docs][midway] for more detail.

### Development

```bash
$ npm i
$ npm run dev
$ open http://localhost:7001/
```

### Deploy

```bash
$ npm start
$ npm stop
```

### npm scripts

- Use `npm run lint` to check code style.
- Use `npm test` to run unit test.


[midway]: https://midwayjs.org
30 changes: 30 additions & 0 deletions README.zh-CN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# my-midway-project

## 快速入门

<!-- 在此次添加使用文档 -->

如需进一步了解,参见 [midway 文档][midway]

### 本地开发

```bash
$ npm i
$ npm run dev
$ open http://localhost:7001/
```

### 部署

```bash
$ npm start
$ npm stop
```

### 内置指令

- 使用 `npm run lint` 来做代码风格检查。
- 使用 `npm test` 来执行单元测试。


[midway]: https://midwayjs.org
2 changes: 2 additions & 0 deletions bootstrap.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
const { Bootstrap } = require('@midwayjs/bootstrap');
Bootstrap.run();
7 changes: 7 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
testPathIgnorePatterns: ['<rootDir>/test/fixtures'],
coveragePathIgnorePatterns: ['<rootDir>/test/'],
setupFilesAfterEnv: ['./jest.setup.js']
};
1 change: 1 addition & 0 deletions jest.setup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
jest.setTimeout(30000);
7 changes: 7 additions & 0 deletions migration.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
if [ $1 == "run" ];then
npx mwtypeorm migration:run -d application/config/config.default.ts
fi

if [ $1 == "generate" ];then
npx mwtypeorm migration:generate -d application/config/config.default.ts $2
fi
15 changes: 15 additions & 0 deletions migration/mysql/1684998784938-user.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { MigrationInterface, QueryRunner } from 'typeorm';

export class User1684998784938 implements MigrationInterface {
name = 'User1684998784938';

public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
'CREATE TABLE `user` (`id` int NOT NULL AUTO_INCREMENT, `name` varchar(255) NOT NULL, `age` int NOT NULL, PRIMARY KEY (`id`)) ENGINE=InnoDB'
);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query('DROP TABLE `user`');
}
}
15 changes: 15 additions & 0 deletions migration/mysql/1684999468601-user.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { MigrationInterface, QueryRunner } from 'typeorm';

export class User1684999468601 implements MigrationInterface {
name = 'User1684999468601';

public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
'ALTER TABLE `user` ADD `gender` varchar(255) NOT NULL'
);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query('ALTER TABLE `user` DROP COLUMN `gender`');
}
}
37 changes: 37 additions & 0 deletions migration/mysql/1685069789288-user.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { MigrationInterface, QueryRunner } from 'typeorm';

export class User1685069789288 implements MigrationInterface {
name = 'User1685069789288';

public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
'ALTER TABLE `user` ADD `create_time` datetime(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6)'
);
await queryRunner.query(
'ALTER TABLE `user` ADD `update_time` datetime(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)'
);
await queryRunner.query(
'ALTER TABLE `user` ADD `delete_time` datetime(6) NULL'
);
await queryRunner.query('ALTER TABLE `user` CHANGE `id` `id` int NOT NULL');
await queryRunner.query('ALTER TABLE `user` DROP PRIMARY KEY');
await queryRunner.query('ALTER TABLE `user` DROP COLUMN `id`');
await queryRunner.query(
'ALTER TABLE `user` ADD `id` bigint NOT NULL PRIMARY KEY'
);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query('ALTER TABLE `user` DROP COLUMN `id`');
await queryRunner.query(
'ALTER TABLE `user` ADD `id` int NOT NULL AUTO_INCREMENT'
);
await queryRunner.query('ALTER TABLE `user` ADD PRIMARY KEY (`id`)');
await queryRunner.query(
'ALTER TABLE `user` CHANGE `id` `id` int NOT NULL AUTO_INCREMENT'
);
await queryRunner.query('ALTER TABLE `user` DROP COLUMN `delete_time`');
await queryRunner.query('ALTER TABLE `user` DROP COLUMN `update_time`');
await queryRunner.query('ALTER TABLE `user` DROP COLUMN `create_time`');
}
}
19 changes: 19 additions & 0 deletions migration/mysql/1685082490484-user.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { MigrationInterface, QueryRunner } from 'typeorm';

export class User1685082490484 implements MigrationInterface {
name = 'User1685082490484';

public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query('ALTER TABLE `user` DROP PRIMARY KEY');
await queryRunner.query('ALTER TABLE `user` DROP COLUMN `id`');
await queryRunner.query(
'ALTER TABLE `user` ADD `id` bigint NOT NULL PRIMARY KEY AUTO_INCREMENT'
);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query('ALTER TABLE `user` DROP COLUMN `id`');
await queryRunner.query('ALTER TABLE `user` ADD `id` bigint NOT NULL');
await queryRunner.query('ALTER TABLE `user` ADD PRIMARY KEY (`id`)');
}
}
27 changes: 27 additions & 0 deletions migration/mysql/1685082956619-user.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { MigrationInterface, QueryRunner } from 'typeorm';

export class User1685082956619 implements MigrationInterface {
name = 'User1685082956619';

public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
'ALTER TABLE `user` CHANGE `id` `id` bigint NOT NULL'
);
await queryRunner.query('ALTER TABLE `user` DROP PRIMARY KEY');
await queryRunner.query('ALTER TABLE `user` DROP COLUMN `id`');
await queryRunner.query(
'ALTER TABLE `user` ADD `id` int NOT NULL PRIMARY KEY AUTO_INCREMENT'
);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query('ALTER TABLE `user` DROP COLUMN `id`');
await queryRunner.query(
'ALTER TABLE `user` ADD `id` bigint NOT NULL AUTO_INCREMENT'
);
await queryRunner.query('ALTER TABLE `user` ADD PRIMARY KEY (`id`)');
await queryRunner.query(
'ALTER TABLE `user` CHANGE `id` `id` bigint NOT NULL AUTO_INCREMENT'
);
}
}
51 changes: 51 additions & 0 deletions migration/mysql/1685263894453-user.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import { MigrationInterface, QueryRunner } from 'typeorm';

export class User1685263894453 implements MigrationInterface {
name = 'User1685263894453';

public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
"ALTER TABLE `user` CHANGE `id` `id` int NOT NULL AUTO_INCREMENT COMMENT '数据库主键,自增id'"
);
await queryRunner.query(
"ALTER TABLE `user` CHANGE `create_time` `create_time` datetime(6) NOT NULL COMMENT '创建时间' DEFAULT CURRENT_TIMESTAMP(6)"
);
await queryRunner.query(
"ALTER TABLE `user` CHANGE `update_time` `update_time` datetime(6) NOT NULL COMMENT '更新时间' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)"
);
await queryRunner.query(
"ALTER TABLE `user` CHANGE `delete_time` `delete_time` datetime(6) NULL COMMENT '软删除字段'"
);
await queryRunner.query(
'ALTER TABLE `user` CHANGE `name` `name` varchar(255) NULL'
);
await queryRunner.query('ALTER TABLE `user` CHANGE `age` `age` int NULL');
await queryRunner.query(
"ALTER TABLE `user` CHANGE `gender` `gender` varchar(255) NOT NULL DEFAULT '1'"
);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
'ALTER TABLE `user` CHANGE `gender` `gender` varchar(255) NOT NULL'
);
await queryRunner.query(
'ALTER TABLE `user` CHANGE `age` `age` int NOT NULL'
);
await queryRunner.query(
'ALTER TABLE `user` CHANGE `name` `name` varchar(255) NOT NULL'
);
await queryRunner.query(
'ALTER TABLE `user` CHANGE `delete_time` `delete_time` datetime(6) NULL'
);
await queryRunner.query(
'ALTER TABLE `user` CHANGE `update_time` `update_time` datetime(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)'
);
await queryRunner.query(
'ALTER TABLE `user` CHANGE `create_time` `create_time` datetime(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6)'
);
await queryRunner.query(
'ALTER TABLE `user` CHANGE `id` `id` int NOT NULL AUTO_INCREMENT'
);
}
}
58 changes: 58 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{
"name": "mightyena",
"version": "1.0.0",
"description": "",
"private": true,
"dependencies": {
"@midwayjs/bootstrap": "^3.0.0",
"@midwayjs/core": "^3.0.0",
"@midwayjs/decorator": "^3.0.0",
"@midwayjs/typeorm": "3",
"@midwayjs/validate": "^3.11.6",
"@midwayjs/web": "^3.0.0",
"dayjs": "^1.11.7",
"egg": "^2.0.0",
"egg-cors": "^2.2.3",
"joi": "17.9.1",
"mysql2": "^3.3.2",
"qs": "^6.11.2",
"typeorm": "^0.3.16"
},
"devDependencies": {
"@midwayjs/cli": "^2.0.0",
"@midwayjs/egg-ts-helper": "^1.0.1",
"@midwayjs/mock": "^3.0.0",
"@types/jest": "^29.2.0",
"@types/node": "14",
"@types/qs": "^6.9.7",
"cross-env": "^6.0.0",
"egg-mock": "^3.26.0",
"jest": "^29.2.2",
"mwts": "^1.0.5",
"ts-jest": "^29.0.3",
"typescript": "~4.8.0"
},
"engines": {
"node": ">=12.0.0"
},
"scripts": {
"start": "cross-env NODE_ENV=production node bootstrap.js",
"dev": "cross-env ets && cross-env NODE_ENV=local midway-bin dev --ts",
"test": "midway-bin test --ts",
"cov": "midway-bin cov --ts",
"lint": "mwts check",
"lint:fix": "mwts fix",
"ci": "npm run cov",
"build": "midway-bin build -c"
},
"midway-bin-clean": [
".vscode/.tsbuildinfo",
"dist"
],
"repository": {
"type": "git",
"url": ""
},
"author": "",
"license": "MIT"
}
Loading

0 comments on commit da09071

Please sign in to comment.