Skip to content

Commit 7a54eb0

Browse files
committed
add Dockerfile docker-compose
1 parent c5ac307 commit 7a54eb0

File tree

94 files changed

+6865
-818
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

94 files changed

+6865
-818
lines changed

.dockerignore

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
.vscode
2+
/node_modules
3+
4+
.eslintrc.js
5+
.prettierrc
6+
.prettierignore
7+
.prettierrc.json
8+
9+
Dockerfile
10+
docker-compose.yml
11+
.git
12+
13+
*.log

.prettierrc

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
{
22
"singleQuote": true,
3-
"trailingComma": "all"
3+
"trailingComma": "all",
4+
"tabWidth": 2,
5+
"semi": true,
6+
"bracketSpacing": true
47
}

1682652864086-migrations.ts

-20
This file was deleted.

1682654037795-migrations.ts

-14
This file was deleted.

1682655265751-migrations.ts

-14
This file was deleted.

Dockerfile

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
FROM node:16.14-alpine as base
2+
WORKDIR /app
3+
COPY package.json . yarn.lock ./
4+
RUN yarn install && yarn cache clean
5+
6+
FROM base as builder
7+
WORKDIR /app
8+
COPY . .
9+
COPY --from=base ./app/node_modules ./node_modules
10+
CMD yarn build
11+
12+
FROM base
13+
WORKDIR /app
14+
COPY --from=builder /app/dist ./dist
15+
COPY --from=builder ./app/.env .
16+
EXPOSE 3002
17+
CMD yarn start
18+

docker-compose.yml

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
version: '3'
2+
services:
3+
ezhome:
4+
restart: always
5+
build: .
6+
environment:
7+
- PORT=3002
8+
ports:
9+
- '3002:3002'
10+
volumes:
11+
- ./logs:/usr/src/app/dist/logs
12+
env_file:
13+
- .env
+24-15
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,29 @@
1-
import { MigrationInterface, QueryRunner } from "typeorm";
1+
import { MigrationInterface, QueryRunner } from 'typeorm';
22

33
export class AddCouponTable1682653067022 implements MigrationInterface {
4-
name = 'AddCouponTable1682653067022'
4+
name = 'AddCouponTable1682653067022';
55

6-
public async up(queryRunner: QueryRunner): Promise<void> {
7-
await queryRunner.query(`CREATE TABLE \`coupons\` (\`idCoupon\` int NOT NULL AUTO_INCREMENT, \`createDate\` date NOT NULL, \`startDate\` date NOT NULL, \`endDate\` date NOT NULL, \`value\` int NOT NULL, \`idUser\` int NOT NULL, \`user\` int NULL, PRIMARY KEY (\`idCoupon\`)) ENGINE=InnoDB`);
8-
await queryRunner.query(`ALTER TABLE \`homes\` ADD \`idCoupon\` int NULL`);
9-
await queryRunner.query(`ALTER TABLE \`coupons\` ADD CONSTRAINT \`FK_609acd00b593903cd918ad7d088\` FOREIGN KEY (\`user\`) REFERENCES \`users\`(\`idUser\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
10-
await queryRunner.query(`ALTER TABLE \`homes\` ADD CONSTRAINT \`FK_d6aa0c0f753cae0515519234275\` FOREIGN KEY (\`idCoupon\`) REFERENCES \`coupons\`(\`idCoupon\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
11-
}
12-
13-
public async down(queryRunner: QueryRunner): Promise<void> {
14-
await queryRunner.query(`ALTER TABLE \`homes\` DROP FOREIGN KEY \`FK_d6aa0c0f753cae0515519234275\``);
15-
await queryRunner.query(`ALTER TABLE \`coupons\` DROP FOREIGN KEY \`FK_609acd00b593903cd918ad7d088\``);
16-
await queryRunner.query(`ALTER TABLE \`homes\` DROP COLUMN \`idCoupon\``);
17-
await queryRunner.query(`DROP TABLE \`coupons\``);
18-
}
6+
public async up(queryRunner: QueryRunner): Promise<void> {
7+
await queryRunner.query(
8+
`CREATE TABLE \`coupons\` (\`idCoupon\` int NOT NULL AUTO_INCREMENT, \`createDate\` date NOT NULL, \`startDate\` date NOT NULL, \`endDate\` date NOT NULL, \`value\` int NOT NULL, \`idUser\` int NOT NULL, \`user\` int NULL, PRIMARY KEY (\`idCoupon\`)) ENGINE=InnoDB`,
9+
);
10+
await queryRunner.query(`ALTER TABLE \`homes\` ADD \`idCoupon\` int NULL`);
11+
await queryRunner.query(
12+
`ALTER TABLE \`coupons\` ADD CONSTRAINT \`FK_609acd00b593903cd918ad7d088\` FOREIGN KEY (\`user\`) REFERENCES \`users\`(\`idUser\`) ON DELETE NO ACTION ON UPDATE NO ACTION`,
13+
);
14+
await queryRunner.query(
15+
`ALTER TABLE \`homes\` ADD CONSTRAINT \`FK_d6aa0c0f753cae0515519234275\` FOREIGN KEY (\`idCoupon\`) REFERENCES \`coupons\`(\`idCoupon\`) ON DELETE NO ACTION ON UPDATE NO ACTION`,
16+
);
17+
}
1918

19+
public async down(queryRunner: QueryRunner): Promise<void> {
20+
await queryRunner.query(
21+
`ALTER TABLE \`homes\` DROP FOREIGN KEY \`FK_d6aa0c0f753cae0515519234275\``,
22+
);
23+
await queryRunner.query(
24+
`ALTER TABLE \`coupons\` DROP FOREIGN KEY \`FK_609acd00b593903cd918ad7d088\``,
25+
);
26+
await queryRunner.query(`ALTER TABLE \`homes\` DROP COLUMN \`idCoupon\``);
27+
await queryRunner.query(`DROP TABLE \`coupons\``);
28+
}
2029
}
+10-9
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1-
import { MigrationInterface, QueryRunner } from "typeorm";
1+
import { MigrationInterface, QueryRunner } from 'typeorm';
22

