Skip to content

Commit

Permalink
update packages and run prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
CaramelFur committed Sep 6, 2022
1 parent 32ee928 commit 422b4a7
Show file tree
Hide file tree
Showing 87 changed files with 446 additions and 457 deletions.
1 change: 0 additions & 1 deletion .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# These are supported funding model platforms

github: rubikscraft

1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,4 @@ yarn-error.log
!.yarn/versions
.pnp.*


temp
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules
dist
.angular
.yarn
2 changes: 1 addition & 1 deletion .yarnrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ nodeLinker: node-modules

plugins:
- path: .yarn/plugins/@yarnpkg/plugin-version.cjs
spec: "@yarnpkg/plugin-version"
spec: '@yarnpkg/plugin-version'

yarnPath: .yarn/releases/yarn-berry.cjs
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ Every featured marked here should work in the latest release.
- [x] Deletable images
- [x] Proper DB migrations
- [x] Show own images in list
- [X] Correct previews on chats
- [x] Correct previews on chats

- [ ] Expiring images
- [ ] White mode
Expand Down
16 changes: 8 additions & 8 deletions backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
},
"dependencies": {
"@fastify/helmet": "^10.0.0",
"@fastify/multipart": "^7.1.1",
"@fastify/multipart": "^7.1.2",
"@fastify/static": "^6.5.0",
"@nestjs/common": "^9.0.11",
"@nestjs/config": "^2.2.0",
Expand Down Expand Up @@ -52,28 +52,28 @@
"reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2",
"rxjs": "^7.5.6",
"sharp": "^0.30.7",
"sharp": "^0.31.0",
"stream-parser": "^0.3.1",
"thunks": "^4.9.6",
"typeorm": "0.3.9",
"zod": "^3.18.0"
"zod": "^3.19.0"
},
"devDependencies": {
"@nestjs/cli": "^9.1.1",
"@nestjs/schematics": "^9.0.2",
"@nestjs/cli": "^9.1.2",
"@nestjs/schematics": "^9.0.3",
"@nestjs/testing": "^9.0.11",
"@types/bcrypt": "^5.0.0",
"@types/cors": "^2.8.12",
"@types/ms": "^0.7.31",
"@types/multer": "^1.4.7",
"@types/node": "^18.7.14",
"@types/node": "^18.7.15",
"@types/passport-jwt": "^3.0.6",
"@types/passport-local": "^1.0.34",
"@types/passport-strategy": "^0.2.35",
"@types/sharp": "^0.30.5",
"@types/supertest": "^2.0.12",
"@typescript-eslint/eslint-plugin": "^5.36.1",
"@typescript-eslint/parser": "^5.36.1",
"@typescript-eslint/eslint-plugin": "^5.36.2",
"@typescript-eslint/parser": "^5.36.2",
"eslint": "^8.23.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-prettier": "^4.2.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ import { Injectable, Logger } from '@nestjs/common';
import {
DecodedPref,
PrefValueType,
PrefValueTypeStrings
PrefValueTypeStrings,
} from 'picsur-shared/dist/dto/preferences.dto';
import {
AsyncFailable,
Fail,
Failable,
FT,
HasFailed
HasFailed,
} from 'picsur-shared/dist/types';

type Enum = Record<string, string>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@ import { InjectRepository } from '@nestjs/typeorm';
import {
DecodedSysPref,
PrefValueType,
PrefValueTypeStrings
PrefValueTypeStrings,
} from 'picsur-shared/dist/dto/preferences.dto';
import { SysPreference } from 'picsur-shared/dist/dto/sys-preferences.enum';
import { AsyncFailable, Fail, FT, HasFailed } from 'picsur-shared/dist/types';
import { Repository } from 'typeorm';
import {
ESysPreferenceBackend,
ESysPreferenceSchema
ESysPreferenceSchema,
} from '../../database/entities/sys-preference.entity';
import {
SysPreferenceList,
SysPreferenceValueTypes
SysPreferenceValueTypes,
} from '../../models/constants/syspreferences.const';
import { MutexFallBack } from '../../util/mutex-fallback';
import { PreferenceCommonService } from './preference-common.service';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@ import { InjectRepository } from '@nestjs/typeorm';
import {
DecodedUsrPref,
PrefValueType,
PrefValueTypeStrings
PrefValueTypeStrings,
} from 'picsur-shared/dist/dto/preferences.dto';
import { UsrPreference } from 'picsur-shared/dist/dto/usr-preferences.enum';
import { AsyncFailable, Fail, FT, HasFailed } from 'picsur-shared/dist/types';
import { Repository } from 'typeorm';
import {
EUsrPreferenceBackend,
EUsrPreferenceSchema
EUsrPreferenceSchema,
} from '../../database/entities/usr-preference.entity';
import {
UsrPreferenceList,
UsrPreferenceValueTypes
UsrPreferenceValueTypes,
} from '../../models/constants/usrpreferences.const';
import { MutexFallBack } from '../../util/mutex-fallback';
import { PreferenceCommonService } from './preference-common.service';
Expand Down
2 changes: 1 addition & 1 deletion backend/src/collections/role-db/role-db.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { ERoleBackend } from '../../database/entities/role.entity';
import {
ImmutableRolesList,
SystemRoleDefaults,
SystemRolesList
SystemRolesList,
} from '../../models/constants/roles.const';
import { RoleDbService } from './role-db.service';

Expand Down
7 changes: 3 additions & 4 deletions backend/src/collections/role-db/role-db.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ import {
Fail,
FT,
HasFailed,
HasSuccess
HasSuccess,
} from 'picsur-shared/dist/types';
import { makeUnique } from 'picsur-shared/dist/util/unique';
import { In, Repository } from 'typeorm';
import { ERoleBackend } from '../../database/entities/role.entity';
import { Permissions } from '../../models/constants/permissions.const';
import {
ImmutableRolesList,
UndeletableRolesList
UndeletableRolesList,
} from '../../models/constants/roles.const';

@Injectable()
Expand All @@ -24,8 +24,7 @@ export class RoleDbService {
constructor(
@InjectRepository(ERoleBackend)
private readonly rolesRepository: Repository<ERoleBackend>,
) {
}
) {}

public async create(
name: string,
Expand Down
8 changes: 4 additions & 4 deletions backend/src/collections/user-db/user-db.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
Fail,
FT,
HasFailed,
HasSuccess
HasSuccess,
} from 'picsur-shared/dist/types';
import { FindResult } from 'picsur-shared/dist/types/find-result';
import { makeUnique } from 'picsur-shared/dist/util/unique';
Expand All @@ -16,12 +16,12 @@ import { EUserBackend } from '../../database/entities/user.entity';
import { Permissions } from '../../models/constants/permissions.const';
import {
DefaultRolesList,
SoulBoundRolesList
SoulBoundRolesList,
} from '../../models/constants/roles.const';
import {
ImmutableUsersList,
LockedLoginUsersList,
UndeletableUsersList
UndeletableUsersList,
} from '../../models/constants/special-users.const';
import { GetCols } from '../../util/collection';
import { SysPreferenceDbService } from '../preference-db/sys-preference-db.service';
Expand Down Expand Up @@ -198,7 +198,7 @@ export class UserDbService {
select: ['id'],
});

