放弃短信验证了

This commit is contained in:
2025-05-07 17:21:49 +08:00
parent 8039a3571d
commit 9570fb4524
7 changed files with 369 additions and 4 deletions

View File

@@ -1,4 +1,8 @@
import { Module } from '@nestjs/common';
import { NotificationService } from './notification.service';
@Module({})
@Module({
providers: [NotificationService],
exports: [NotificationService],
})
export class NotificationModule {}

View File

@@ -0,0 +1,18 @@
import { Test, TestingModule } from '@nestjs/testing';
import { NotificationService } from './notification.service';
describe('NotificationService', () => {
let service: NotificationService;
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
providers: [NotificationService],
}).compile();
service = module.get<NotificationService>(NotificationService);
});
it('should be defined', () => {
expect(service).toBeDefined();
});
});

View File

@@ -0,0 +1,38 @@
import { Injectable } from '@nestjs/common';
@Injectable()
export class NotificationService {
sendEmail(email: string, subject: string, content: string) {
}
/**
* @deprecated 短信签名暂未通过
*/
async sendSMS(phone: string, type: 'login', code: string) {
// const config = new $OpenApi.Config({
// accessKeyId: process.env.ALIYUN_ACCESS_KEY_ID,
// accessKeySecret: process.env.ALIYUN_ACCESS_KEY_SECRET,
// })
// config.endpoint = 'dysmsapi.aliyuncs.com';
// const client = new Client(config);
// const request = new $dysmsapi.SendSmsRequest({});
// request.phoneNumbers = phone;
// request.signName = (() => {
// switch (type) {
// case 'login':
// return process.env.ALIYUN_SMS_LOGIN_SIGN_NAME;
// default:
// throw new Error('Unknown SMS type');
// }
// })();
// request.templateCode = code;
// await client.sendSms(request).then(a => {
// console.log(a)
// }).catch(err => {
// console.error(err);
// })
}
}