mirror of
https://github.com/KevinMidboe/immich.git
synced 2026-05-02 11:38:18 +00:00
Transfer repository from Gitlab
This commit is contained in:
19
server/src/config/app.config.ts
Normal file
19
server/src/config/app.config.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import { ConfigModuleOptions } from '@nestjs/config';
|
||||
import Joi from 'joi';
|
||||
|
||||
export const immichAppConfig: ConfigModuleOptions = {
|
||||
envFilePath: '.env',
|
||||
isGlobal: true,
|
||||
validationSchema: Joi.object({
|
||||
NODE_ENV: Joi.string().required().valid('development', 'production', 'staging').default('development'),
|
||||
DB_HOST: Joi.string().required(),
|
||||
DB_USERNAME: Joi.string().required(),
|
||||
DB_PASSWORD: Joi.string().required(),
|
||||
DB_DATABASE: Joi.string().required(),
|
||||
UPLOAD_LOCATION: Joi.string().required(),
|
||||
JWT_SECRET: Joi.string().required(),
|
||||
REDIS_HOST: Joi.string().required(),
|
||||
REDIS_PORT: Joi.string().required(),
|
||||
REDIS_PASSWORD: Joi.string().required(),
|
||||
}),
|
||||
};
|
||||
27
server/src/config/database.config.ts
Normal file
27
server/src/config/database.config.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import { TypeOrmModuleOptions } from '@nestjs/typeorm';
|
||||
import dotenv from 'dotenv';
|
||||
|
||||
const result = dotenv.config();
|
||||
|
||||
if (result.error) {
|
||||
console.log(result.error);
|
||||
}
|
||||
|
||||
export const databaseConfig: TypeOrmModuleOptions = {
|
||||
type: 'postgres',
|
||||
host: process.env.DB_HOST,
|
||||
port: 5432,
|
||||
username: process.env.DB_USERNAME,
|
||||
password: process.env.DB_PASSWORD,
|
||||
database: process.env.DB_DATABASE,
|
||||
entities: [__dirname + '/../**/*.entity.{js,ts}'],
|
||||
synchronize: true,
|
||||
// logging: true,
|
||||
// logger: 'advanced-console',
|
||||
// ssl: process.env.NODE_ENV == 'production',
|
||||
// extra: {
|
||||
// ssl: {
|
||||
// rejectUnauthorized: false,
|
||||
// },
|
||||
// },
|
||||
};
|
||||
7
server/src/config/jwt.config.ts
Normal file
7
server/src/config/jwt.config.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
import { JwtModuleOptions } from '@nestjs/jwt';
|
||||
import { jwtSecret } from '../constants/jwt.constant';
|
||||
|
||||
export const jwtConfig: JwtModuleOptions = {
|
||||
secret: jwtSecret,
|
||||
signOptions: { expiresIn: '36500d' },
|
||||
};
|
||||
38
server/src/config/multer-option.config.ts
Normal file
38
server/src/config/multer-option.config.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
import { HttpException, HttpStatus } from '@nestjs/common';
|
||||
import { MulterOptions } from '@nestjs/platform-express/multer/interfaces/multer-options.interface';
|
||||
import { existsSync, mkdirSync } from 'fs';
|
||||
import { diskStorage } from 'multer';
|
||||
import { extname } from 'path';
|
||||
import { Request } from 'express';
|
||||
|
||||
export const multerConfig = {
|
||||
dest: process.env.UPLOAD_LOCATION,
|
||||
};
|
||||
|
||||
export const multerOption: MulterOptions = {
|
||||
fileFilter: (req: Request, file: any, cb: any) => {
|
||||
if (file.mimetype.match(/\/(jpg|jpeg|png|gif|mp4|x-msvideo|quicktime)$/)) {
|
||||
cb(null, true);
|
||||
} else {
|
||||
cb(new HttpException(`Unsupported file type ${extname(file.originalname)}`, HttpStatus.BAD_REQUEST), false);
|
||||
}
|
||||
},
|
||||
|
||||
storage: diskStorage({
|
||||
destination: (req: Request, file: Express.Multer.File, cb: any) => {
|
||||
const uploadPath = multerConfig.dest;
|
||||
|
||||
const userPath = `${uploadPath}/${req.user['id']}/original/${req.body['deviceId']}`;
|
||||
|
||||
if (!existsSync(userPath)) {
|
||||
mkdirSync(userPath, { recursive: true });
|
||||
}
|
||||
|
||||
cb(null, userPath);
|
||||
},
|
||||
|
||||
filename: (req: Request, file: Express.Multer.File, cb: any) => {
|
||||
cb(null, `${file.originalname}${req.body['fileExtension']}`);
|
||||
},
|
||||
}),
|
||||
};
|
||||
Reference in New Issue
Block a user