return { available: !found};
return { available: !found };
} catch (e) {
return Fail(FT.Database, e);
}
Expand Down
2 changes: 1 addition & 1 deletion backend/src/config/early/host.config.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { ConfigService } from '@nestjs/config';
import {
ParseBool,
ParseInt,
ParseString
ParseString,
} from 'picsur-shared/dist/util/parse-simple';
import { EnvPrefix } from '../config.static';

Expand Down
2 changes: 1 addition & 1 deletion backend/src/config/early/serve-static.config.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Injectable, Logger } from '@nestjs/common';
import { ConfigService } from '@nestjs/config';
import {
ServeStaticModuleOptions,
ServeStaticModuleOptionsFactory
ServeStaticModuleOptionsFactory,
} from '@nestjs/serve-static';
import { join } from 'path';
import { ParseString } from 'picsur-shared/dist/util/parse-simple';
Expand Down
5 changes: 1 addition & 4 deletions backend/src/config/early/type-orm.config.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,7 @@ export class TypeOrmConfigService implements TypeOrmOptionsFactory {
this.configService.get(`${EnvPrefix}DB_HOST`),
'localhost',
),
port: ParseInt(
this.configService.get(`${EnvPrefix}DB_PORT`),
5432,
),
port: ParseInt(this.configService.get(`${EnvPrefix}DB_PORT`), 5432),
username: ParseString(
this.configService.get(`${EnvPrefix}DB_USERNAME`),
DefaultName,
Expand Down
6 changes: 4 additions & 2 deletions backend/src/database/entities/apikey.entity.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { EApiKeySchema } from 'picsur-shared/dist/entities/apikey.entity';
import {
Column, Entity,
Column,
Entity,
Index,
ManyToOne, PrimaryGeneratedColumn
ManyToOne,
PrimaryGeneratedColumn,
} from 'typeorm';
import { z } from 'zod';
import { EUserBackend } from './user.entity';
Expand Down
8 changes: 7 additions & 1 deletion backend/src/database/entities/user.entity.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import { EUserSchema } from 'picsur-shared/dist/entities/user.entity';
import { Column, Entity, Index, OneToMany, PrimaryGeneratedColumn } from 'typeorm';
import {
Column,
Entity,
Index,
OneToMany,
PrimaryGeneratedColumn,
} from 'typeorm';
import { z } from 'zod';
import { EApiKeyBackend } from './apikey.entity';

Expand Down
127 changes: 88 additions & 39 deletions backend/src/database/migrations/1661692206479-V_0_3_0_a.ts
Original file line number Diff line number Diff line change
@@ -1,44 +1,93 @@
import { MigrationInterface, QueryRunner } from "typeorm";
import { MigrationInterface, QueryRunner } from 'typeorm';

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

public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`CREATE TABLE "e_image_derivative_backend" ("_id" uuid NOT NULL DEFAULT uuid_generate_v4(), "image_id" character varying NOT NULL, "key" character varying NOT NULL, "filetype" character varying NOT NULL, "last_read" TIMESTAMP NOT NULL, "data" bytea NOT NULL, CONSTRAINT "UQ_fa03f5333afd74c5cc5ff780d75" UNIQUE ("image_id", "key"), CONSTRAINT "PK_ff1ecff935b8d7bdcea89087810" PRIMARY KEY ("_id"))`);
await queryRunner.query(`CREATE INDEX "IDX_37055605f39b3f8847232d604f" ON "e_image_derivative_backend" ("image_id") `);
await queryRunner.query(`CREATE INDEX "IDX_7dc534a666f442383341896062" ON "e_image_derivative_backend" ("key") `);
await queryRunner.query(`CREATE TABLE "e_image_file_backend" ("_id" uuid NOT NULL DEFAULT uuid_generate_v4(), "image_id" character varying NOT NULL, "variant" character varying NOT NULL, "filetype" character varying NOT NULL, "data" bytea NOT NULL, CONSTRAINT "UQ_872384f20feaf7bfd27e28b8d4a" UNIQUE ("image_id", "variant"), CONSTRAINT "PK_95953be58a506e5de46feec6186" PRIMARY KEY ("_id"))`);
await queryRunner.query(`CREATE INDEX "IDX_8055f37d3b9f52f421b94ee84d" ON "e_image_file_backend" ("image_id") `);
await queryRunner.query(`CREATE INDEX "IDX_d0500b00b0b4109b623f897c2d" ON "e_image_file_backend" ("variant") `);
await queryRunner.query(`CREATE TABLE "e_image_backend" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "user_id" character varying NOT NULL, "created" TIMESTAMP NOT NULL, CONSTRAINT "PK_5f7993001a7c82564ec5300540d" PRIMARY KEY ("id"))`);
await queryRunner.query(`CREATE TABLE "e_role_backend" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "name" character varying NOT NULL, "permissions" text array NOT NULL, CONSTRAINT "UQ_cbedb9f42a98a82d91422e7fedf" UNIQUE ("name"), CONSTRAINT "PK_af7ba6a46bf69a7b10c425f0367" PRIMARY KEY ("id"))`);
await queryRunner.query(`CREATE INDEX "IDX_cbedb9f42a98a82d91422e7fed" ON "e_role_backend" ("name") `);
await queryRunner.query(`CREATE TABLE "e_sys_preference_backend" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "key" character varying NOT NULL, "value" character varying NOT NULL, CONSTRAINT "UQ_b04e47c4814fb6e315c5879fa75" UNIQUE ("key"), CONSTRAINT "PK_b79f051e19b46e74cf255e9ba3b" PRIMARY KEY ("id"))`);
await queryRunner.query(`CREATE INDEX "IDX_b04e47c4814fb6e315c5879fa7" ON "e_sys_preference_backend" ("key") `);
await queryRunner.query(`CREATE TABLE "e_user_backend" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "username" character varying NOT NULL, "roles" text array NOT NULL, "hashed_password" character varying NOT NULL, CONSTRAINT "UQ_ae538430fd08b28f4ab297eff09" UNIQUE ("username"), CONSTRAINT "PK_0b9d256d52e55a48d32e8b64d96" PRIMARY KEY ("id"))`);
await queryRunner.query(`CREATE INDEX "IDX_ae538430fd08b28f4ab297eff0" ON "e_user_backend" ("username") `);
await queryRunner.query(`CREATE TABLE "e_usr_preference_backend" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "key" character varying NOT NULL, "value" character varying NOT NULL, "user_id" character varying NOT NULL, CONSTRAINT "UQ_576678406a479d569123a33e132" UNIQUE ("key", "user_id"), CONSTRAINT "PK_8f8251016cd9283e7eb04c5498b" PRIMARY KEY ("id"))`);
await queryRunner.query(`CREATE INDEX "IDX_673fe530e2484ff7e31ac81099" ON "e_usr_preference_backend" ("key") `);
await queryRunner.query(`CREATE INDEX "IDX_f1a427e855045fa793c275861a" ON "e_usr_preference_backend" ("user_id") `);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`DROP INDEX "public"."IDX_f1a427e855045fa793c275861a"`);
await queryRunner.query(`DROP INDEX "public"."IDX_673fe530e2484ff7e31ac81099"`);
await queryRunner.query(`DROP TABLE "e_usr_preference_backend"`);
await queryRunner.query(`DROP INDEX "public"."IDX_ae538430fd08b28f4ab297eff0"`);
await queryRunner.query(`DROP TABLE "e_user_backend"`);
await queryRunner.query(`DROP INDEX "public"."IDX_b04e47c4814fb6e315c5879fa7"`);
await queryRunner.query(`DROP TABLE "e_sys_preference_backend"`);
await queryRunner.query(`DROP INDEX "public"."IDX_cbedb9f42a98a82d91422e7fed"`);
await queryRunner.query(`DROP TABLE "e_role_backend"`);
await queryRunner.query(`DROP TABLE "e_image_backend"`);
await queryRunner.query(`DROP INDEX "public"."IDX_d0500b00b0b4109b623f897c2d"`);
await queryRunner.query(`DROP INDEX "public"."IDX_8055f37d3b9f52f421b94ee84d"`);
await queryRunner.query(`DROP TABLE "e_image_file_backend"`);
await queryRunner.query(`DROP INDEX "public"."IDX_7dc534a666f442383341896062"`);
await queryRunner.query(`DROP INDEX "public"."IDX_37055605f39b3f8847232d604f"`);
await queryRunner.query(`DROP TABLE "e_image_derivative_backend"`);
}
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`CREATE TABLE "e_image_derivative_backend" ("_id" uuid NOT NULL DEFAULT uuid_generate_v4(), "image_id" character varying NOT NULL, "key" character varying NOT NULL, "filetype" character varying NOT NULL, "last_read" TIMESTAMP NOT NULL, "data" bytea NOT NULL, CONSTRAINT "UQ_fa03f5333afd74c5cc5ff780d75" UNIQUE ("image_id", "key"), CONSTRAINT "PK_ff1ecff935b8d7bdcea89087810" PRIMARY KEY ("_id"))`,
);
await queryRunner.query(
`CREATE INDEX "IDX_37055605f39b3f8847232d604f" ON "e_image_derivative_backend" ("image_id") `,
);
await queryRunner.query(
`CREATE INDEX "IDX_7dc534a666f442383341896062" ON "e_image_derivative_backend" ("key") `,
);
await queryRunner.query(
`CREATE TABLE "e_image_file_backend" ("_id" uuid NOT NULL DEFAULT uuid_generate_v4(), "image_id" character varying NOT NULL, "variant" character varying NOT NULL, "filetype" character varying NOT NULL, "data" bytea NOT NULL, CONSTRAINT "UQ_872384f20feaf7bfd27e28b8d4a" UNIQUE ("image_id", "variant"), CONSTRAINT "PK_95953be58a506e5de46feec6186" PRIMARY KEY ("_id"))`,
);
await queryRunner.query(
`CREATE INDEX "IDX_8055f37d3b9f52f421b94ee84d" ON "e_image_file_backend" ("image_id") `,
);
await queryRunner.query(
`CREATE INDEX "IDX_d0500b00b0b4109b623f897c2d" ON "e_image_file_backend" ("variant") `,
);
await queryRunner.query(
`CREATE TABLE "e_image_backend" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "user_id" character varying NOT NULL, "created" TIMESTAMP NOT NULL, CONSTRAINT "PK_5f7993001a7c82564ec5300540d" PRIMARY KEY ("id"))`,
);
await queryRunner.query(
`CREATE TABLE "e_role_backend" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "name" character varying NOT NULL, "permissions" text array NOT NULL, CONSTRAINT "UQ_cbedb9f42a98a82d91422e7fedf" UNIQUE ("name"), CONSTRAINT "PK_af7ba6a46bf69a7b10c425f0367" PRIMARY KEY ("id"))`,
);
await queryRunner.query(
`CREATE INDEX "IDX_cbedb9f42a98a82d91422e7fed" ON "e_role_backend" ("name") `,
);
await queryRunner.query(
`CREATE TABLE "e_sys_preference_backend" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "key" character varying NOT NULL, "value" character varying NOT NULL, CONSTRAINT "UQ_b04e47c4814fb6e315c5879fa75" UNIQUE ("key"), CONSTRAINT "PK_b79f051e19b46e74cf255e9ba3b" PRIMARY KEY ("id"))`,
);
await queryRunner.query(
`CREATE INDEX "IDX_b04e47c4814fb6e315c5879fa7" ON "e_sys_preference_backend" ("key") `,
);
await queryRunner.query(
`CREATE TABLE "e_user_backend" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "username" character varying NOT NULL, "roles" text array NOT NULL, "hashed_password" character varying NOT NULL, CONSTRAINT "UQ_ae538430fd08b28f4ab297eff09" UNIQUE ("username"), CONSTRAINT "PK_0b9d256d52e55a48d32e8b64d96" PRIMARY KEY ("id"))`,
);
await queryRunner.query(
`CREATE INDEX "IDX_ae538430fd08b28f4ab297eff0" ON "e_user_backend" ("username") `,
);
await queryRunner.query(
`CREATE TABLE "e_usr_preference_backend" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "key" character varying NOT NULL, "value" character varying NOT NULL, "user_id" character varying NOT NULL, CONSTRAINT "UQ_576678406a479d569123a33e132" UNIQUE ("key", "user_id"), CONSTRAINT "PK_8f8251016cd9283e7eb04c5498b" PRIMARY KEY ("id"))`,
);
await queryRunner.query(
`CREATE INDEX "IDX_673fe530e2484ff7e31ac81099" ON "e_usr_preference_backend" ("key") `,
);
await queryRunner.query(
`CREATE INDEX "IDX_f1a427e855045fa793c275861a" ON "e_usr_preference_backend" ("user_id") `,
);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`DROP INDEX "public"."IDX_f1a427e855045fa793c275861a"`,
);
await queryRunner.query(
`DROP INDEX "public"."IDX_673fe530e2484ff7e31ac81099"`,
);
await queryRunner.query(`DROP TABLE "e_usr_preference_backend"`);
await queryRunner.query(
`DROP INDEX "public"."IDX_ae538430fd08b28f4ab297eff0"`,
);
await queryRunner.query(`DROP TABLE "e_user_backend"`);
await queryRunner.query(
`DROP INDEX "public"."IDX_b04e47c4814fb6e315c5879fa7"`,
);
await queryRunner.query(`DROP TABLE "e_sys_preference_backend"`);
await queryRunner.query(
`DROP INDEX "public"."IDX_cbedb9f42a98a82d91422e7fed"`,
);
await queryRunner.query(`DROP TABLE "e_role_backend"`);
await queryRunner.query(`DROP TABLE "e_image_backend"`);
await queryRunner.query(
`DROP INDEX "public"."IDX_d0500b00b0b4109b623f897c2d"`,
);
await queryRunner.query(
`DROP INDEX "public"."IDX_8055f37d3b9f52f421b94ee84d"`,
);
await queryRunner.query(`DROP TABLE "e_image_file_backend"`);
await queryRunner.query(
`DROP INDEX "public"."IDX_7dc534a666f442383341896062"`,
);
await queryRunner.query(
`DROP INDEX "public"."IDX_37055605f39b3f8847232d604f"`,
);
await queryRunner.query(`DROP TABLE "e_image_derivative_backend"`);
}
}
Loading

0 comments on commit 422b4a7

Please sign in to comment.