33
export class AddCouponTable1682654192714 implements MigrationInterface {
4-
name = 'AddCouponTable1682654192714'
4+
name = 'AddCouponTable1682654192714';
55

6-
public async up(queryRunner: QueryRunner): Promise<void> {
7-
await queryRunner.query(`ALTER TABLE \`coupons\` DROP COLUMN \`idUser\``);
8-
}
9-
10-
public async down(queryRunner: QueryRunner): Promise<void> {
11-
await queryRunner.query(`ALTER TABLE \`coupons\` ADD \`idUser\` int NOT NULL`);
12-
}
6+
public async up(queryRunner: QueryRunner): Promise<void> {
7+
await queryRunner.query(`ALTER TABLE \`coupons\` DROP COLUMN \`idUser\``);
8+
}
139

10+
public async down(queryRunner: QueryRunner): Promise<void> {
11+
await queryRunner.query(
12+
`ALTER TABLE \`coupons\` ADD \`idUser\` int NOT NULL`,
13+
);
14+
}
1415
}
+12-9
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
1-
import { MigrationInterface, QueryRunner } from "typeorm";
1+
import { MigrationInterface, QueryRunner } from 'typeorm';
22

33
export class AddCouponTable1682655449547 implements MigrationInterface {
4-
name = 'AddCouponTable1682655449547'
4+
name = 'AddCouponTable1682655449547';
55

6-
public async up(queryRunner: QueryRunner): Promise<void> {
7-
await queryRunner.query(`ALTER TABLE \`coupons\` ADD \`couponName\` varchar(255) NOT NULL`);
8-
}
9-
10-
public async down(queryRunner: QueryRunner): Promise<void> {
11-
await queryRunner.query(`ALTER TABLE \`coupons\` DROP COLUMN \`couponName\``);
12-
}
6+
public async up(queryRunner: QueryRunner): Promise<void> {
7+
await queryRunner.query(
8+
`ALTER TABLE \`coupons\` ADD \`couponName\` varchar(255) NOT NULL`,
9+
);
10+
}
1311

12+
public async down(queryRunner: QueryRunner): Promise<void> {
13+
await queryRunner.query(
14+
`ALTER TABLE \`coupons\` DROP COLUMN \`couponName\``,
15+
);
16+
}
1417
}
+24-13
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,29 @@
1-
import { MigrationInterface, QueryRunner } from "typeorm";
1+
import { MigrationInterface, QueryRunner } from 'typeorm';
22

