-
-
Notifications
You must be signed in to change notification settings - Fork 126
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(api): Add configuration live update support (#181)
- Loading branch information
1 parent
8fc8b02
commit e021360
Showing
32 changed files
with
822 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export const Environment = { | ||
DATABASE_URL: process.env.DATABASE_URL! | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
...api/src/prisma/migrations/20240410130019_add_change_notification_socket_map/migration.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
-- CreateTable | ||
CREATE TABLE "ChangeNotificationSocketMap" ( | ||
"id" TEXT NOT NULL, | ||
"socketId" TEXT NOT NULL, | ||
"environmentId" TEXT NOT NULL, | ||
|
||
CONSTRAINT "ChangeNotificationSocketMap_pkey" PRIMARY KEY ("id") | ||
); | ||
|
||
-- CreateIndex | ||
CREATE INDEX "ChangeNotificationSocketMap_environmentId_socketId_idx" ON "ChangeNotificationSocketMap"("environmentId", "socketId"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { Global, Module } from '@nestjs/common' | ||
import { REDIS_CLIENT, RedisProvider } from './redis.provider' | ||
|
||
@Global() | ||
@Module({ | ||
exports: [ | ||
{ | ||
provide: REDIS_CLIENT, | ||
useValue: RedisProvider | ||
} | ||
], | ||
providers: [RedisProvider] | ||
}) | ||
export class ProviderModule {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { Logger, Provider } from '@nestjs/common' | ||
import { exit } from 'process' | ||
import * as redis from 'redis' | ||
|
||
export const REDIS_CLIENT = 'RedisClient' | ||
|
||
export const RedisProvider: Provider = { | ||
provide: REDIS_CLIENT, | ||
useFactory: async () => { | ||
const logger = new Logger('RedisProvider') | ||
if (!process.env.REDIS_URL) { | ||
logger.error('Redis credentials are not set. Stopping the application.') | ||
exit(1) | ||
} | ||
|
||
const subscriber = redis.createClient({ | ||
url: process.env.REDIS_URL, | ||
password: process.env.REDIS_PASSWORD | ||
}) | ||
const publisher = redis.createClient({ | ||
url: process.env.REDIS_URL, | ||
password: process.env.REDIS_PASSWORD | ||
}) | ||
|
||
publisher.on('error', (error) => { | ||
logger.error('Redis client error:', error) | ||
}) | ||
await publisher.connect() | ||
|
||
subscriber.on('error', (error) => { | ||
logger.error('Redis client error:', error) | ||
}) | ||
await subscriber.connect() | ||
|
||
return { | ||
subscriber, | ||
publisher | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.