mirror of
https://github.com/immich-app/immich
synced 2025-11-07 17:27:20 +00:00
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:
parent
cca2f7d178
commit
c918f5b001
64 changed files with 415 additions and 273 deletions
|
|
@ -1,4 +1,4 @@
|
|||
import { InjectQueue, OnQueueActive, OnQueueCompleted, OnQueueWaiting, Process, Processor } from '@nestjs/bull';
|
||||
import { InjectQueue, Process, Processor } from '@nestjs/bull';
|
||||
import { Job, Queue } from 'bull';
|
||||
import { AssetEntity, AssetType } from '@app/database/entities/asset.entity';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
|
|
|
|||
|
|
@ -11,13 +11,12 @@ import { readFile } from 'fs/promises';
|
|||
import { Logger } from '@nestjs/common';
|
||||
import axios from 'axios';
|
||||
import { SmartInfoEntity } from '@app/database/entities/smart-info.entity';
|
||||
import { ConfigService } from '@nestjs/config';
|
||||
import ffmpeg from 'fluent-ffmpeg';
|
||||
// import moment from 'moment';
|
||||
|
||||
@Processor('metadata-extraction-queue')
|
||||
export class MetadataExtractionProcessor {
|
||||
private geocodingClient: GeocodeService;
|
||||
private geocodingClient?: GeocodeService;
|
||||
|
||||
constructor(
|
||||
@InjectRepository(AssetEntity)
|
||||
|
|
@ -29,7 +28,7 @@ export class MetadataExtractionProcessor {
|
|||
@InjectRepository(SmartInfoEntity)
|
||||
private smartInfoRepository: Repository<SmartInfoEntity>,
|
||||
) {
|
||||
if (process.env.ENABLE_MAPBOX == 'true') {
|
||||
if (process.env.ENABLE_MAPBOX == 'true' && process.env.MAPBOX_KEY) {
|
||||
this.geocodingClient = mapboxGeocoding({
|
||||
accessToken: process.env.MAPBOX_KEY,
|
||||
});
|
||||
|
|
@ -65,7 +64,7 @@ export class MetadataExtractionProcessor {
|
|||
newExif.longitude = exifData['longitude'] || null;
|
||||
|
||||
// Reverse GeoCoding
|
||||
if (process.env.ENABLE_MAPBOX && exifData['longitude'] && exifData['latitude']) {
|
||||
if (this.geocodingClient && exifData['longitude'] && exifData['latitude']) {
|
||||
const geoCodeInfo: MapiResponse = await this.geocodingClient
|
||||
.reverseGeocode({
|
||||
query: [exifData['longitude'], exifData['latitude']],
|
||||
|
|
@ -86,7 +85,7 @@ export class MetadataExtractionProcessor {
|
|||
|
||||
await this.exifRepository.save(newExif);
|
||||
} catch (e) {
|
||||
Logger.error(`Error extracting EXIF ${e.toString()}`, 'extractExif');
|
||||
Logger.error(`Error extracting EXIF ${String(e)}`, 'extractExif');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -128,7 +127,7 @@ export class MetadataExtractionProcessor {
|
|||
});
|
||||
}
|
||||
} catch (error) {
|
||||
Logger.error(`Failed to trigger object detection pipe line ${error.toString()}`);
|
||||
Logger.error(`Failed to trigger object detection pipe line ${String(error)}`);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ export class ThumbnailGeneratorProcessor {
|
|||
sharp(asset.originalPath)
|
||||
.resize(1440, 2560, { fit: 'inside' })
|
||||
.jpeg()
|
||||
.toFile(jpegThumbnailPath, async (err, info) => {
|
||||
.toFile(jpegThumbnailPath, async (err) => {
|
||||
if (!err) {
|
||||
await this.assetRepository.update({ id: asset.id }, { resizePath: jpegThumbnailPath });
|
||||
|
||||
|
|
@ -65,7 +65,7 @@ export class ThumbnailGeneratorProcessor {
|
|||
.on('start', () => {
|
||||
Logger.log('Start Generating Video Thumbnail', 'generateJPEGThumbnail');
|
||||
})
|
||||
.on('error', (error, b, c) => {
|
||||
.on('error', (error) => {
|
||||
Logger.error(`Cannot Generate Video Thumbnail ${error}`, 'generateJPEGThumbnail');
|
||||
// reject();
|
||||
})
|
||||
|
|
@ -87,15 +87,18 @@ export class ThumbnailGeneratorProcessor {
|
|||
}
|
||||
|
||||
@Process({ name: 'generate-webp-thumbnail', concurrency: 2 })
|
||||
async generateWepbThumbnail(job: Job) {
|
||||
const { asset }: { asset: AssetEntity } = job.data;
|
||||
async generateWepbThumbnail(job: Job<{ asset: AssetEntity }>) {
|
||||
const { asset } = job.data;
|
||||
|
||||
if (!asset.resizePath) {
|
||||
return;
|
||||
}
|
||||
const webpPath = asset.resizePath.replace('jpeg', 'webp');
|
||||
|
||||
sharp(asset.resizePath)
|
||||
.resize(250)
|
||||
.webp()
|
||||
.toFile(webpPath, (err, info) => {
|
||||
.toFile(webpPath, (err) => {
|
||||
if (!err) {
|
||||
this.assetRepository.update({ id: asset.id }, { webpPath: webpPath });
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ export class VideoTranscodeProcessor {
|
|||
.on('start', () => {
|
||||
Logger.log('Start Converting Video', 'mp4Conversion');
|
||||
})
|
||||
.on('error', (error, b, c) => {
|
||||
.on('error', (error) => {
|
||||
Logger.error(`Cannot Convert Video ${error}`, 'mp4Conversion');
|
||||
reject();
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue