Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
zcpua committed Jul 16, 2023
1 parent 9aafd88 commit 258ef88
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/app.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,17 @@ import {
import { MidjourneyService } from './midjourney.service';
import { FastifyReply } from 'fastify';
import { AvatarBody, PromptMessageBody } from './interfaces';
@Controller('vs1/midjourney')
@Controller('midjourney')
export class AppController {
constructor(private readonly MjService: MidjourneyService) {}
@Post('imagine')
@UseInterceptors()
async Imagine(@Body() data: PromptMessageBody, @Res() res: FastifyReply) {
res.raw.setHeader('Content-Type', 'text/plain');
res.raw.setHeader('Content-Type', 'text/html');
res.raw.setHeader('Transfer-Encoding', 'chunked');
res.raw.setHeader('Cache-Control', 'no-cache, no-store, must-revalidate');
res.raw.setHeader('Pragma', 'no-cache');
res.raw.setHeader('Expires', '0');
const msg = await this.MjService.Imagine(data.prompt, (uri: string) => {
res.raw.write(JSON.stringify({ uri }));
});
Expand All @@ -27,8 +30,12 @@ export class AppController {
@Post('avatar')
@UseInterceptors()
async Avatar(@Body() data: AvatarBody, @Res() res: FastifyReply) {
res.raw.setHeader('Content-Type', 'text/plain');
res.raw.setHeader('Content-Type', 'text/html');
res.raw.setHeader('Transfer-Encoding', 'chunked');
res.raw.setHeader('Cache-Control', 'no-cache, no-store, must-revalidate');
res.raw.setHeader('Pragma', 'no-cache');
res.raw.setHeader('Expires', '0');

const msg = await this.MjService.Avatar(data.img, (uri: string) => {
res.raw.write(JSON.stringify({ uri }));
});
Expand Down

0 comments on commit 258ef88

Please sign in to comment.