12 changed files with 170 additions and 2460 deletions
File diff suppressed because it is too large
@ -0,0 +1,18 @@ |
|||
import { Test, TestingModule } from '@nestjs/testing'; |
|||
import { RacesController } from './races.controller'; |
|||
|
|||
describe('RacesController', () => { |
|||
let controller: RacesController; |
|||
|
|||
beforeEach(async () => { |
|||
const module: TestingModule = await Test.createTestingModule({ |
|||
controllers: [RacesController], |
|||
}).compile(); |
|||
|
|||
controller = module.get<RacesController>(RacesController); |
|||
}); |
|||
|
|||
it('should be defined', () => { |
|||
expect(controller).toBeDefined(); |
|||
}); |
|||
}); |
|||
@ -0,0 +1,27 @@ |
|||
import { Controller, Get, Param } from '@nestjs/common'; |
|||
import { from } from 'rxjs'; |
|||
import * as TMIO from 'trackmania.io'; |
|||
|
|||
@Controller('races') |
|||
export class RacesController { |
|||
TMIO: any; |
|||
|
|||
constructor() { |
|||
this.TMIO = new TMIO.Client(); |
|||
} |
|||
|
|||
@Get('/map/:id') |
|||
findOne(@Param() params: any) { |
|||
let promise = new Promise((resolve, reject) => { |
|||
try{ |
|||
this.TMIO.maps.get(params.id).then(async mapInfo => { |
|||
console.log(mapInfo); |
|||
resolve(mapInfo._data); |
|||
}); |
|||
} catch (error) { |
|||
reject(error); |
|||
} |
|||
}); |
|||
return from(promise); |
|||
} |
|||
} |
|||
@ -0,0 +1,3 @@ |
|||
.img-thumbnail { |
|||
max-width: 12rem; |
|||
} |
|||
Loading…
Reference in new issue