33
export class AddCouponTable1682655674007 implements MigrationInterface {
4-
name = 'AddCouponTable1682655674007'
4+
name = 'AddCouponTable1682655674007';
55

6-
public async up(queryRunner: QueryRunner): Promise<void> {
7-
await queryRunner.query(`ALTER TABLE \`coupons\` CHANGE \`couponName\` \`couponname\` varchar(255) NOT NULL`);
8-
await queryRunner.query(`ALTER TABLE \`coupons\` DROP COLUMN \`couponname\``);
9-
await queryRunner.query(`ALTER TABLE \`coupons\` ADD \`couponname\` varchar(255) NOT NULL`);
10-
}
11-
12-
public async down(queryRunner: QueryRunner): Promise<void> {
13-
await queryRunner.query(`ALTER TABLE \`coupons\` DROP COLUMN \`couponname\``);
14-
await queryRunner.query(`ALTER TABLE \`coupons\` ADD \`couponname\` varchar(255) NOT NULL`);
15-
await queryRunner.query(`ALTER TABLE \`coupons\` CHANGE \`couponname\` \`couponName\` varchar(255) NOT NULL`);
16-
}
6+
public async up(queryRunner: QueryRunner): Promise<void> {
7+
await queryRunner.query(
8+
`ALTER TABLE \`coupons\` CHANGE \`couponName\` \`couponname\` varchar(255) NOT NULL`,
9+
);
10+
await queryRunner.query(
11+
`ALTER TABLE \`coupons\` DROP COLUMN \`couponname\``,
12+
);
13+
await queryRunner.query(
14+
`ALTER TABLE \`coupons\` ADD \`couponname\` varchar(255) NOT NULL`,
15+
);
16+
}
1717

18+
public async down(queryRunner: QueryRunner): Promise<void> {
19+
await queryRunner.query(
20+
`ALTER TABLE \`coupons\` DROP COLUMN \`couponname\``,
21+
);
22+
await queryRunner.query(
23+
`ALTER TABLE \`coupons\` ADD \`couponname\` varchar(255) NOT NULL`,
24+
);
25+
await queryRunner.query(
26+
`ALTER TABLE \`coupons\` CHANGE \`couponname\` \`couponName\` varchar(255) NOT NULL`,
27+
);
28+
}
1829
}
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
1-
import { MigrationInterface, QueryRunner } from "typeorm";
1+
import { MigrationInterface, QueryRunner } from 'typeorm';
22

33
export class AddCouponTableFix1682676157247 implements MigrationInterface {
4-
name = 'AddCouponTableFix1682676157247'
4+
name = 'AddCouponTableFix1682676157247';
55

6-
public async up(queryRunner: QueryRunner): Promise<void> {
7-
await queryRunner.query(`ALTER TABLE \`coupons\` ADD \`test\` int NULL`);
8-
}
9-
10-
public async down(queryRunner: QueryRunner): Promise<void> {
11-
await queryRunner.query(`ALTER TABLE \`coupons\` DROP COLUMN \`test\``);
12-
}
6+
public async up(queryRunner: QueryRunner): Promise<void> {
7+
await queryRunner.query(`ALTER TABLE \`coupons\` ADD \`test\` int NULL`);
8+
}
139

10+
public async down(queryRunner: QueryRunner): Promise<void> {
11+
await queryRunner.query(`ALTER TABLE \`coupons\` DROP COLUMN \`test\``);
12+
}
1413
}
+30-15
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,35 @@
1-
import { MigrationInterface, QueryRunner } from "typeorm";
1+
import { MigrationInterface, QueryRunner } from 'typeorm';
22

33
export class FixCouponCascade1683192661710 implements MigrationInterface {
4-
name = 'FixCouponCascade1683192661710'
4+
name = 'FixCouponCascade1683192661710';
55

6-
public async up(queryRunner: QueryRunner): Promise<void> {
7-
await queryRunner.query(`DROP INDEX \`FK_609acd00b593903cd918ad7d088\` ON \`coupons\``);
8-
await queryRunner.query(`DROP INDEX \`FK_d6aa0c0f753cae0515519234275\` ON \`homes\``);
9-
await queryRunner.query(`ALTER TABLE \`coupons\` ADD CONSTRAINT \`FK_609acd00b593903cd918ad7d088\` FOREIGN KEY (\`user\`) REFERENCES \`users\`(\`idUser\`) ON DELETE CASCADE ON UPDATE NO ACTION`);
10-
await queryRunner.query(`ALTER TABLE \`homes\` ADD CONSTRAINT \`FK_d6aa0c0f753cae0515519234275\` FOREIGN KEY (\`idCoupon\`) REFERENCES \`coupons\`(\`idCoupon\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
11-
}
12-
13-
public async down(queryRunner: QueryRunner): Promise<void> {
14-
await queryRunner.query(`ALTER TABLE \`homes\` DROP FOREIGN KEY \`FK_d6aa0c0f753cae0515519234275\``);
15-
await queryRunner.query(`ALTER TABLE \`coupons\` DROP FOREIGN KEY \`FK_609acd00b593903cd918ad7d088\``);
16-
await queryRunner.query(`CREATE INDEX \`FK_d6aa0c0f753cae0515519234275\` ON \`homes\` (\`idCoupon\`)`);
17-
await queryRunner.query(`CREATE INDEX \`FK_609acd00b593903cd918ad7d088\` ON \`coupons\` (\`user\`)`);
18-
}
6+
public async up(queryRunner: QueryRunner): Promise<void> {
7+
await queryRunner.query(
8+
`DROP INDEX \`FK_609acd00b593903cd918ad7d088\` ON \`coupons\``,
9+
);
10+
await queryRunner.query(
11+
`DROP INDEX \`FK_d6aa0c0f753cae0515519234275\` ON \`homes\``,
12+
);
13+
await queryRunner.query(
14+
`ALTER TABLE \`coupons\` ADD CONSTRAINT \`FK_609acd00b593903cd918ad7d088\` FOREIGN KEY (\`user\`) REFERENCES \`users\`(\`idUser\`) ON DELETE CASCADE ON UPDATE NO ACTION`,
15+
);
16+
await queryRunner.query(
17+
`ALTER TABLE \`homes\` ADD CONSTRAINT \`FK_d6aa0c0f753cae0515519234275\` FOREIGN KEY (\`idCoupon\`) REFERENCES \`coupons\`(\`idCoupon\`) ON DELETE NO ACTION ON UPDATE NO ACTION`,
18+
);
19+
}
1920

21+
public async down(queryRunner: QueryRunner): Promise<void> {
22+
await queryRunner.query(
23+
`ALTER TABLE \`homes\` DROP FOREIGN KEY \`FK_d6aa0c0f753cae0515519234275\``,
24+
);
25+
await queryRunner.query(
26+
`ALTER TABLE \`coupons\` DROP FOREIGN KEY \`FK_609acd00b593903cd918ad7d088\``,
27+
);
28+
await queryRunner.query(
29+
`CREATE INDEX \`FK_d6aa0c0f753cae0515519234275\` ON \`homes\` (\`idCoupon\`)`,
30+
);
31+
await queryRunner.query(
32+
`CREATE INDEX \`FK_609acd00b593903cd918ad7d088\` ON \`coupons\` (\`user\`)`,
33+
);
34+
}
2035
}
+18-11
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,23 @@
1-
import { MigrationInterface, QueryRunner } from "typeorm";
1+
import { MigrationInterface, QueryRunner } from 'typeorm';
22

