🔧 fix(src/notifications): обновляет инициализацию Firebase в NotificationsService
✨ feat(src/main): изменяет название API на JustUs и обновляет описание 🔄 chore(package): обновляет зависимости и devDependencies в package.json 🔧 fix(tsconfig): добавляет игнорирование устаревших предупреждений в tsconfig.json
This commit is contained in:
40
package.json
40
package.json
@@ -23,37 +23,37 @@
|
|||||||
"db:seed": "ts-node -r tsconfig-paths/register src/database/seed.ts"
|
"db:seed": "ts-node -r tsconfig-paths/register src/database/seed.ts"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@fastify/multipart": "^8.3.0",
|
"@fastify/multipart": "^10.0.0",
|
||||||
"@fastify/static": "^7.0.4",
|
"@fastify/static": "^8.3.0",
|
||||||
"@nestjs/common": "^10.4.15",
|
"@nestjs/common": "^10.4.1",
|
||||||
"@nestjs/config": "^3.3.0",
|
"@nestjs/config": "^3.3.0",
|
||||||
"@nestjs/core": "^10.4.15",
|
"@nestjs/core": "^11.1.27",
|
||||||
"@nestjs/jwt": "^10.2.0",
|
"@nestjs/jwt": "^10.2.0",
|
||||||
"@nestjs/passport": "^10.0.3",
|
"@nestjs/passport": "^11.0.5",
|
||||||
"@nestjs/platform-fastify": "^10.4.15",
|
"@nestjs/platform-fastify": "^11.1.27",
|
||||||
"@nestjs/platform-socket.io": "^10.4.15",
|
"@nestjs/platform-socket.io": "^10.4.22",
|
||||||
"@nestjs/swagger": "^7.4.2",
|
"@nestjs/swagger": "^7.4.2",
|
||||||
"@nestjs/websockets": "^10.4.15",
|
"@nestjs/websockets": "^10.4.22",
|
||||||
"bcrypt": "^5.1.1",
|
"bcrypt": "^5.1.1",
|
||||||
"class-transformer": "^0.5.1",
|
"class-transformer": "^0.5.1",
|
||||||
"class-validator": "^0.14.1",
|
"class-validator": "^0.14.1",
|
||||||
"dotenv": "^17.4.2",
|
"dotenv": "^17.4.2",
|
||||||
"drizzle-orm": "^0.38.3",
|
"drizzle-orm": "^0.45.2",
|
||||||
"fastify": "^4.28.1",
|
"fastify": "^5.8.5",
|
||||||
"firebase-admin": "^12.7.0",
|
"firebase-admin": "^14.0.0",
|
||||||
"ioredis": "^5.4.1",
|
"ioredis": "^5.4.2",
|
||||||
"minio": "^8.0.3",
|
"minio": "^8.0.3",
|
||||||
"passport": "^0.7.0",
|
"passport": "^0.7.0",
|
||||||
"passport-jwt": "^4.0.1",
|
"passport-jwt": "^4.0.1",
|
||||||
"pg": "^8.13.1",
|
"pg": "^8.13.1",
|
||||||
"reflect-metadata": "^0.2.2",
|
"reflect-metadata": "^0.2.2",
|
||||||
"rxjs": "^7.8.1",
|
"rxjs": "^7.8.2",
|
||||||
"socket.io": "^4.8.1",
|
"socket.io": "^4.8.3",
|
||||||
"uuid": "^11.0.3"
|
"uuid": "^11.0.5"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@nestjs/cli": "^10.4.9",
|
"@nestjs/cli": "^11.0.23",
|
||||||
"@nestjs/schematics": "^10.2.3",
|
"@nestjs/schematics": "^11.1.0",
|
||||||
"@nestjs/testing": "^10.4.15",
|
"@nestjs/testing": "^10.4.15",
|
||||||
"@types/bcrypt": "^5.0.2",
|
"@types/bcrypt": "^5.0.2",
|
||||||
"@types/dotenv": "^8.2.3",
|
"@types/dotenv": "^8.2.3",
|
||||||
@@ -64,15 +64,15 @@
|
|||||||
"@types/pg": "^8.11.10",
|
"@types/pg": "^8.11.10",
|
||||||
"@types/uuid": "^10.0.0",
|
"@types/uuid": "^10.0.0",
|
||||||
"@typescript-eslint/eslint-plugin": "^8.18.2",
|
"@typescript-eslint/eslint-plugin": "^8.18.2",
|
||||||
"@typescript-eslint/parser": "^8.18.2",
|
"@typescript-eslint/parser": "^8.62.0",
|
||||||
"drizzle-kit": "^0.29.1",
|
"drizzle-kit": "^0.31.10",
|
||||||
"eslint": "^9.17.0",
|
"eslint": "^9.17.0",
|
||||||
"jest": "^29.7.0",
|
"jest": "^29.7.0",
|
||||||
"prettier": "^3.4.2",
|
"prettier": "^3.4.2",
|
||||||
"ts-jest": "^29.2.5",
|
"ts-jest": "^29.2.5",
|
||||||
"ts-node": "^10.9.2",
|
"ts-node": "^10.9.2",
|
||||||
"tsconfig-paths": "^4.2.0",
|
"tsconfig-paths": "^4.2.0",
|
||||||
"typescript": "^5.7.2"
|
"typescript": "^6.0.3"
|
||||||
},
|
},
|
||||||
"jest": {
|
"jest": {
|
||||||
"moduleFileExtensions": [
|
"moduleFileExtensions": [
|
||||||
|
|||||||
2614
pnpm-lock.yaml
generated
2614
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@@ -1,10 +1,11 @@
|
|||||||
onlyBuiltDependencies:
|
onlyBuiltDependencies:
|
||||||
- "@nestjs/core"
|
- "@nestjs/core"
|
||||||
- bcrypt
|
- bcrypt
|
||||||
- esbuild
|
- esbuild
|
||||||
- protobufjs
|
- protobufjs
|
||||||
|
|
||||||
allowBuilds:
|
allowBuilds:
|
||||||
|
'@firebase/util': false
|
||||||
"@nestjs/core": true
|
"@nestjs/core": true
|
||||||
bcrypt: true
|
bcrypt: true
|
||||||
esbuild: true
|
esbuild: true
|
||||||
|
|||||||
12
src/main.ts
12
src/main.ts
@@ -7,10 +7,10 @@ import multipart from '@fastify/multipart';
|
|||||||
import { AppModule } from './app.module';
|
import { AppModule } from './app.module';
|
||||||
|
|
||||||
async function bootstrap() {
|
async function bootstrap() {
|
||||||
const app = await NestFactory.create<NestFastifyApplication>(
|
const app = (await NestFactory.create(
|
||||||
AppModule,
|
AppModule,
|
||||||
new FastifyAdapter({ logger: true }),
|
new FastifyAdapter({ logger: true }),
|
||||||
);
|
)) as NestFastifyApplication;
|
||||||
|
|
||||||
const configService = app.get(ConfigService);
|
const configService = app.get(ConfigService);
|
||||||
const port = configService.get<number>('app.port');
|
const port = configService.get<number>('app.port');
|
||||||
@@ -39,14 +39,14 @@ async function bootstrap() {
|
|||||||
|
|
||||||
if (nodeEnv !== 'production') {
|
if (nodeEnv !== 'production') {
|
||||||
const swaggerConfig = new DocumentBuilder()
|
const swaggerConfig = new DocumentBuilder()
|
||||||
.setTitle('Daiting App API')
|
.setTitle('JustUs API')
|
||||||
.setDescription('REST API for Daiting mobile application')
|
.setDescription('REST API for JustUs mobile application')
|
||||||
.setVersion('1.0')
|
.setVersion('1.0')
|
||||||
.addBearerAuth()
|
.addBearerAuth()
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
const document = SwaggerModule.createDocument(app, swaggerConfig);
|
const document = SwaggerModule.createDocument(app as any, swaggerConfig);
|
||||||
SwaggerModule.setup('api/docs', app, document, {
|
SwaggerModule.setup('api/docs', app as any, document, {
|
||||||
swaggerOptions: { persistAuthorization: true },
|
swaggerOptions: { persistAuthorization: true },
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
import { Injectable, Logger, OnModuleInit } from '@nestjs/common';
|
import { Injectable, Logger, OnModuleInit } from '@nestjs/common';
|
||||||
import { ConfigService } from '@nestjs/config';
|
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()
|
@Injectable()
|
||||||
export class NotificationsService implements OnModuleInit {
|
export class NotificationsService implements OnModuleInit {
|
||||||
private readonly logger = new Logger(NotificationsService.name);
|
private readonly logger = new Logger(NotificationsService.name);
|
||||||
private app: admin.app.App;
|
private app: App;
|
||||||
|
|
||||||
constructor(private readonly configService: ConfigService) {}
|
constructor(private readonly configService: ConfigService) {}
|
||||||
|
|
||||||
@@ -19,12 +20,12 @@ export class NotificationsService implements OnModuleInit {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (admin.apps.length === 0) {
|
if (getApps().length === 0) {
|
||||||
this.app = admin.initializeApp({
|
this.app = initializeApp({
|
||||||
credential: admin.credential.cert({ projectId, privateKey, clientEmail }),
|
credential: cert({ projectId, privateKey, clientEmail }),
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
this.app = admin.apps[0];
|
this.app = getApps()[0];
|
||||||
}
|
}
|
||||||
this.logger.log('Firebase initialized');
|
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>) {
|
async sendPushNotification(fcmToken: string, title: string, body: string, data?: Record<string, string>) {
|
||||||
if (!this.app || !fcmToken) return;
|
if (!this.app || !fcmToken) return;
|
||||||
try {
|
try {
|
||||||
await admin.messaging(this.app).send({
|
await getMessaging(this.app).send({
|
||||||
token: fcmToken,
|
token: fcmToken,
|
||||||
notification: { title, body },
|
notification: { title, body },
|
||||||
data,
|
data,
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} 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>) {
|
async sendMulticast(fcmTokens: string[], title: string, body: string, data?: Record<string, string>) {
|
||||||
if (!this.app || !fcmTokens.length) return;
|
if (!this.app || !fcmTokens.length) return;
|
||||||
try {
|
try {
|
||||||
await admin.messaging(this.app).sendEachForMulticast({
|
await getMessaging(this.app).sendEachForMulticast({
|
||||||
tokens: fcmTokens,
|
tokens: fcmTokens,
|
||||||
notification: { title, body },
|
notification: { title, body },
|
||||||
data,
|
data,
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.logger.error(`Failed to send multicast: ${error.message}`);
|
this.logger.error(`Failed to send multicast: ${(error as Error).message}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
"sourceMap": true,
|
"sourceMap": true,
|
||||||
"outDir": "./dist",
|
"outDir": "./dist",
|
||||||
"baseUrl": "./",
|
"baseUrl": "./",
|
||||||
|
"ignoreDeprecations": "6.0",
|
||||||
"incremental": true,
|
"incremental": true,
|
||||||
"skipLibCheck": true,
|
"skipLibCheck": true,
|
||||||
"strictNullChecks": false,
|
"strictNullChecks": false,
|
||||||
|
|||||||
Reference in New Issue
Block a user