🔧 fix(src/notifications): обновляет инициализацию Firebase в NotificationsService

 feat(src/main): изменяет название API на JustUs и обновляет описание

🔄 chore(package): обновляет зависимости и devDependencies в package.json

🔧 fix(tsconfig): добавляет игнорирование устаревших предупреждений в tsconfig.json
This commit is contained in:
Oscar
2026-06-24 17:44:22 +03:00
parent cd98f04987
commit c533dff6ed
6 changed files with 1653 additions and 1038 deletions

View File

@@ -23,37 +23,37 @@
"db:seed": "ts-node -r tsconfig-paths/register src/database/seed.ts"
},
"dependencies": {
"@fastify/multipart": "^8.3.0",
"@fastify/static": "^7.0.4",
"@nestjs/common": "^10.4.15",
"@fastify/multipart": "^10.0.0",
"@fastify/static": "^8.3.0",
"@nestjs/common": "^10.4.1",
"@nestjs/config": "^3.3.0",
"@nestjs/core": "^10.4.15",
"@nestjs/core": "^11.1.27",
"@nestjs/jwt": "^10.2.0",
"@nestjs/passport": "^10.0.3",
"@nestjs/platform-fastify": "^10.4.15",
"@nestjs/platform-socket.io": "^10.4.15",
"@nestjs/passport": "^11.0.5",
"@nestjs/platform-fastify": "^11.1.27",
"@nestjs/platform-socket.io": "^10.4.22",
"@nestjs/swagger": "^7.4.2",
"@nestjs/websockets": "^10.4.15",
"@nestjs/websockets": "^10.4.22",
"bcrypt": "^5.1.1",
"class-transformer": "^0.5.1",
"class-validator": "^0.14.1",
"dotenv": "^17.4.2",
"drizzle-orm": "^0.38.3",
"fastify": "^4.28.1",
"firebase-admin": "^12.7.0",
"ioredis": "^5.4.1",
"drizzle-orm": "^0.45.2",
"fastify": "^5.8.5",
"firebase-admin": "^14.0.0",
"ioredis": "^5.4.2",
"minio": "^8.0.3",
"passport": "^0.7.0",
"passport-jwt": "^4.0.1",
"pg": "^8.13.1",
"reflect-metadata": "^0.2.2",
"rxjs": "^7.8.1",
"socket.io": "^4.8.1",
"uuid": "^11.0.3"
"rxjs": "^7.8.2",
"socket.io": "^4.8.3",
"uuid": "^11.0.5"
},
"devDependencies": {
"@nestjs/cli": "^10.4.9",
"@nestjs/schematics": "^10.2.3",
"@nestjs/cli": "^11.0.23",
"@nestjs/schematics": "^11.1.0",
"@nestjs/testing": "^10.4.15",
"@types/bcrypt": "^5.0.2",
"@types/dotenv": "^8.2.3",
@@ -64,15 +64,15 @@
"@types/pg": "^8.11.10",
"@types/uuid": "^10.0.0",
"@typescript-eslint/eslint-plugin": "^8.18.2",
"@typescript-eslint/parser": "^8.18.2",
"drizzle-kit": "^0.29.1",
"@typescript-eslint/parser": "^8.62.0",
"drizzle-kit": "^0.31.10",
"eslint": "^9.17.0",
"jest": "^29.7.0",
"prettier": "^3.4.2",
"ts-jest": "^29.2.5",
"ts-node": "^10.9.2",
"tsconfig-paths": "^4.2.0",
"typescript": "^5.7.2"
"typescript": "^6.0.3"
},
"jest": {
"moduleFileExtensions": [

2614
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,10 +1,11 @@
onlyBuiltDependencies:
onlyBuiltDependencies:
- "@nestjs/core"
- bcrypt
- esbuild
- protobufjs
allowBuilds:
'@firebase/util': false
"@nestjs/core": true
bcrypt: true
esbuild: true

View File

@@ -7,10 +7,10 @@ import multipart from '@fastify/multipart';
import { AppModule } from './app.module';
async function bootstrap() {
const app = await NestFactory.create<NestFastifyApplication>(
const app = (await NestFactory.create(
AppModule,
new FastifyAdapter({ logger: true }),
);
)) as NestFastifyApplication;
const configService = app.get(ConfigService);
const port = configService.get<number>('app.port');
@@ -39,14 +39,14 @@ async function bootstrap() {
if (nodeEnv !== 'production') {
const swaggerConfig = new DocumentBuilder()
.setTitle('Daiting App API')
.setDescription('REST API for Daiting mobile application')
.setTitle('JustUs API')
.setDescription('REST API for JustUs mobile application')
.setVersion('1.0')
.addBearerAuth()
.build();
const document = SwaggerModule.createDocument(app, swaggerConfig);
SwaggerModule.setup('api/docs', app, document, {
const document = SwaggerModule.createDocument(app as any, swaggerConfig);
SwaggerModule.setup('api/docs', app as any, document, {
swaggerOptions: { persistAuthorization: true },
});
}

View File

@@ -1,11 +1,12 @@
import { Injectable, Logger, OnModuleInit } from '@nestjs/common';
import { ConfigService } from '@nestjs/config';
import * as admin from 'firebase-admin';
import { initializeApp, getApps, cert, App } from 'firebase-admin/app';
import { getMessaging } from 'firebase-admin/messaging';
@Injectable()
export class NotificationsService implements OnModuleInit {
private readonly logger = new Logger(NotificationsService.name);
private app: admin.app.App;
private app: App;
constructor(private readonly configService: ConfigService) {}
@@ -19,12 +20,12 @@ export class NotificationsService implements OnModuleInit {
return;
}
if (admin.apps.length === 0) {
this.app = admin.initializeApp({
credential: admin.credential.cert({ projectId, privateKey, clientEmail }),
if (getApps().length === 0) {
this.app = initializeApp({
credential: cert({ projectId, privateKey, clientEmail }),
});
} else {
this.app = admin.apps[0];
this.app = getApps()[0];
}
this.logger.log('Firebase initialized');
}
@@ -32,26 +33,26 @@ export class NotificationsService implements OnModuleInit {
async sendPushNotification(fcmToken: string, title: string, body: string, data?: Record<string, string>) {
if (!this.app || !fcmToken) return;
try {
await admin.messaging(this.app).send({
await getMessaging(this.app).send({
token: fcmToken,
notification: { title, body },
data,
});
} catch (error) {
this.logger.error(`Failed to send push notification: ${error.message}`);
this.logger.error(`Failed to send push notification: ${(error as Error).message}`);
}
}
async sendMulticast(fcmTokens: string[], title: string, body: string, data?: Record<string, string>) {
if (!this.app || !fcmTokens.length) return;
try {
await admin.messaging(this.app).sendEachForMulticast({
await getMessaging(this.app).sendEachForMulticast({
tokens: fcmTokens,
notification: { title, body },
data,
});
} catch (error) {
this.logger.error(`Failed to send multicast: ${error.message}`);
this.logger.error(`Failed to send multicast: ${(error as Error).message}`);
}
}
}

View File

@@ -10,6 +10,7 @@
"sourceMap": true,
"outDir": "./dist",
"baseUrl": "./",
"ignoreDeprecations": "6.0",
"incremental": true,
"skipLibCheck": true,
"strictNullChecks": false,