Commit 74cab697 authored by nanahira's avatar nanahira

/score api

parent 66b86b2f
Pipeline #2271 passed with stages
in 2 minutes and 29 seconds
......@@ -846,6 +846,16 @@
"iterare": "1.2.1",
"tslib": "2.0.3",
"uuid": "8.3.1"
},
"dependencies": {
"axios": {
"version": "0.21.0",
"resolved": "https://registry.npmjs.org/axios/-/axios-0.21.0.tgz",
"integrity": "sha512-fmkJBknJKoZwem3/IKSSLpkdNXZeBu5Q7GA/aRsr2btgrptmSCxi2oFjZHqGdK9DoTil9PIHlPIZw2EcRJXRvw==",
"requires": {
"follow-redirects": "^1.10.0"
}
}
}
},
"@nestjs/core": {
......@@ -1933,9 +1943,9 @@
"integrity": "sha512-xh1Rl34h6Fi1DC2WWKfxUTVqRsNnr6LsKz2+hfwDxQJWmrx8+c7ylaqBMcHfl1U1r2dsifOvKX3LQuLNZ+XSvA=="
},
"axios": {
"version": "0.21.0",
"resolved": "https://registry.npmjs.org/axios/-/axios-0.21.0.tgz",
"integrity": "sha512-fmkJBknJKoZwem3/IKSSLpkdNXZeBu5Q7GA/aRsr2btgrptmSCxi2oFjZHqGdK9DoTil9PIHlPIZw2EcRJXRvw==",
"version": "0.21.1",
"resolved": "https://registry.npmjs.org/axios/-/axios-0.21.1.tgz",
"integrity": "sha512-dKQiRHxGD9PPRIUNIWvZhPTPpl1rf/OxTYKsqKUDjBwYylTvV7SjSHJb9ratfyzM6wCdLCOYLzs73qpg5c4iGA==",
"requires": {
"follow-redirects": "^1.10.0"
}
......@@ -3655,9 +3665,9 @@
"dev": true
},
"follow-redirects": {
"version": "1.13.0",
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.13.0.tgz",
"integrity": "sha512-aq6gF1BEKje4a9i9+5jimNFIpq4Q1WiwBToeRK5NvZBd/TRsmW8BsJfOEGkr76TbOyPVD3OVDN910EcUNtRYEA=="
"version": "1.13.2",
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.13.2.tgz",
"integrity": "sha512-6mPTgLxYm3r6Bkkg0vNM0HTjfGrOEtsfbhagQvbxDEsEkpNhw582upBaoRZylzen6krEmxXJgt9Ju6HiI4O7BA=="
},
"for-in": {
"version": "1.0.2",
......
class Utils {
export class EloUtility {
static getExpScore(
expA: number,
expB: number,
......
import {Body, Controller, Get, Post, Query, Res} from '@nestjs/common';
import { Body, Controller, Get, Post, Query, Res } from '@nestjs/common';
import express from 'express';
import { AppService } from './app.service';
import { UserInfo } from './entities/mycard/UserInfo';
import { config } from './config';
@Controller('api')
export class AppController {
constructor(private readonly appService: AppService) {}
@Post('score')
async postScore(
@Body() body: any,
@Body('accesskey') accessKey,
@Res() res: express.Response,
) {
if (accessKey !== config.accessKey) {
return res.status(403).json({
msg: 'accesskey error',
});
}
const message = await this.appService.postScore(body);
if (message) {
res.status(404).json({
msg: message,
});
} else {
res.json({
msg: 'success',
});
}
}
@Get('users')
async getUsers(@Query('o') orderByWhat: string) {
return await this.appService.getUsersRaw(orderByWhat === 'pt');
......@@ -41,6 +65,6 @@ export class AppController {
@Post('activity')
async updateActivity(@Body() body: any) {
return await this.updateActivity(body);
return await this.appService.updateActivity(body);
}
}
import { Injectable, Scope, Logger } from '@nestjs/common';
import moment from 'moment';
@Injectable()
export class AppLogger extends Logger {}
export class AppLogger extends Logger {
private combineStrings(args: any[]) {
const strings = args.map((arg) => {
if (typeof arg === 'string') {
return arg;
}
return arg.toString() as string;
});
const combinedString = strings.join(' ');
return combinedString;
}
compatLog(...args) {
return this.log(this.combineStrings(args));
}
compatWarn(...args) {
return this.warn(this.combineStrings(args));
}
compatError(...args) {
return this.error(this.combineStrings(args));
}
compatDebug(...args) {
return this.debug(this.combineStrings(args));
}
}
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment