diff --git a/client/ecommerce/public/_redirects b/client/ecommerce/public/_redirects new file mode 100644 index 0000000..78f7f20 --- /dev/null +++ b/client/ecommerce/public/_redirects @@ -0,0 +1 @@ +/* /index.html 200 \ No newline at end of file diff --git a/server/ecommerce/db/migrations/1711285970930-NewMigration.ts b/server/ecommerce/db/migrations/1711285970930-NewMigration.ts new file mode 100644 index 0000000..0ab82a7 --- /dev/null +++ b/server/ecommerce/db/migrations/1711285970930-NewMigration.ts @@ -0,0 +1,113 @@ +import { MigrationInterface, QueryRunner } from 'typeorm'; + +export class NewMigration1711285970930 implements MigrationInterface { + name = 'NewMigration1711285970930'; + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query( + `CREATE TABLE "admin_notifications" ("id" SERIAL NOT NULL, "username" character varying NOT NULL, "userId" integer NOT NULL, "action" character varying NOT NULL, "createdAt" TIMESTAMP NOT NULL DEFAULT now(), CONSTRAINT "PK_1fecd1cab747b7ab6e850091901" PRIMARY KEY ("id"))`, + ); + await queryRunner.query( + `CREATE TABLE "image" ("id" SERIAL NOT NULL, "imageUrl" character varying, "imageName" character varying NOT NULL, "productId" integer, CONSTRAINT "PK_d6db1ab4ee9ad9dbe86c64e4cc3" PRIMARY KEY ("id"))`, + ); + await queryRunner.query( + `CREATE TABLE "product" ("id" SERIAL NOT NULL, "brand" character varying NOT NULL, "category" character varying NOT NULL, "title" character varying NOT NULL, "description" character varying NOT NULL, "price" integer NOT NULL, "userId" integer, CONSTRAINT "PK_bebc9158e480b949565b4dc7a82" PRIMARY KEY ("id"))`, + ); + await queryRunner.query( + `CREATE TABLE "profile" ("id" SERIAL NOT NULL, "aboutYou" character varying, "country" character varying NOT NULL DEFAULT 'Poland', CONSTRAINT "PK_3dd8bfc97e4a77c70971591bdcb" PRIMARY KEY ("id"))`, + ); + await queryRunner.query( + `CREATE TABLE "follow" ("id" SERIAL NOT NULL, "followerId" integer, "followingId" integer, CONSTRAINT "PK_fda88bc28a84d2d6d06e19df6e5" PRIMARY KEY ("id"))`, + ); + await queryRunner.query( + `CREATE TABLE "message" ("id" SERIAL NOT NULL, "content" character varying NOT NULL, "conversationId" integer, "authorId" integer, CONSTRAINT "PK_ba01f0a3e0123651915008bc578" PRIMARY KEY ("id"))`, + ); + await queryRunner.query( + `CREATE TABLE "avatar" ("id" SERIAL NOT NULL, "avatarUrl" character varying, "avatarName" character varying NOT NULL, "userId" integer, CONSTRAINT "PK_50e36da9d45349941038eaf149d" PRIMARY KEY ("id"))`, + ); + await queryRunner.query( + `CREATE TABLE "review" ("id" SERIAL NOT NULL, "comment" character varying NOT NULL, "rating" integer NOT NULL, "createdAt" TIMESTAMP NOT NULL DEFAULT now(), "reviewRecipientId" integer, "reviewCreatorId" integer, CONSTRAINT "PK_2e4299a343a81574217255c00ca" PRIMARY KEY ("id"))`, + ); + await queryRunner.query( + `CREATE TABLE "user" ("id" SERIAL NOT NULL, "username" character varying NOT NULL, "googleId" character varying, "email" character varying NOT NULL, "password" character varying, "role" character varying NOT NULL DEFAULT 'user', "avatar" character varying, "profileId" integer, "avatarEntityId" integer, CONSTRAINT "UQ_78a916df40e02a9deb1c4b75edb" UNIQUE ("username"), CONSTRAINT "REL_9466682df91534dd95e4dbaa61" UNIQUE ("profileId"), CONSTRAINT "REL_b8bf2e21095af67654559d2fed" UNIQUE ("avatarEntityId"), CONSTRAINT "PK_cace4a159ff9f2512dd42373760" PRIMARY KEY ("id"))`, + ); + await queryRunner.query( + `CREATE TABLE "conversation" ("id" SERIAL NOT NULL, "lastMessageSentAt" TIMESTAMP NOT NULL DEFAULT now(), "creatorId" integer, "recipientId" integer, "lastMessageSentId" integer, CONSTRAINT "REL_941c7b5b184899308341512638" UNIQUE ("lastMessageSentId"), CONSTRAINT "PK_864528ec4274360a40f66c29845" PRIMARY KEY ("id"))`, + ); + await queryRunner.query( + `CREATE TABLE "notification" ("id" SERIAL NOT NULL, "isRead" boolean NOT NULL, "date" TIMESTAMP NOT NULL DEFAULT now(), "senderId" integer, "receiverId" integer, CONSTRAINT "PK_705b6c7cdf9b2c2ff7ac7872cb7" PRIMARY KEY ("id"))`, + ); + await queryRunner.query( + `CREATE TABLE "product_notification" ("id" SERIAL NOT NULL, "message" character varying NOT NULL, "isRead" boolean NOT NULL, "receiverId" integer NOT NULL, "productId" integer, CONSTRAINT "PK_17eabbfd538c6ab61d0fa6425e0" PRIMARY KEY ("id"))`, + ); + await queryRunner.query( + `ALTER TABLE "product" ADD CONSTRAINT "FK_329b8ae12068b23da547d3b4798" FOREIGN KEY ("userId") REFERENCES "user"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`, + ); + await queryRunner.query( + `ALTER TABLE "follow" ADD CONSTRAINT "FK_550dce89df9570f251b6af2665a" FOREIGN KEY ("followerId") REFERENCES "user"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`, + ); + await queryRunner.query( + `ALTER TABLE "follow" ADD CONSTRAINT "FK_e9f68503556c5d72a161ce38513" FOREIGN KEY ("followingId") REFERENCES "user"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`, + ); + await queryRunner.query( + `ALTER TABLE "message" ADD CONSTRAINT "FK_c72d82fa0e8699a141ed6cc41b3" FOREIGN KEY ("authorId") REFERENCES "user"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`, + ); + await queryRunner.query( + `ALTER TABLE "review" ADD CONSTRAINT "FK_30909ac2f5b587d9944fb7cf3ef" FOREIGN KEY ("reviewRecipientId") REFERENCES "user"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`, + ); + await queryRunner.query( + `ALTER TABLE "review" ADD CONSTRAINT "FK_b9d6f5a7e9a73348c3dbf005d80" FOREIGN KEY ("reviewCreatorId") REFERENCES "user"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`, + ); + await queryRunner.query( + `ALTER TABLE "user" ADD CONSTRAINT "FK_9466682df91534dd95e4dbaa616" FOREIGN KEY ("profileId") REFERENCES "profile"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`, + ); + await queryRunner.query( + `ALTER TABLE "user" ADD CONSTRAINT "FK_b8bf2e21095af67654559d2fed2" FOREIGN KEY ("avatarEntityId") REFERENCES "avatar"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`, + ); + await queryRunner.query( + `ALTER TABLE "conversation" ADD CONSTRAINT "FK_941c7b5b184899308341512638a" FOREIGN KEY ("lastMessageSentId") REFERENCES "message"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`, + ); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query( + `ALTER TABLE "conversation" DROP CONSTRAINT "FK_941c7b5b184899308341512638a"`, + ); + await queryRunner.query( + `ALTER TABLE "user" DROP CONSTRAINT "FK_b8bf2e21095af67654559d2fed2"`, + ); + await queryRunner.query( + `ALTER TABLE "user" DROP CONSTRAINT "FK_9466682df91534dd95e4dbaa616"`, + ); + await queryRunner.query( + `ALTER TABLE "review" DROP CONSTRAINT "FK_b9d6f5a7e9a73348c3dbf005d80"`, + ); + await queryRunner.query( + `ALTER TABLE "review" DROP CONSTRAINT "FK_30909ac2f5b587d9944fb7cf3ef"`, + ); + await queryRunner.query( + `ALTER TABLE "message" DROP CONSTRAINT "FK_c72d82fa0e8699a141ed6cc41b3"`, + ); + await queryRunner.query( + `ALTER TABLE "follow" DROP CONSTRAINT "FK_e9f68503556c5d72a161ce38513"`, + ); + await queryRunner.query( + `ALTER TABLE "follow" DROP CONSTRAINT "FK_550dce89df9570f251b6af2665a"`, + ); + await queryRunner.query( + `ALTER TABLE "product" DROP CONSTRAINT "FK_329b8ae12068b23da547d3b4798"`, + ); + await queryRunner.query(`DROP TABLE "product_notification"`); + await queryRunner.query(`DROP TABLE "notification"`); + await queryRunner.query(`DROP TABLE "conversation"`); + await queryRunner.query(`DROP TABLE "user"`); + await queryRunner.query(`DROP TABLE "review"`); + await queryRunner.query(`DROP TABLE "avatar"`); + await queryRunner.query(`DROP TABLE "message"`); + await queryRunner.query(`DROP TABLE "follow"`); + await queryRunner.query(`DROP TABLE "profile"`); + await queryRunner.query(`DROP TABLE "product"`); + await queryRunner.query(`DROP TABLE "image"`); + await queryRunner.query(`DROP TABLE "admin_notifications"`); + } +} diff --git a/server/ecommerce/ormconfig.ts b/server/ecommerce/ormconfig.ts index a3dc171..4ec0c4b 100644 --- a/server/ecommerce/ormconfig.ts +++ b/server/ecommerce/ormconfig.ts @@ -15,7 +15,7 @@ import { AdminNotifications } from 'src/utils/entities/adminNotifications.entity import { DataSource } from 'typeorm'; export let config: PostgresConnectionOptions; -if (process.env.IS_PRODUCTION === 'true') { +if (process.env.IS_PRODUCTION == 'true') { config = { type: 'postgres', database: process.env.EXTERNAL_POSTGRES_DB, diff --git a/server/ecommerce/package.json b/server/ecommerce/package.json index eed6203..4e78932 100644 --- a/server/ecommerce/package.json +++ b/server/ecommerce/package.json @@ -8,7 +8,7 @@ "scripts": { "build": "nest build", "format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"", - "start": "nest start", + "start": "NODE_OPTIONS='--max_old_space_size=400' nest start", "start:dev": "nest start --watch", "start:debug": "nest start --debug --watch", "start:prod": "node dist/main", diff --git a/server/ecommerce/src/main.ts b/server/ecommerce/src/main.ts index 807dc46..17bfed6 100644 --- a/server/ecommerce/src/main.ts +++ b/server/ecommerce/src/main.ts @@ -14,6 +14,6 @@ async function bootstrap() { }); const { httpAdapter } = app.get(HttpAdapterHost); app.useGlobalFilters(new ZodExceptionFilter(httpAdapter)); - await app.listen(3000); + await app.listen(process.env.PORT || 3000); } bootstrap();