Set TypeScript to strict mode and fix issues related to server types (#261)

* Fix lint issues and some other TS issues

- set TypeScript in strict mode
- add npm commands to lint / check code
- fix all lint issues
- fix some TS issues
- rename User reponse DTO to make it consistent with the other ones
- override Express/User interface to use UserResponseDto interface
 This is for when the accessing the `user` from a Express Request,
 like in `asset-upload-config`

* Fix the rest of TS issues

- fix all the remaining TypeScript errors
- add missing `@types/mapbox__mapbox-sdk` package

* Move global.d.ts to server `src` folder

* Update AssetReponseDto duration type

This is now of type `string` that defaults to '0:00:00.00000' if not set
which is what the mobile app currently expects

* Set context when logging error in asset.service

Use `ServeFile` as the context for logging an error when
asset.resizePath is not set

* Fix wrong AppController merge conflict resolution

`redirectToWebpage` was removed in main as is no longer used.
This commit is contained in:
Jaime Baez 2022-06-25 19:53:06 +02:00 committed by GitHub
parent cca2f7d178
commit c918f5b001
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
64 changed files with 415 additions and 273 deletions

View file

@ -5,23 +5,23 @@ import { UserAlbumEntity } from './user-album.entity';
@Entity('albums')
export class AlbumEntity {
@PrimaryGeneratedColumn('uuid')
id: string;
id!: string;
@Column()
ownerId: string;
ownerId!: string;
@Column({ default: 'Untitled Album' })
albumName: string;
albumName!: string;
@CreateDateColumn({ type: 'timestamptz' })
createdAt: string;
createdAt!: string;
@Column({ comment: 'Asset ID to be used as thumbnail', nullable: true })
albumThumbnailAssetId: string;
@Column({ comment: 'Asset ID to be used as thumbnail', type: 'varchar', nullable: true})
albumThumbnailAssetId!: string | null;
@OneToMany(() => UserAlbumEntity, (userAlbums) => userAlbums.albumInfo)
sharedUsers: UserAlbumEntity[];
sharedUsers?: UserAlbumEntity[];
@OneToMany(() => AssetAlbumEntity, (assetAlbumEntity) => assetAlbumEntity.albumInfo)
assets: AssetAlbumEntity[];
assets?: AssetAlbumEntity[];
}

View file

@ -6,25 +6,25 @@ import { AssetEntity } from './asset.entity';
@Unique('PK_unique_asset_in_album', ['albumId', 'assetId'])
export class AssetAlbumEntity {
@PrimaryGeneratedColumn()
id: string;
id!: string;
@Column()
albumId: string;
albumId!: string;
@Column()
assetId: string;
assetId!: string;
@ManyToOne(() => AlbumEntity, (album) => album.assets, {
onDelete: 'CASCADE',
nullable: true,
})
@JoinColumn({ name: 'albumId' })
albumInfo: AlbumEntity;
albumInfo!: AlbumEntity;
@ManyToOne(() => AssetEntity, {
onDelete: 'CASCADE',
nullable: true,
})
@JoinColumn({ name: 'assetId' })
assetInfo: AssetEntity;
assetInfo!: AssetEntity;
}

View file

@ -1,4 +1,4 @@
import { Column, Entity, JoinColumn, OneToOne, PrimaryColumn, PrimaryGeneratedColumn, Unique } from 'typeorm';
import { Column, Entity, OneToOne, PrimaryGeneratedColumn, Unique } from 'typeorm';
import { ExifEntity } from './exif.entity';
import { SmartInfoEntity } from './smart-info.entity';
@ -6,52 +6,52 @@ import { SmartInfoEntity } from './smart-info.entity';
@Unique(['deviceAssetId', 'userId', 'deviceId'])
export class AssetEntity {
@PrimaryGeneratedColumn('uuid')
id: string;
id!: string;
@Column()
deviceAssetId: string;
deviceAssetId!: string;
@Column()
userId: string;
userId!: string;
@Column()
deviceId: string;
deviceId!: string;
@Column()
type: AssetType;
type!: AssetType;
@Column()
originalPath: string;
originalPath!: string;
@Column({ nullable: true })
resizePath: string;
@Column({ type: 'varchar', nullable: true })
resizePath!: string | null;
@Column({ nullable: true })
webpPath: string;
@Column({ type: 'varchar', nullable: true })
webpPath!: string | null;
@Column({ nullable: true })
encodedVideoPath: string;
@Column({ type: 'varchar', nullable: true })
encodedVideoPath!: string;
@Column()
createdAt: string;
createdAt!: string;
@Column()
modifiedAt: string;
modifiedAt!: string;
@Column({ type: 'boolean', default: false })
isFavorite: boolean;
isFavorite!: boolean;
@Column({ nullable: true })
mimeType: string;
@Column({ type: 'varchar', nullable: true })
mimeType!: string | null;
@Column({ nullable: true })
duration: string;
@Column({ type: 'varchar', nullable: true })
duration!: string | null;
@OneToOne(() => ExifEntity, (exifEntity) => exifEntity.asset)
exifInfo: ExifEntity;
exifInfo?: ExifEntity;
@OneToOne(() => SmartInfoEntity, (smartInfoEntity) => smartInfoEntity.asset)
smartInfo: SmartInfoEntity;
smartInfo?: SmartInfoEntity;
}
export enum AssetType {

View file

@ -4,25 +4,25 @@ import { Column, CreateDateColumn, Entity, PrimaryGeneratedColumn, Unique } from
@Unique(['userId', 'deviceId'])
export class DeviceInfoEntity {
@PrimaryGeneratedColumn()
id: number;
id!: number;
@Column()
userId: string;
userId!: string;
@Column()
deviceId: string;
deviceId!: string;
@Column()
deviceType: DeviceType;
deviceType!: DeviceType;
@Column({ nullable: true })
notificationToken: string;
@Column({ type: 'varchar', nullable: true })
notificationToken!: string | null;
@CreateDateColumn()
createdAt: string;
createdAt!: string;
@Column({ type: 'bool', default: false })
isAutoBackup: boolean;
isAutoBackup!: boolean;
}
export enum DeviceType {

View file

@ -7,70 +7,70 @@ import { AssetEntity } from './asset.entity';
@Entity('exif')
export class ExifEntity {
@PrimaryGeneratedColumn()
id: string;
id!: string;
@Index({ unique: true })
@Column({ type: 'uuid' })
assetId: string;
assetId!: string;
@Column({ nullable: true })
make: string;
@Column({ type: 'varchar', nullable: true })
make!: string | null;
@Column({ nullable: true })
model: string;
@Column({ type: 'varchar', nullable: true })
model!: string | null;
@Column({ nullable: true })
imageName: string;
@Column({ type: 'varchar', nullable: true })
imageName!: string | null;
@Column({ nullable: true })
exifImageWidth: number;
@Column({ type: 'integer', nullable: true })
exifImageWidth!: number | null;
@Column({ nullable: true })
exifImageHeight: number;
@Column({ type: 'integer', nullable: true })
exifImageHeight!: number | null;
@Column({ nullable: true })
fileSizeInByte: number;
@Column({ type: 'integer', nullable: true })
fileSizeInByte!: number | null;
@Column({ nullable: true })
orientation: string;
@Column({ type: 'varchar', nullable: true })
orientation!: string | null;
@Column({ type: 'timestamptz', nullable: true })
dateTimeOriginal: Date;
dateTimeOriginal!: Date | null;
@Column({ type: 'timestamptz', nullable: true })
modifyDate: Date;
modifyDate!: Date | null;
@Column({ nullable: true })
lensModel: string;
@Column({ type: 'varchar', nullable: true })
lensModel!: string | null;
@Column({ type: 'float8', nullable: true })
fNumber: number;
fNumber!: number | null;
@Column({ type: 'float8', nullable: true })
focalLength: number;
focalLength!: number | null;
@Column({ nullable: true })
iso: number;
@Column({ type: 'integer', nullable: true })
iso!: number | null;
@Column({ type: 'float', nullable: true })
exposureTime: number;
exposureTime!: number | null;
@Column({ type: 'float', nullable: true })
latitude: number;
latitude!: number | null;
@Column({ type: 'float', nullable: true })
longitude: number;
longitude!: number | null;
@Column({ nullable: true })
city: string;
@Column({ type: 'varchar', nullable: true })
city!: string | null;
@Column({ nullable: true })
state: string;
@Column({ type: 'varchar', nullable: true })
state!: string | null;
@Column({ nullable: true })
country: string;
@Column({ type: 'varchar', nullable: true })
country!: string | null;
@OneToOne(() => AssetEntity, { onDelete: 'CASCADE', nullable: true })
@JoinColumn({ name: 'assetId', referencedColumnName: 'id' })
asset: ExifEntity;
asset?: ExifEntity;
}

View file

@ -4,19 +4,19 @@ import { AssetEntity } from './asset.entity';
@Entity('smart_info')
export class SmartInfoEntity {
@PrimaryGeneratedColumn()
id: string;
id!: string;
@Index({ unique: true })
@Column({ type: 'uuid' })
assetId: string;
assetId!: string;
@Column({ type: 'text', array: true, nullable: true })
tags: string[];
tags!: string[] | null;
@Column({ type: 'text', array: true, nullable: true })
objects: string[];
objects!: string[] | null;
@OneToOne(() => AssetEntity, { onDelete: 'CASCADE', nullable: true })
@JoinColumn({ name: 'assetId', referencedColumnName: 'id' })
asset: SmartInfoEntity;
asset?: SmartInfoEntity;
}

View file

@ -6,22 +6,22 @@ import { AlbumEntity } from './album.entity';
@Unique('PK_unique_user_in_album', ['albumId', 'sharedUserId'])
export class UserAlbumEntity {
@PrimaryGeneratedColumn()
id: string;
id!: string;
@Column()
albumId: string;
albumId!: string;
@Column()
sharedUserId: string;
sharedUserId!: string;
@ManyToOne(() => AlbumEntity, (album) => album.sharedUsers, {
onDelete: 'CASCADE',
nullable: true,
})
@JoinColumn({ name: 'albumId' })
albumInfo: AlbumEntity;
albumInfo!: AlbumEntity;
@ManyToOne(() => UserEntity)
@JoinColumn({ name: 'sharedUserId' })
userInfo: UserEntity;
userInfo!: UserEntity;
}

View file

@ -3,32 +3,32 @@ import { Column, CreateDateColumn, Entity, PrimaryGeneratedColumn } from 'typeor
@Entity('users')
export class UserEntity {
@PrimaryGeneratedColumn('uuid')
id: string;
id!: string;
@Column()
firstName: string;
firstName!: string;
@Column()
lastName: string;
lastName!: string;
@Column()
isAdmin: boolean;
isAdmin!: boolean;
@Column()
email: string;
email!: string;
@Column({ select: false })
password: string;
password?: string;
@Column({ select: false })
salt: string;
salt?: string;
@Column()
profileImagePath: string;
profileImagePath!: string;
@Column()
isFirstLoggedIn: boolean;
isFirstLoggedIn!: boolean;
@CreateDateColumn()
createdAt: string;
createdAt!: string;
}