33
export class FixCouponCascade1683193005207 implements MigrationInterface {
4-
name = 'FixCouponCascade1683193005207'
4+
name = 'FixCouponCascade1683193005207';
55

6-
public async up(queryRunner: QueryRunner): Promise<void> {
7-
await queryRunner.query(`ALTER TABLE \`homes\` DROP FOREIGN KEY \`FK_d6aa0c0f753cae0515519234275\``);
8-
await queryRunner.query(`ALTER TABLE \`homes\` ADD CONSTRAINT \`FK_d6aa0c0f753cae0515519234275\` FOREIGN KEY (\`idCoupon\`) REFERENCES \`coupons\`(\`idCoupon\`) ON DELETE CASCADE ON UPDATE NO ACTION`);
9-
}
10-
11-
public async down(queryRunner: QueryRunner): Promise<void> {
12-
await queryRunner.query(`ALTER TABLE \`homes\` DROP FOREIGN KEY \`FK_d6aa0c0f753cae0515519234275\``);
13-
await queryRunner.query(`ALTER TABLE \`homes\` ADD CONSTRAINT \`FK_d6aa0c0f753cae0515519234275\` FOREIGN KEY (\`idCoupon\`) REFERENCES \`coupons\`(\`idCoupon\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
14-
}
6+
public async up(queryRunner: QueryRunner): Promise<void> {
7+
await queryRunner.query(
8+
`ALTER TABLE \`homes\` DROP FOREIGN KEY \`FK_d6aa0c0f753cae0515519234275\``,
9+
);
10+
await queryRunner.query(
11+
`ALTER TABLE \`homes\` ADD CONSTRAINT \`FK_d6aa0c0f753cae0515519234275\` FOREIGN KEY (\`idCoupon\`) REFERENCES \`coupons\`(\`idCoupon\`) ON DELETE CASCADE ON UPDATE NO ACTION`,
12+
);
13+
}
1514

15+
public async down(queryRunner: QueryRunner): Promise<void> {
16+
await queryRunner.query(
17+
`ALTER TABLE \`homes\` DROP FOREIGN KEY \`FK_d6aa0c0f753cae0515519234275\``,
18+
);
19+
await queryRunner.query(
20+
`ALTER TABLE \`homes\` ADD CONSTRAINT \`FK_d6aa0c0f753cae0515519234275\` FOREIGN KEY (\`idCoupon\`) REFERENCES \`coupons\`(\`idCoupon\`) ON DELETE NO ACTION ON UPDATE NO ACTION`,
21+
);
22+
}
1623
}
+18-11
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,23 @@
1-
import { MigrationInterface, QueryRunner } from "typeorm";
1+
import { MigrationInterface, QueryRunner } from 'typeorm';
22

33
export class FixCouponCascade1683193305992 implements MigrationInterface {
4-
name = 'FixCouponCascade1683193305992'
4+
name = 'FixCouponCascade1683193305992';
55

6-
public async up(queryRunner: QueryRunner): Promise<void> {
7-
await queryRunner.query(`ALTER TABLE \`homes\` DROP FOREIGN KEY \`FK_d6aa0c0f753cae0515519234275\``);
8-
await queryRunner.query(`ALTER TABLE \`homes\` ADD CONSTRAINT \`FK_d6aa0c0f753cae0515519234275\` FOREIGN KEY (\`idCoupon\`) REFERENCES \`coupons\`(\`idCoupon\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
9-
}
10-
11-
public async down(queryRunner: QueryRunner): Promise<void> {
12-
await queryRunner.query(`ALTER TABLE \`homes\` DROP FOREIGN KEY \`FK_d6aa0c0f753cae0515519234275\``);
13-
await queryRunner.query(`ALTER TABLE \`homes\` ADD CONSTRAINT \`FK_d6aa0c0f753cae0515519234275\` FOREIGN KEY (\`idCoupon\`) REFERENCES \`coupons\`(\`idCoupon\`) ON DELETE CASCADE ON UPDATE NO ACTION`);
14-
}
6+
public async up(queryRunner: QueryRunner): Promise<void> {
7+
await queryRunner.query(
8+
`ALTER TABLE \`homes\` DROP FOREIGN KEY \`FK_d6aa0c0f753cae0515519234275\``,
9+
);
10+
await queryRunner.query(
11+
`ALTER TABLE \`homes\` ADD CONSTRAINT \`FK_d6aa0c0f753cae0515519234275\` FOREIGN KEY (\`idCoupon\`) REFERENCES \`coupons\`(\`idCoupon\`) ON DELETE NO ACTION ON UPDATE NO ACTION`,
12+
);
13+
}
1514

15+
public async down(queryRunner: QueryRunner): Promise<void> {
16+
await queryRunner.query(
17+
`ALTER TABLE \`homes\` DROP FOREIGN KEY \`FK_d6aa0c0f753cae0515519234275\``,
18+
);
19+
await queryRunner.query(
20+
`ALTER TABLE \`homes\` ADD CONSTRAINT \`FK_d6aa0c0f753cae0515519234275\` FOREIGN KEY (\`idCoupon\`) REFERENCES \`coupons\`(\`idCoupon\`) ON DELETE CASCADE ON UPDATE NO ACTION`,
21+
);
22+
}
1623
}

0 commit comments

Comments
 (0)