Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V1.7.0 #183

Merged
merged 3 commits into from
May 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@ jobs:
- name: Upload Coverage
uses: codecov/codecov-action@v3
with:
# token: ${{secrets.CODECOV_TOKEN}} # required for private repos
token: ${{secrets.CODECOV_TOKEN}}
directory: coverage
fail_ci_if_error: true
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@ logs/*
.DS_Store

coverage/

bucket/*
!bucket/.gitkeep
Empty file added bucket/.gitkeep
Empty file.
3,205 changes: 2,962 additions & 243 deletions package-lock.json

Large diffs are not rendered by default.

8 changes: 7 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
},
"license": "Apache-2.0",
"dependencies": {
"@aws-sdk/client-cloudfront": "^3.582.0",
"@aws-sdk/client-s3": "3.481.0",
"@vendia/serverless-express": "4.12.6",
"axios": "1.6.3",
Expand All @@ -71,12 +72,15 @@
"express-async-errors": "3.1.1",
"express-fileupload": "1.4.3",
"jsonwebtoken": "9.0.2",
"mime-types": "^2.1.35",
"mysql2": "3.6.5",
"node-cache": "5.1.2",
"reflect-metadata": "0.2.1",
"sharp": "^0.33.4",
"source-map-support": "0.5.21",
"tslib": "2.6.2",
"typeorm": "0.3.17",
"uuid": "^9.0.1",
"winston": "3.11.0",
"winston-loki": "6.0.8"
},
Expand All @@ -93,8 +97,10 @@
"@types/express-fileupload": "1.4.4",
"@types/jest": "29.5.11",
"@types/jsonwebtoken": "9.0.5",
"@types/mime-types": "^2.1.4",
"@types/node": "20.10.5",
"@types/supertest": "6.0.2",
"@types/uuid": "^9.0.8",
"@types/validator": "13.11.7",
"@typescript-eslint/eslint-plugin": "6.16.0",
"@typescript-eslint/parser": "6.16.0",
Expand All @@ -116,7 +122,7 @@
"jest": "29.7.0",
"lint-staged": "15.2.0",
"prettier": "3.1.1",
"sqlite3": "5.1.6",
"sqlite3": "^5.1.6",
"supertest": "6.3.3",
"ts-jest": "29.1.1",
"ts-node": "10.9.2",
Expand Down
Binary file added serverless_express_template.db
Binary file not shown.
43 changes: 43 additions & 0 deletions src/database/migrations/1716477015921-migrations.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { MigrationInterface, QueryRunner } from 'typeorm';

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

public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`CREATE TABLE "user" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar NOT NULL, "avatar" varchar, "created_at" datetime NOT NULL DEFAULT (datetime('now')), "updated_at" datetime NOT NULL DEFAULT (datetime('now')), "deletion_date" datetime, "username" varchar NOT NULL, "email" varchar NOT NULL, "password" varchar NOT NULL, CONSTRAINT "UQ_78a916df40e02a9deb1c4b75edb" UNIQUE ("username"), CONSTRAINT "UQ_e12875dfb3b1d92d7d7c5377e22" UNIQUE ("email"))`,
);
await queryRunner.query(
`CREATE TABLE "session" ("id" varchar PRIMARY KEY NOT NULL, "expires_in" integer NOT NULL, "created_at" datetime NOT NULL DEFAULT (datetime('now')), "userId" integer)`,
);
await queryRunner.query(
`CREATE TABLE "temporary_session" ("id" varchar PRIMARY KEY NOT NULL, "expires_in" integer NOT NULL, "created_at" datetime NOT NULL DEFAULT (datetime('now')), "userId" integer, CONSTRAINT "FK_3d2f174ef04fb312fdebd0ddc53" FOREIGN KEY ("userId") REFERENCES "user" ("id") ON DELETE SET NULL ON UPDATE CASCADE)`,
);
await queryRunner.query(
`INSERT INTO "temporary_session"("id", "expires_in", "created_at", "userId") SELECT "id", "expires_in", "created_at", "userId" FROM "session"`,
);
await queryRunner.query(`DROP TABLE "session"`);
await queryRunner.query(
`ALTER TABLE "temporary_session" RENAME TO "session"`,
);
// Password: Admin@123
await queryRunner.query(
`INSERT INTO \`user\` (\`name\`, \`username\`, \`email\`, \`password\`) VALUES ('Admin', 'admin', '[email protected]', '$2a$08$K.dwMjqI4ngCX5Ne8Y/WyOBZJ5ekncZJRU7m7VoI.yv81XR1i7fpa')`,
);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`ALTER TABLE "session" RENAME TO "temporary_session"`,
);
await queryRunner.query(
`CREATE TABLE "session" ("id" varchar PRIMARY KEY NOT NULL, "expires_in" integer NOT NULL, "created_at" datetime NOT NULL DEFAULT (datetime('now')), "userId" integer)`,
);
await queryRunner.query(
`INSERT INTO "session"("id", "expires_in", "created_at", "userId") SELECT "id", "expires_in", "created_at", "userId" FROM "temporary_session"`,
);
await queryRunner.query(`DROP TABLE "temporary_session"`);
await queryRunner.query(`DROP TABLE "session"`);
await queryRunner.query(`DROP TABLE "user"`);
}
}
4 changes: 3 additions & 1 deletion src/database/sources/development.source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ const developmentDataSource = new DataSource({
synchronize: false,
logging: true,
entities: [`${path.resolve(__dirname, '..', '..')}/entities/*.{js,ts}`],
migrations: [`${path.resolve(__dirname, '..')}/migrations/*.{js,ts}`],
migrations: [
`${path.resolve(__dirname, '..')}/migrations/*-migrations.{js,ts}`,
],
subscribers: [],
});

Expand Down
2 changes: 0 additions & 2 deletions src/entities/user.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import {
IsEmail,
IsNotEmpty,
IsOptional,
IsUrl,
MaxLength,
MinLength,
} from 'class-validator';
Expand All @@ -30,7 +29,6 @@ export class User {

@Column({ name: 'avatar', nullable: true, default: null, type: String })
@IsOptional()
@IsUrl()
avatar: string | null;

@CreateDateColumn({ name: 'created_at' })
Expand Down
10 changes: 6 additions & 4 deletions src/environments/default.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
{
"database": {
"type": "mysql",
"type": "sqlite",
"host": "mysql-db.host",
"port": 3306,
"username": "root",
"password": "password",
"name": "serverless_express_template"
"name": "serverless_express_template.db"
},
"s3": {
"AWS_ACCESS_KEY_ID": "",
"AWS_SECRET_ACCESS_KEY": "",
"AWS_REGION": "us-east-1",
"AWS_S3_BUCKET": "serverless_express_template"
"AWS_S3_BUCKET": ""
},
"port": 3333
"storage": "local",
"port": 3333,
"hostname": "http://localhost:3333"
}
8 changes: 5 additions & 3 deletions src/environments/production.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
{
"database": {
"type": "mysql",
"type": "sqlite",
"host": "mysql.host",
"port": 3306,
"username": "username",
"password": "password",
"name": "serverless_express_template"
"name": "serverless_express_template.db"
},
"s3": {
"AWS_ACCESS_KEY_ID": "",
"AWS_SECRET_ACCESS_KEY": "",
"AWS_REGION": "us-east-1",
"AWS_S3_BUCKET": "serverless_express_template"
},
"port": 3333
"storage": "local",
"port": 3333,
"hostname": "http://localhost:3333"
}
5 changes: 4 additions & 1 deletion src/environments/staging.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,8 @@
"AWS_SECRET_ACCESS_KEY": "",
"AWS_REGION": "us-east-1",
"AWS_S3_BUCKET": "serverless_express_template"
}
},
"storage": "local",
"port": 3333,
"hostname": "http://localhost:3333"
}
Loading
Loading