mirror of
https://github.com/immich-app/immich
synced 2025-11-07 17:27:20 +00:00
chore(server) Update NestJs to V9 (#1312)
* chore(server) update nestjs to v9 * remove deadcode * downgrade local-reverse-geocoder * Added ignore script * remove ignore script * Fixed local-reverse-geocoder to a working version * Fixed issue with eslint mismatch typescript version * chore: remove unused package Co-authored-by: Jason Rasmussen <jrasm91@gmail.com>
This commit is contained in:
parent
67c52c3764
commit
6db541c89b
6 changed files with 2039 additions and 1471 deletions
|
|
@ -24,7 +24,9 @@ async function bootstrap() {
|
|||
app.enableCors();
|
||||
}
|
||||
|
||||
app.useWebSocketAdapter(new RedisIoAdapter(app));
|
||||
const redisIoAdapter = new RedisIoAdapter(app);
|
||||
await redisIoAdapter.connectToRedis();
|
||||
app.useWebSocketAdapter(redisIoAdapter);
|
||||
|
||||
const config = new DocumentBuilder()
|
||||
.setTitle('Immich')
|
||||
|
|
|
|||
|
|
@ -1,31 +1,32 @@
|
|||
import { IoAdapter } from '@nestjs/platform-socket.io';
|
||||
import { RedisClient } from 'redis';
|
||||
import { createClient } from 'redis';
|
||||
import { ServerOptions } from 'socket.io';
|
||||
import { createAdapter } from 'socket.io-redis';
|
||||
import { createAdapter } from '@socket.io/redis-adapter';
|
||||
|
||||
const redisHost = process.env.REDIS_HOSTNAME || 'immich_redis';
|
||||
const redisPort = parseInt(process.env.REDIS_PORT || '6379');
|
||||
const redisDb = parseInt(process.env.REDIS_DBINDEX || '0');
|
||||
const redisPassword = process.env.REDIS_PASSWORD || undefined;
|
||||
const redisSocket = process.env.REDIS_SOCKET || undefined;
|
||||
// const pubClient = createClient({ url: `redis://${redis_host}:6379` });
|
||||
// const subClient = pubClient.duplicate();
|
||||
|
||||
const pubClient = new RedisClient({
|
||||
host: redisHost,
|
||||
port: redisPort,
|
||||
db: redisDb,
|
||||
password: redisPassword,
|
||||
path: redisSocket,
|
||||
});
|
||||
|
||||
const subClient = pubClient.duplicate();
|
||||
const redisAdapter = createAdapter({ pubClient, subClient });
|
||||
// const redisSocket = process.env.REDIS_SOCKET || undefined;
|
||||
|
||||
export class RedisIoAdapter extends IoAdapter {
|
||||
private adapterConstructor: any;
|
||||
|
||||
async connectToRedis(): Promise<void> {
|
||||
const pubClient = createClient({
|
||||
url: `redis://${redisHost}:${redisPort}/${redisDb}`,
|
||||
password: redisPassword,
|
||||
});
|
||||
const subClient = pubClient.duplicate();
|
||||
|
||||
await Promise.all([pubClient.connect(), subClient.connect()]);
|
||||
|
||||
this.adapterConstructor = createAdapter(pubClient, subClient);
|
||||
}
|
||||
|
||||
createIOServer(port: number, options?: ServerOptions): any {
|
||||
const server = super.createIOServer(port, options);
|
||||
server.adapter(redisAdapter);
|
||||
server.adapter(this.adapterConstructor);
|
||||
return server;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,9 @@ const logger = new Logger('ImmichMicroservice');
|
|||
async function bootstrap() {
|
||||
const app = await NestFactory.create(MicroservicesModule);
|
||||
|
||||
app.useWebSocketAdapter(new RedisIoAdapter(app));
|
||||
const redisIoAdapter = new RedisIoAdapter(app);
|
||||
await redisIoAdapter.connectToRedis();
|
||||
app.useWebSocketAdapter(redisIoAdapter);
|
||||
|
||||
await app.listen(3002, () => {
|
||||
const envName = (process.env.NODE_ENV || 'development').toUpperCase();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue