mirror of
https://github.com/jiangrui1994/CloudSaver.git
synced 2026-01-12 08:08:46 +08:00
Refactor the backend
This commit is contained in:
@@ -2,34 +2,11 @@ import { Request, Response } from "express";
|
||||
import { injectable, inject } from "inversify";
|
||||
import { TYPES } from "../core/types";
|
||||
import { QuarkService } from "../services/QuarkService";
|
||||
import { BaseController } from "./BaseController";
|
||||
import { BaseCloudController } from "./BaseCloudController";
|
||||
|
||||
@injectable()
|
||||
export class QuarkController extends BaseController {
|
||||
constructor(@inject(TYPES.QuarkService) private quarkService: QuarkService) {
|
||||
super();
|
||||
}
|
||||
|
||||
async getShareInfo(req: Request, res: Response): Promise<void> {
|
||||
await this.handleRequest(req, res, async () => {
|
||||
const { shareCode, receiveCode } = req.query;
|
||||
await this.quarkService.setCookie(req);
|
||||
return await this.quarkService.getShareInfo(shareCode as string, receiveCode as string);
|
||||
});
|
||||
}
|
||||
|
||||
async getFolderList(req: Request, res: Response): Promise<void> {
|
||||
await this.handleRequest(req, res, async () => {
|
||||
const { parentCid } = req.query;
|
||||
await this.quarkService.setCookie(req);
|
||||
return await this.quarkService.getFolderList(parentCid as string);
|
||||
});
|
||||
}
|
||||
|
||||
async saveFile(req: Request, res: Response): Promise<void> {
|
||||
await this.handleRequest(req, res, async () => {
|
||||
await this.quarkService.setCookie(req);
|
||||
return await this.quarkService.saveSharedFile(req.body);
|
||||
});
|
||||
export class QuarkController extends BaseCloudController {
|
||||
constructor(@inject(TYPES.QuarkService) quarkService: QuarkService) {
|
||||
super(quarkService);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user