This commit is contained in:
longdayi 2024-09-03 18:07:48 +08:00
parent 0237afecb7
commit 835a1ca534
7 changed files with 82 additions and 4 deletions

View File

@ -37,17 +37,21 @@
"socket.io": "^4.7.5",
"superjson-cjs": "^2.2.3",
"tus-js-client": "^4.1.0",
"zod": "^3.23.8"
"zod": "^3.23.8",
"dayjs": "^1.11.13",
"exceljs": "^4.4.0"
},
"devDependencies": {
"@nestjs/cli": "^10.0.0",
"@nestjs/schematics": "^10.0.0",
"@nestjs/testing": "^10.0.0",
"@types/express": "^4.17.17",
"@types/jest": "^29.5.2",
"@types/mime-types": "^2.1.4",
"@types/node": "^20.3.1",
"@types/supertest": "^6.0.0",
"@types/exceljs": "^1.3.0",
"@types/express": "^4.17.21",
"@types/multer": "^1.4.12",
"@typescript-eslint/eslint-plugin": "^6.0.0",
"@typescript-eslint/parser": "^6.0.0",
"eslint": "^8.42.0",

View File

@ -7,10 +7,12 @@ import { RedisService } from './redis/redis.service';
import { RedisModule } from './redis/redis.module';
import { SocketGateway } from './socket/socket.gateway';
import { QueueModule } from './queue/queue.module';
import { TransformModule } from './transform/transform.module';
import { ControllerService } from './controller/controller.service';
@Module({
imports: [TrpcModule, RedisModule, QueueModule],
imports: [TrpcModule, RedisModule, QueueModule, TransformModule],
controllers: [AppController],
providers: [AppService, RedisService, SocketGateway],
providers: [AppService, RedisService, SocketGateway, ControllerService],
})
export class AppModule { }

View File

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

View File

@ -0,0 +1,23 @@
import {
Controller,
Post,
UseInterceptors,
UploadedFile,
Body,
} from '@nestjs/common';
import { FileInterceptor } from '@nestjs/platform-express';
@Controller('transform')
export class TransformController {
@Post('import')
@UseInterceptors(FileInterceptor('file'))
async uploadFile(@UploadedFile() file: Express.Multer.File, @Body('type') type: string) {
console.log(file);
let result = 'test';
switch (type) {
default:
throw new Error(`Unsupported import type: ${type}`);
}
return result;
}
}

View File

@ -0,0 +1,9 @@
import { Module } from '@nestjs/common';
import { TransformController } from './transform.controller';
import { TransformService } from './transform.service';
@Module({
controllers: [TransformController],
providers: [TransformService]
})
export class TransformModule {}

View File

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

View File

@ -0,0 +1,4 @@
import { Injectable } from '@nestjs/common';
@Injectable()
export class TransformService {}