Add PoW module

This commit is contained in:
2024-04-02 16:45:09 -06:00
parent 27954f6a8c
commit 8b25ba39b8
5 changed files with 131 additions and 1 deletions

24
src/pow/pow.controller.ts Normal file
View File

@@ -0,0 +1,24 @@
import { Body, Controller, Get, Post, Query } from '@nestjs/common';
import { PowService } from './pow.service';
import { ApiBody, ApiQuery, ApiTags } from '@nestjs/swagger';
@ApiTags('pow')
@Controller('pow')
export class PowController {
constructor(
private readonly powService: PowService,
) { }
@Get('challenge')
async generateChallenge() {
return this.powService.generateChallenge();
}
@Post('challenge')
@ApiBody({ schema: { properties: { challenge: { type: 'string' }, proof: { type: 'string' } } } })
async verifyChallenge(@Body() body: { challenge: string, proof: string }) {
return this.powService.verifyChallenge(body.challenge, body.proof);
}
}