1
0
Fork 0
mirror of https://github.com/immich-app/immich.git synced 2024-12-29 15:11:58 +00:00

refactor(server): flatten infra folders (#2120)

* refactor: flatten infra folders

* fix: database migrations

* fix: test related import

* fix: github actions workflow

* chore: rename schemas to typesense-schemas
This commit is contained in:
Jason Rasmussen 2023-03-30 15:38:55 -04:00 committed by GitHub
parent 468e620372
commit 34d300d1da
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
176 changed files with 185 additions and 176 deletions

View file

@ -110,13 +110,13 @@ jobs:
continue-on-error: true
run: |
cd server
npm run typeorm:migrations:generate ./libs/infra/src/db/migrations/TestMigration
npm run typeorm:migrations:generate ./libs/infra/src/migrations/TestMigration
- name: Find file changes
uses: tj-actions/verify-changed-files@v13.1
id: verify-changed-files
with:
files: |
server/libs/infra/src/db/migrations/
server/libs/infra/src/migrations/
- name: Verify files have not changed
if: steps.verify-changed-files.outputs.files_changed == 'true'
run: |

View file

@ -1,5 +1,5 @@
import { AlbumEntity, AssetEntity, UserEntity } from '@app/infra/db/entities';
import { dataSource } from '@app/infra/db/config';
import { AlbumEntity, AssetEntity, UserEntity } from '@app/infra/entities';
import { dataSource } from '@app/infra/database.config';
import { Injectable } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { Repository } from 'typeorm';

View file

@ -2,7 +2,7 @@ import { Module } from '@nestjs/common';
import { AlbumService } from './album.service';
import { AlbumController } from './album.controller';
import { TypeOrmModule } from '@nestjs/typeorm';
import { AlbumEntity, AssetEntity } from '@app/infra/db/entities';
import { AlbumEntity, AssetEntity } from '@app/infra/entities';
import { AlbumRepository, IAlbumRepository } from './album-repository';
import { DownloadModule } from '../../modules/download/download.module';

View file

@ -1,7 +1,7 @@
import { AlbumService } from './album.service';
import { AuthUserDto } from '../../decorators/auth-user.decorator';
import { BadRequestException, NotFoundException, ForbiddenException } from '@nestjs/common';
import { AlbumEntity, UserEntity } from '@app/infra/db/entities';
import { AlbumEntity, UserEntity } from '@app/infra/entities';
import { AlbumResponseDto, ICryptoRepository, IJobRepository, JobName, mapUser } from '@app/domain';
import { AddAssetsResponseDto } from './response-dto/add-assets-response.dto';
import { IAlbumRepository } from './album-repository';

View file

@ -1,7 +1,7 @@
import { BadRequestException, Inject, Injectable, NotFoundException, ForbiddenException, Logger } from '@nestjs/common';
import { AuthUserDto } from '../../decorators/auth-user.decorator';
import { CreateAlbumDto } from './dto/create-album.dto';
import { AlbumEntity, SharedLinkType } from '@app/infra/db/entities';
import { AlbumEntity, SharedLinkType } from '@app/infra/entities';
import { AddUsersDto } from './dto/add-users.dto';
import { RemoveAssetsDto } from './dto/remove-assets.dto';
import { UpdateAlbumDto } from './dto/update-album.dto';

View file

@ -1,6 +1,6 @@
import { SearchPropertiesDto } from './dto/search-properties.dto';
import { CuratedLocationsResponseDto } from './response-dto/curated-locations-response.dto';
import { AssetEntity, AssetType } from '@app/infra/db/entities';
import { AssetEntity, AssetType } from '@app/infra/entities';
import { Inject, Injectable } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { Repository } from 'typeorm/repository/Repository';

View file

@ -1,5 +1,5 @@
import { AuthUserDto, IJobRepository, JobName } from '@app/domain';
import { AssetEntity, UserEntity } from '@app/infra/db/entities';
import { AssetEntity, UserEntity } from '@app/infra/entities';
import { IAssetRepository } from './asset-repository';
import { CreateAssetDto, UploadFile } from './dto/create-asset.dto';

View file

@ -2,7 +2,7 @@ import { Module } from '@nestjs/common';
import { AssetService } from './asset.service';
import { AssetController } from './asset.controller';
import { TypeOrmModule } from '@nestjs/typeorm';
import { AssetEntity } from '@app/infra/db/entities';
import { AssetEntity } from '@app/infra/entities';
import { AssetRepository, IAssetRepository } from './asset-repository';
import { DownloadModule } from '../../modules/download/download.module';
import { TagModule } from '../tag/tag.module';

View file

@ -1,7 +1,7 @@
import { IAssetRepository } from './asset-repository';
import { AssetService } from './asset.service';
import { QueryFailedError, Repository } from 'typeorm';
import { AssetEntity, AssetType } from '@app/infra/db/entities';
import { AssetEntity, AssetType } from '@app/infra/entities';
import { CreateAssetDto } from './dto/create-asset.dto';
import { AssetCountByTimeBucket } from './response-dto/asset-count-by-time-group-response.dto';
import { TimeGroupEnum } from './dto/get-asset-count-by-time-bucket.dto';

View file

@ -12,7 +12,7 @@ import {
import { InjectRepository } from '@nestjs/typeorm';
import { QueryFailedError, Repository } from 'typeorm';
import { AuthUserDto } from '../../decorators/auth-user.decorator';
import { AssetEntity, AssetType, SharedLinkType } from '@app/infra/db/entities';
import { AssetEntity, AssetType, SharedLinkType } from '@app/infra/entities';
import { constants, createReadStream, stat } from 'fs';
import { ServeFileDto } from './dto/serve-file.dto';
import { Response as Res } from 'express';

View file

@ -1,4 +1,4 @@
import { AssetType } from '@app/infra/db/entities';
import { AssetType } from '@app/infra/entities';
import { ApiProperty } from '@nestjs/swagger';
import { IsBoolean, IsEnum, IsNotEmpty, IsOptional } from 'class-validator';
import { ImmichFile } from '../../../config/asset-upload.config';

View file

@ -1,4 +1,4 @@
import { TagType } from '@app/infra/db/entities';
import { TagType } from '@app/infra/entities';
import { ApiProperty } from '@nestjs/swagger';
import { IsEnum, IsNotEmpty, IsString } from 'class-validator';

View file

@ -1,7 +1,7 @@
import { Module } from '@nestjs/common';
import { TagService } from './tag.service';
import { TagController } from './tag.controller';
import { TagEntity } from '@app/infra/db/entities';
import { TagEntity } from '@app/infra/entities';
import { TypeOrmModule } from '@nestjs/typeorm';
import { TagRepository, ITagRepository } from './tag.repository';

View file

@ -1,4 +1,4 @@
import { TagEntity, TagType } from '@app/infra/db/entities';
import { TagEntity, TagType } from '@app/infra/entities';
import { Injectable } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { In, Repository } from 'typeorm';

View file

@ -1,4 +1,4 @@
import { TagEntity, TagType, UserEntity } from '@app/infra/db/entities';
import { TagEntity, TagType, UserEntity } from '@app/infra/entities';
import { AuthUserDto } from '../../decorators/auth-user.decorator';
import { ITagRepository } from './tag.repository';
import { TagService } from './tag.service';

View file

@ -1,4 +1,4 @@
import { TagEntity } from '@app/infra/db/entities';
import { TagEntity } from '@app/infra/entities';
import { BadRequestException, Inject, Injectable, Logger } from '@nestjs/common';
import { AuthUserDto } from '../../decorators/auth-user.decorator';
import { CreateTagDto } from './dto/create-tag.dto';

View file

@ -1,4 +1,4 @@
import { AssetEntity } from '@app/infra/db/entities';
import { AssetEntity } from '@app/infra/entities';
import { BadRequestException, Injectable, InternalServerErrorException, Logger, StreamableFile } from '@nestjs/common';
import archiver from 'archiver';
import { extname } from 'path';

View file

@ -1,6 +1,6 @@
import { DomainModule } from '@app/domain';
import { InfraModule } from '@app/infra';
import { ExifEntity } from '@app/infra/db/entities';
import { ExifEntity } from '@app/infra/entities';
import { Module } from '@nestjs/common';
import { TypeOrmModule } from '@nestjs/typeorm';
import {

View file

@ -10,7 +10,7 @@ import {
QueueName,
WithoutProperty,
} from '@app/domain';
import { AssetType, ExifEntity } from '@app/infra/db/entities';
import { AssetType, ExifEntity } from '@app/infra/entities';
import { Process, Processor } from '@nestjs/bull';
import { Inject, Logger } from '@nestjs/common';
import { ConfigService } from '@nestjs/config';

View file

@ -12,7 +12,7 @@ import {
SystemConfigService,
WithoutProperty,
} from '@app/domain';
import { AssetEntity, AssetType, TranscodePreset } from '@app/infra/db/entities';
import { AssetEntity, AssetType, TranscodePreset } from '@app/infra/entities';
import { Process, Processor } from '@nestjs/bull';
import { Inject, Logger } from '@nestjs/common';
import { Job } from 'bull';

View file

@ -1,4 +1,4 @@
import { AlbumEntity } from '@app/infra/db/entities';
import { AlbumEntity } from '@app/infra/entities';
export const IAlbumRepository = 'IAlbumRepository';

View file

@ -1,4 +1,4 @@
import { AlbumEntity } from '@app/infra/db/entities';
import { AlbumEntity } from '@app/infra/entities';
import { Inject, Injectable } from '@nestjs/common';
import { IAssetRepository } from '../asset';
import { AuthUserDto } from '../auth';

View file

@ -1,4 +1,4 @@
import { AlbumEntity } from '@app/infra/db/entities';
import { AlbumEntity } from '@app/infra/entities';
import { ApiProperty } from '@nestjs/swagger';
import { AssetResponseDto, mapAsset } from '../../asset';
import { mapUser, UserResponseDto } from '../../user';

View file

@ -1,4 +1,4 @@
import { APIKeyEntity } from '@app/infra/db/entities';
import { APIKeyEntity } from '@app/infra/entities';
export const IKeyRepository = 'IKeyRepository';

View file

@ -1,4 +1,4 @@
import { APIKeyEntity } from '@app/infra/db/entities';
import { APIKeyEntity } from '@app/infra/entities';
export class APIKeyResponseDto {
id!: string;

View file

@ -1,4 +1,4 @@
import { AssetEntity, AssetType } from '@app/infra/db/entities';
import { AssetEntity, AssetType } from '@app/infra/entities';
import { IJobRepository, JobName } from '../job';
import { AssetSearchOptions, IAssetRepository } from './asset.repository';

View file

@ -1,4 +1,4 @@
import { AssetEntity, AssetType } from '@app/infra/db/entities';
import { AssetEntity, AssetType } from '@app/infra/entities';
export interface AssetSearchOptions {
isVisible?: boolean;

View file

@ -1,4 +1,4 @@
import { AssetEntity, AssetType } from '@app/infra/db/entities';
import { AssetEntity, AssetType } from '@app/infra/entities';
import { assetEntityStub, newAssetRepositoryMock, newJobRepositoryMock } from '../../test';
import { AssetService, IAssetRepository } from '../asset';
import { IJobRepository, JobName } from '../job';

View file

@ -1,4 +1,4 @@
import { AssetEntity, AssetType } from '@app/infra/db/entities';
import { AssetEntity, AssetType } from '@app/infra/entities';
import { Inject } from '@nestjs/common';
import { IAssetUploadedJob, IJobRepository, JobName } from '../job';
import { AssetCore } from './asset.core';

View file

@ -1,4 +1,4 @@
import { AssetEntity, AssetType } from '@app/infra/db/entities';
import { AssetEntity, AssetType } from '@app/infra/entities';
import { ApiProperty } from '@nestjs/swagger';
import { mapTag, TagResponseDto } from '../../tag';
import { ExifResponseDto, mapExif } from './exif-response.dto';

View file

@ -1,4 +1,4 @@
import { ExifEntity } from '@app/infra/db/entities';
import { ExifEntity } from '@app/infra/entities';
import { ApiProperty } from '@nestjs/swagger';
export class ExifResponseDto {

View file

@ -1,4 +1,4 @@
import { SmartInfoEntity } from '@app/infra/db/entities';
import { SmartInfoEntity } from '@app/infra/entities';
export class SmartInfoResponseDto {
tags?: string[] | null;

View file

@ -1,4 +1,4 @@
import { SystemConfig, UserEntity } from '@app/infra/db/entities';
import { SystemConfig, UserEntity } from '@app/infra/entities';
import { ISystemConfigRepository } from '../system-config';
import { SystemConfigCore } from '../system-config/system-config.core';
import { AuthType, IMMICH_ACCESS_COOKIE, IMMICH_AUTH_TYPE_COOKIE } from './auth.constant';

View file

@ -1,4 +1,4 @@
import { SystemConfig, UserEntity } from '@app/infra/db/entities';
import { SystemConfig, UserEntity } from '@app/infra/entities';
import { BadRequestException, UnauthorizedException } from '@nestjs/common';
import { IncomingHttpHeaders } from 'http';
import { generators, Issuer } from 'openid-client';

View file

@ -1,4 +1,4 @@
import { SystemConfig } from '@app/infra/db/entities';
import { SystemConfig } from '@app/infra/entities';
import {
BadRequestException,
Inject,

View file

@ -1,4 +1,4 @@
import { UserEntity } from '@app/infra/db/entities';
import { UserEntity } from '@app/infra/entities';
export class AdminSignupResponseDto {
id!: string;

View file

@ -1,4 +1,4 @@
import { UserEntity } from '@app/infra/db/entities';
import { UserEntity } from '@app/infra/entities';
import { ApiResponseProperty } from '@nestjs/swagger';
export class LoginResponseDto {

View file

@ -1,4 +1,4 @@
import { DeviceInfoEntity } from '@app/infra/db/entities';
import { DeviceInfoEntity } from '@app/infra/entities';
import { IDeviceInfoRepository } from './device-info.repository';
type UpsertKeys = Pick<DeviceInfoEntity, 'deviceId' | 'userId'>;

View file

@ -1,4 +1,4 @@
import { DeviceInfoEntity } from '@app/infra/db/entities';
import { DeviceInfoEntity } from '@app/infra/entities';
export const IDeviceInfoRepository = 'IDeviceInfoRepository';

View file

@ -1,4 +1,4 @@
import { DeviceInfoEntity, DeviceType } from '@app/infra/db/entities';
import { DeviceInfoEntity, DeviceType } from '@app/infra/entities';
import { authStub, newDeviceInfoRepositoryMock } from '../../test';
import { IDeviceInfoRepository } from './device-info.repository';
import { DeviceInfoService } from './device-info.service';

View file

@ -1,5 +1,5 @@
import { IsNotEmpty, IsOptional } from 'class-validator';
import { DeviceType } from '@app/infra/db/entities';
import { DeviceType } from '@app/infra/entities';
import { ApiProperty } from '@nestjs/swagger';
export class UpsertDeviceInfoDto {

View file

@ -1,4 +1,4 @@
import { DeviceInfoEntity, DeviceType } from '@app/infra/db/entities';
import { DeviceInfoEntity, DeviceType } from '@app/infra/entities';
import { ApiProperty } from '@nestjs/swagger';
export class DeviceInfoResponseDto {

View file

@ -1,4 +1,4 @@
import { AlbumEntity, AssetEntity, UserEntity } from '@app/infra/db/entities';
import { AlbumEntity, AssetEntity, UserEntity } from '@app/infra/entities';
export interface IBaseJob {
force?: boolean;

View file

@ -1,4 +1,4 @@
import { AssetType } from '@app/infra/db/entities';
import { AssetType } from '@app/infra/entities';
import { Inject, Injectable, Logger } from '@nestjs/common';
import { join } from 'path';
import { IAssetRepository, mapAsset, WithoutProperty } from '../asset';

View file

@ -1,4 +1,4 @@
import { SystemConfig } from '@app/infra/db/entities';
import { SystemConfig } from '@app/infra/entities';
import { BadRequestException, Injectable, Logger } from '@nestjs/common';
import { ClientMetadata, custom, generators, Issuer, UserinfoResponse } from 'openid-client';
import { ISystemConfigRepository } from '../system-config';

View file

@ -1,4 +1,4 @@
import { SystemConfig, UserEntity } from '@app/infra/db/entities';
import { SystemConfig, UserEntity } from '@app/infra/entities';
import { BadRequestException } from '@nestjs/common';
import { generators, Issuer } from 'openid-client';
import {

View file

@ -1,4 +1,4 @@
import { SystemConfig } from '@app/infra/db/entities';
import { SystemConfig } from '@app/infra/entities';
import { BadRequestException, Inject, Injectable, Logger } from '@nestjs/common';
import { AuthType, AuthUserDto, LoginResponseDto } from '../auth';
import { AuthCore } from '../auth/auth.core';

View file

@ -1,4 +1,4 @@
import { AssetType } from '@app/infra/db/entities';
import { AssetType } from '@app/infra/entities';
import { Transform } from 'class-transformer';
import { IsArray, IsBoolean, IsEnum, IsNotEmpty, IsOptional, IsString } from 'class-validator';
import { toBoolean } from '../../../../../apps/immich/src/utils/transform.util';

View file

@ -1,4 +1,4 @@
import { AlbumEntity, AssetEntity, AssetType } from '@app/infra/db/entities';
import { AlbumEntity, AssetEntity, AssetType } from '@app/infra/entities';
export enum SearchCollection {
ASSETS = 'assets',

View file

@ -1,4 +1,4 @@
import { AlbumEntity, AssetEntity } from '@app/infra/db/entities';
import { AlbumEntity, AssetEntity } from '@app/infra/entities';
import { BadRequestException, Inject, Injectable, Logger } from '@nestjs/common';
import { ConfigService } from '@nestjs/config';
import { mapAlbum } from '../album';

View file

@ -1,4 +1,4 @@
import { AlbumEntity, AssetEntity, SharedLinkType } from '@app/infra/db/entities';
import { AlbumEntity, AssetEntity, SharedLinkType } from '@app/infra/entities';
export class CreateSharedLinkDto {
description?: string;

View file

@ -1,4 +1,4 @@
import { SharedLinkEntity, SharedLinkType } from '@app/infra/db/entities';
import { SharedLinkEntity, SharedLinkType } from '@app/infra/entities';
import { ApiProperty } from '@nestjs/swagger';
import _ from 'lodash';
import { AlbumResponseDto, mapAlbumExcludeAssetInfo } from '../../album';

View file

@ -1,4 +1,4 @@
import { AssetEntity, SharedLinkEntity } from '@app/infra/db/entities';
import { AssetEntity, SharedLinkEntity } from '@app/infra/entities';
import {
BadRequestException,
ForbiddenException,

View file

@ -1,4 +1,4 @@
import { SharedLinkEntity } from '@app/infra/db/entities';
import { SharedLinkEntity } from '@app/infra/entities';
export const ISharedLinkRepository = 'ISharedLinkRepository';

View file

@ -1,4 +1,4 @@
import { SmartInfoEntity } from '@app/infra/db/entities';
import { SmartInfoEntity } from '@app/infra/entities';
export const ISmartInfoRepository = 'ISmartInfoRepository';

View file

@ -1,4 +1,4 @@
import { AssetEntity } from '@app/infra/db/entities';
import { AssetEntity } from '@app/infra/entities';
import {
assetEntityStub,
newAssetRepositoryMock,

View file

@ -1,4 +1,4 @@
import { AssetEntity, AssetType, SystemConfig } from '@app/infra/db/entities';
import { AssetEntity, AssetType, SystemConfig } from '@app/infra/entities';
import { Logger } from '@nestjs/common';
import handlebar from 'handlebars';
import * as luxon from 'luxon';

View file

@ -1,4 +1,4 @@
import { AssetEntity, SystemConfig } from '@app/infra/db/entities';
import { AssetEntity, SystemConfig } from '@app/infra/entities';
import { Inject, Injectable, Logger } from '@nestjs/common';
import { IAssetRepository } from '../asset/asset.repository';
import { APP_MEDIA_LOCATION } from '../domain.constant';

View file

@ -1,5 +1,5 @@
import { IsEnum, IsString } from 'class-validator';
import { TranscodePreset } from '@app/infra/db/entities';
import { TranscodePreset } from '@app/infra/entities';
export class SystemConfigFFmpegDto {
@IsString()

View file

@ -1,4 +1,4 @@
import { SystemConfig } from '@app/infra/db/entities';
import { SystemConfig } from '@app/infra/entities';
import { ValidateNested } from 'class-validator';
import { SystemConfigFFmpegDto } from './system-config-ffmpeg.dto';
import { SystemConfigOAuthDto } from './system-config-oauth.dto';

View file

@ -1,4 +1,4 @@
import { SystemConfig, SystemConfigEntity, SystemConfigKey, TranscodePreset } from '@app/infra/db/entities';
import { SystemConfig, SystemConfigEntity, SystemConfigKey, TranscodePreset } from '@app/infra/entities';
import { BadRequestException, Injectable, Logger } from '@nestjs/common';
import * as _ from 'lodash';
import { Subject } from 'rxjs';

View file

@ -1,4 +1,4 @@
import { SystemConfigEntity } from '@app/infra/db/entities';
import { SystemConfigEntity } from '@app/infra/entities';
export const ISystemConfigRepository = 'ISystemConfigRepository';

View file

@ -1,4 +1,4 @@
import { SystemConfigEntity, SystemConfigKey, TranscodePreset } from '@app/infra/db/entities';
import { SystemConfigEntity, SystemConfigKey, TranscodePreset } from '@app/infra/entities';
import { BadRequestException } from '@nestjs/common';
import { newJobRepositoryMock, newSystemConfigRepositoryMock, systemConfigStub } from '../../test';
import { IJobRepository, JobName } from '../job';

View file

@ -1,4 +1,4 @@
import { TagEntity, TagType } from '@app/infra/db/entities';
import { TagEntity, TagType } from '@app/infra/entities';
import { ApiProperty } from '@nestjs/swagger';
export class TagResponseDto {

View file

@ -1,4 +1,4 @@
import { UserEntity } from '@app/infra/db/entities';
import { UserEntity } from '@app/infra/entities';
import { Injectable, UnauthorizedException } from '@nestjs/common';
import { ICryptoRepository } from '../crypto';
import { IUserTokenRepository } from './user-token.repository';

View file

@ -1,4 +1,4 @@
import { UserTokenEntity } from '@app/infra/db/entities';
import { UserTokenEntity } from '@app/infra/entities';
export const IUserTokenRepository = 'IUserTokenRepository';

View file

@ -1,4 +1,4 @@
import { UserEntity } from '@app/infra/db/entities';
import { UserEntity } from '@app/infra/entities';
export class UserResponseDto {
id!: string;

View file

@ -1,4 +1,4 @@
import { UserEntity } from '@app/infra/db/entities';
import { UserEntity } from '@app/infra/entities';
import {
BadRequestException,
ForbiddenException,

View file

@ -1,4 +1,4 @@
import { UserEntity } from '@app/infra/db/entities';
import { UserEntity } from '@app/infra/entities';
export interface UserListFilter {
excludeId?: string;

View file

@ -1,4 +1,4 @@
import { UserEntity } from '@app/infra/db/entities';
import { UserEntity } from '@app/infra/entities';
import { BadRequestException, ForbiddenException, NotFoundException } from '@nestjs/common';
import { when } from 'jest-when';
import {

View file

@ -1,4 +1,4 @@
import { UserEntity } from '@app/infra/db/entities';
import { UserEntity } from '@app/infra/entities';
import { BadRequestException, Inject, Injectable, Logger, NotFoundException } from '@nestjs/common';
import { randomBytes } from 'crypto';
import { ReadStream } from 'fs';

View file

@ -9,7 +9,7 @@ import {
TranscodePreset,
UserEntity,
UserTokenEntity,
} from '@app/infra/db/entities';
} from '@app/infra/entities';
import {
AlbumResponseDto,
AssetResponseDto,

View file

@ -1,2 +0,0 @@
export * from './communication.gateway';
export * from './communication.repository';

View file

@ -1,5 +1,5 @@
import { PostgresConnectionOptions } from 'typeorm/driver/postgres/PostgresConnectionOptions';
import { DataSource } from 'typeorm';
import { PostgresConnectionOptions } from 'typeorm/driver/postgres/PostgresConnectionOptions';
const url = process.env.DB_URL;
const urlOrParts = url
@ -14,12 +14,13 @@ const urlOrParts = url
export const databaseConfig: PostgresConnectionOptions = {
type: 'postgres',
entities: [__dirname + '/../**/*.entity.{js,ts}'],
entities: [__dirname + '/entities/*.entity.{js,ts}'],
synchronize: false,
migrations: [__dirname + '/../migrations/*.{js,ts}'],
migrations: [__dirname + '/migrations/*.{js,ts}'],
migrationsRun: true,
connectTimeoutMS: 10000, // 10 seconds
...urlOrParts,
};
// this export is used by TypeORM commands in package.json#scripts
export const dataSource = new DataSource(databaseConfig);

View file

@ -1 +0,0 @@
export * from './database.config';

View file

@ -1,11 +0,0 @@
export * from './album.entity';
export * from './api-key.entity';
export * from './asset.entity';
export * from './device-info.entity';
export * from './exif.entity';
export * from './smart-info.entity';
export * from './system-config.entity';
export * from './tag.entity';
export * from './user.entity';
export * from './user-token.entity';
export * from './shared-link.entity';

View file

@ -1,3 +0,0 @@
export * from './config';
export * from './entities';
export * from './repository';

View file

@ -0,0 +1,33 @@
import { AlbumEntity } from './album.entity';
import { APIKeyEntity } from './api-key.entity';
import { AssetEntity } from './asset.entity';
import { DeviceInfoEntity } from './device-info.entity';
import { SharedLinkEntity } from './shared-link.entity';
import { SmartInfoEntity } from './smart-info.entity';
import { SystemConfigEntity } from './system-config.entity';
import { UserTokenEntity } from './user-token.entity';
import { UserEntity } from './user.entity';
export * from './album.entity';
export * from './api-key.entity';
export * from './asset.entity';
export * from './device-info.entity';
export * from './exif.entity';
export * from './shared-link.entity';
export * from './smart-info.entity';
export * from './system-config.entity';
export * from './tag.entity';
export * from './user-token.entity';
export * from './user.entity';
export const databaseEntities = [
AssetEntity,
AlbumEntity,
APIKeyEntity,
DeviceInfoEntity,
UserEntity,
SharedLinkEntity,
SmartInfoEntity,
SystemConfigEntity,
UserTokenEntity,
];

View file

@ -1,2 +1,3 @@
export * from './db';
export * from './database.config';
export * from './infra.config';
export * from './infra.module';

View file

@ -0,0 +1,35 @@
import { BullModuleOptions } from '@nestjs/bull';
import { ConfigurationOptions } from 'typesense/lib/Typesense/Configuration';
import { QueueName } from '../../domain/src';
export const bullConfig: BullModuleOptions = {
prefix: 'immich_bull',
redis: {
host: process.env.REDIS_HOSTNAME || 'immich_redis',
port: parseInt(process.env.REDIS_PORT || '6379'),
db: parseInt(process.env.REDIS_DBINDEX || '0'),
password: process.env.REDIS_PASSWORD || undefined,
path: process.env.REDIS_SOCKET || undefined,
},
defaultJobOptions: {
attempts: 3,
removeOnComplete: true,
removeOnFail: false,
},
};
export const bullQueues: BullModuleOptions[] = Object.values(QueueName).map((name) => ({ name }));
export const typesenseConfig: ConfigurationOptions = {
nodes: [
{
host: process.env.TYPESENSE_HOST || 'typesense',
port: Number(process.env.TYPESENSE_PORT) || 8108,
protocol: process.env.TYPESENSE_PROTOCOL || 'http',
},
],
apiKey: process.env.TYPESENSE_API_KEY as string,
numRetries: 15,
retryIntervalSeconds: 4,
connectionTimeoutSeconds: 10,
};

View file

@ -16,40 +16,33 @@ import {
ISystemConfigRepository,
IUserRepository,
IUserTokenRepository,
QueueName,
} from '@app/domain';
import { BullModule } from '@nestjs/bull';
import { Global, Module, Provider } from '@nestjs/common';
import { ConfigModule } from '@nestjs/config';
import { TypeOrmModule } from '@nestjs/typeorm';
import { CryptoRepository } from './auth/crypto.repository';
import { CommunicationGateway, CommunicationRepository } from './communication';
import { CommunicationGateway } from './communication.gateway';
import { databaseConfig } from './database.config';
import { databaseEntities } from './entities';
import { bullConfig, bullQueues } from './infra.config';
import {
AlbumEntity,
AlbumRepository,
APIKeyEntity,
APIKeyRepository,
AssetEntity,
AssetRepository,
databaseConfig,
DeviceInfoEntity,
CommunicationRepository,
CryptoRepository,
DeviceInfoRepository,
SharedLinkEntity,
FilesystemProvider,
JobRepository,
MachineLearningRepository,
MediaRepository,
SharedLinkRepository,
SmartInfoEntity,
SmartInfoRepository,
SystemConfigEntity,
SystemConfigRepository,
UserEntity,
TypesenseRepository,
UserRepository,
UserTokenEntity,
UserTokenRepository,
} from './db';
import { JobRepository } from './job';
import { MachineLearningRepository } from './machine-learning';
import { MediaRepository } from './media';
import { TypesenseRepository } from './search';
import { FilesystemProvider } from './storage';
} from './repositories';
const providers: Provider[] = [
{ provide: IAlbumRepository, useClass: AlbumRepository },
@ -74,38 +67,10 @@ const providers: Provider[] = [
@Module({
imports: [
ConfigModule.forRoot(immichAppConfig),
TypeOrmModule.forRoot(databaseConfig),
TypeOrmModule.forFeature([
AssetEntity,
AlbumEntity,
APIKeyEntity,
DeviceInfoEntity,
UserEntity,
SharedLinkEntity,
SmartInfoEntity,
SystemConfigEntity,
UserTokenEntity,
]),
BullModule.forRootAsync({
useFactory: async () => ({
prefix: 'immich_bull',
redis: {
host: process.env.REDIS_HOSTNAME || 'immich_redis',
port: parseInt(process.env.REDIS_PORT || '6379'),
db: parseInt(process.env.REDIS_DBINDEX || '0'),
password: process.env.REDIS_PASSWORD || undefined,
path: process.env.REDIS_SOCKET || undefined,
},
defaultJobOptions: {
attempts: 3,
removeOnComplete: true,
removeOnFail: false,
},
}),
}),
BullModule.registerQueue(...Object.values(QueueName).map((name) => ({ name }))),
TypeOrmModule.forFeature(databaseEntities),
BullModule.forRoot(bullConfig),
BullModule.registerQueue(...bullQueues),
],
providers: [...providers, CommunicationGateway],
exports: [...providers, BullModule],

View file

@ -1 +0,0 @@
export * from './job.repository';

View file

@ -1 +0,0 @@
export * from './machine-learning.repository';

View file

@ -1 +0,0 @@
export * from './media.repository';

Some files were not shown because too many files have changed in this diff Show more