Skip to content

Commit

Permalink
feat(libs+user-notification): Contentful graphql client library plus …
Browse files Browse the repository at this point in the history
…user notification implementation (#14901)

* basic setup

* chore: nx format:write update dirty files

* eslintrc

* chore: nx format:write update dirty files

* remix

* chore: nx format:write update dirty files

* update readme edits

* update readme edits

* chore: nx format:write update dirty files

* cleanup setup

* chore: nx format:write update dirty files

* rename files

* rename files

* working demo

* implementing lib

* consolidate queries refactor

* consolidate queries refactor

* cleanup

* cleanup queries

* enhancedfetch redis cache setup

* chore: charts update dirty files

* charts

* redis working

* redis cache tweaks

* redis cache tweaks

* graphql generated

* user notification gql

* user notification gql setup works

* tidy up

* update tests

* codegen cleanup

* cache works

* cleanup

* cleanup

* implicitDependencies

* updated readme

* disable codegen in CI

* disable codegen in CI

* disable codegen in CI

* rename lib

* rename lib

* GetOrganizationByNationalId

* nationalId: senderId

* cleanStringAdvanced

* rename lib to cms

* rename lib to cms

* fetch schema command

* fetch schema command

* fetch schema command

* chore: nx format:write update dirty files

* fix lint error

* cleanup

---------

Co-authored-by: andes-it <[email protected]>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Jun 18, 2024
1 parent 579ee9f commit 17a146e
Show file tree
Hide file tree
Showing 33 changed files with 27,752 additions and 171 deletions.
10 changes: 10 additions & 0 deletions apps/services/user-notification/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,16 @@ services:
- POSTGRES_PASSWORD=dev_db
ports:
- 5432:5432
redis_cluster:
container_name: redis_cluster
image: docker.io/grokzen/redis-cluster:6.0.16
networks:
- local
privileged: true
environment:
- IP=0.0.0.0
ports:
- '7000-7005:7000-7005'

networks:
local:
3 changes: 3 additions & 0 deletions apps/services/user-notification/infra/user-notification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ const getEnv = (services: {
staging: '[email protected]',
prod: '[email protected]',
},
REDIS_USE_SSL: 'true',
})

export const userNotificationServiceSetup = (services: {
Expand All @@ -57,6 +58,7 @@ export const userNotificationServiceSetup = (services: {
.db()
.command('node')
.args('--no-experimental-fetch', 'main.js')
.redis()
.env(getEnv(services))
.secrets({
FIREBASE_CREDENTIALS: `/k8s/${serviceName}/firestore-credentials`,
Expand Down Expand Up @@ -121,6 +123,7 @@ export const userNotificationWorkerSetup = (services: {
.args('--no-experimental-fetch', 'main.js', '--job=worker')
.db()
.migrations()
.redis()
.env({
...getEnv(services),
EMAIL_REGION: 'eu-west-1',
Expand Down
2 changes: 2 additions & 0 deletions apps/services/user-notification/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { AuthDelegationApiClientConfig } from '@island.is/clients/auth/delegatio
import { SequelizeConfigService } from './sequelizeConfig.service'
import { environment } from '../environments/environment'
import { UserNotificationsConfig } from '../config'
import { CmsConfig } from '@island.is/clients/cms'

@Module({
imports: [
Expand All @@ -36,6 +37,7 @@ import { UserNotificationsConfig } from '../config'
UserProfileClientConfig,
IdsClientConfig,
AuthDelegationApiClientConfig,
CmsConfig,
],
}),
NotificationsModule,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { LOGGER_PROVIDER } from '@island.is/logging'
import { Notification } from './types'
import { FIREBASE_PROVIDER } from '../../../constants'
import { V2UsersApi } from '@island.is/clients/user-profile'
import type { FirebaseError } from 'firebase-admin/lib/utils/error'

@Injectable()
export class NotificationDispatchService {
Expand Down Expand Up @@ -115,7 +116,7 @@ export class NotificationDispatchService {
}

private async handleSendError(
error: any,
error: FirebaseError,
nationalId: string,
token: string,
messageId: string,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { InjectQueue, QueueService } from '@island.is/message-queue'
import { CacheInterceptor } from '@nestjs/cache-manager'
import {
Body,
Controller,
Expand All @@ -8,7 +7,6 @@ import {
Param,
Post,
Query,
UseInterceptors,
Version,
} from '@nestjs/common'
import { ApiExtraModels, ApiTags } from '@nestjs/swagger'
Expand All @@ -26,7 +24,6 @@ import type { Locale } from '@island.is/shared/types'
@Controller('notifications')
@ApiTags('notifications')
@ApiExtraModels(CreateNotificationDto)
@UseInterceptors(CacheInterceptor)
export class NotificationsController {
constructor(
@Inject(LOGGER_PROVIDER) private logger: Logger,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { Module } from '@nestjs/common'
import { SequelizeModule } from '@nestjs/sequelize'
import { CacheModule } from '@nestjs/cache-manager'
import * as firebaseAdmin from 'firebase-admin'

import { AuthDelegationApiClientModule } from '@island.is/clients/auth/delegation-api'
import { NationalRegistryV3ClientModule } from '@island.is/clients/national-registry-v3'
import { UserProfileClientModule } from '@island.is/clients/user-profile'
Expand All @@ -12,7 +10,6 @@ import { LoggingModule } from '@island.is/logging'
import { QueueModule } from '@island.is/message-queue'
import { FeatureFlagModule } from '@island.is/nest/feature-flags'
import { type ConfigType } from '@island.is/nest/config'

import { UserNotificationsConfig } from '../../../config'
import { FIREBASE_PROVIDER } from '../../../constants'
import { environment } from '../../../environments/environment'
Expand All @@ -23,15 +20,12 @@ import { Notification } from './notification.model'
import { NotificationDispatchService } from './notificationDispatch.service'
import { NotificationsWorkerService } from './notificationsWorker/notificationsWorker.service'
import { MessageProcessorService } from './messageProcessor.service'
import { CmsModule } from '@island.is/clients/cms'

@Module({
exports: [NotificationsService],
imports: [
SequelizeModule.forFeature([Notification]),
CacheModule.register({
ttl: 60 * 10 * 1000, // 10 minutes
max: 1000, // 1000 items max
}),
LoggingModule,
CmsTranslationsModule,
QueueModule.register({
Expand All @@ -49,6 +43,7 @@ import { MessageProcessorService } from './messageProcessor.service'
FeatureFlagModule,
NationalRegistryV3ClientModule,
AuthDelegationApiClientModule,
CmsModule,
],
controllers: [NotificationsController, MeNotificationsController],
providers: [
Expand Down
Loading

0 comments on commit 17a146e

Please sign in to comment.