Skip to content

Commit

Permalink
modify: 修改第三方 oss api 的模块名称为 oss-middleware
Browse files Browse the repository at this point in the history
  • Loading branch information
kangood committed Feb 24, 2024
1 parent a157226 commit ac1b764
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 44 deletions.
13 changes: 6 additions & 7 deletions src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@ import { APP_FILTER, APP_GUARD, APP_INTERCEPTOR, APP_PIPE } from '@nestjs/core';
import { JwtService } from '@nestjs/jwt';

import { database } from './config';
import { AuthorityGuard } from './modules/auth/authority.guard';
import { LoginGuard } from './modules/auth/login.guard';
import { AppFilter, AppIntercepter, AppPipe } from './modules/core/providers';
import { DatabaseModule } from './modules/database/database.module';
import { OrgModule } from './modules/org/org.module';
import { ResourceModule } from './modules/resource/resource.module';
import { OSSModule } from './modules/restful/oss/oss.module';
import { OSSMiddlewareModule } from './modules/restful/oss/oss-middleware.module';
import { SystemModule } from './modules/system/system.module';

const envFilePath = ['.env'];
Expand All @@ -29,7 +28,7 @@ if (IS_DEV) {
DatabaseModule.forRoot(database),
SystemModule,
OrgModule,
OSSModule,
OSSMiddlewareModule,
ResourceModule,
ConfigModule.forRoot({
isGlobal: true,
Expand Down Expand Up @@ -65,10 +64,10 @@ if (IS_DEV) {
provide: APP_GUARD,
useClass: LoginGuard,
},
{
provide: APP_GUARD,
useClass: AuthorityGuard,
},
// {
// provide: APP_GUARD,
// useClass: AuthorityGuard,
// },
JwtService,
Logger,
],
Expand Down
21 changes: 21 additions & 0 deletions src/modules/restful/oss/oss-middleware.controller.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { Get, Controller } from '@nestjs/common';

import { RequireAuthority, RequireLogin } from '@/modules/auth/auth.decorator';

import { OSSMiddlewareService } from './oss-middleware.service';
import { OSSMiddlewareType } from './oss-middleware.type';

@Controller('oss-middleware')
@RequireLogin()
export class OSSMiddlewareController {
constructor(protected service: OSSMiddlewareService) {}

/**
* 获取阿里 OSS 上传信息
*/
@Get('getAliOSSInfo')
@RequireAuthority('oss-middleware:getAliOSSInfo')
async getAliOSSInfo(): Promise<OSSMiddlewareType> {
return this.service.getSignature();
}
}
12 changes: 12 additions & 0 deletions src/modules/restful/oss/oss-middleware.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { Module } from '@nestjs/common';

import { OSSMiddlewareController } from './oss-middleware.controller';
import { OSSMiddlewareService } from './oss-middleware.service';

@Module({
imports: [],
controllers: [OSSMiddlewareController],
providers: [OSSMiddlewareService],
exports: [],
})
export class OSSMiddlewareModule {}
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ import { Injectable } from '@nestjs/common';
import OSS from 'ali-oss';
import dayjs from 'dayjs';

import { OSSType } from './oss.type';
import { OSSMiddlewareType } from './oss-middleware.type';

@Injectable()
export class OSSService {
export class OSSMiddlewareService {
/**
* @description 获取 OSS 上传签名
* @see https://help.aliyun.com/document_detail/31926.html
* @return {*} {Promise<OSSType>}
* @memberof OSSService
*/
async getSignature(): Promise<OSSType> {
async getSignature(): Promise<OSSMiddlewareType> {
const config = {
accessKeyId: process.env.ACCESS_KEY,
accessKeySecret: process.env.ACCESS_KEY_SECRET,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export class OSSType {
export class OSSMiddlewareType {
expire: string;

policy: string;
Expand Down
21 changes: 0 additions & 21 deletions src/modules/restful/oss/oss.controller.ts

This file was deleted.

12 changes: 0 additions & 12 deletions src/modules/restful/oss/oss.module.ts

This file was deleted.

0 comments on commit ac1b764

Please sign in to comment.