forked from noxious/server
More cache stuff
This commit is contained in:
@ -5,8 +5,28 @@ import MapObjectRepository from '#repositories/mapObjectRepository'
|
||||
import MapRepository from '#repositories/mapRepository'
|
||||
import SpriteRepository from '#repositories/spriteRepository'
|
||||
import TileRepository from '#repositories/tileRepository'
|
||||
import CharacterHairRepository from '#repositories/characterHairRepository'
|
||||
import CharacterTypeRepository from '#repositories/characterTypeRepository'
|
||||
|
||||
export class CacheController extends BaseController {
|
||||
/**
|
||||
* Serve a list of tiles and send as JSON
|
||||
* @param req
|
||||
* @param res
|
||||
*/
|
||||
public async tiles(req: Request, res: Response) {
|
||||
const items: any[] = []
|
||||
|
||||
const tileRepository = new TileRepository()
|
||||
const tiles = await tileRepository.getAll()
|
||||
|
||||
for (const tile of tiles) {
|
||||
items.push(await tile.cache())
|
||||
}
|
||||
|
||||
return this.sendSuccess(res, items)
|
||||
}
|
||||
|
||||
/**
|
||||
* Serve a list of maps and send as JSON
|
||||
* @param req
|
||||
@ -42,4 +62,58 @@ export class CacheController extends BaseController {
|
||||
|
||||
return this.sendSuccess(res, items)
|
||||
}
|
||||
|
||||
/**
|
||||
* Serve a list of character hairs and send as JSON
|
||||
* @param req
|
||||
* @param res
|
||||
*/
|
||||
public async characterHair(req: Request, res: Response) {
|
||||
const items: any[] = []
|
||||
|
||||
const characterHairRepository = new CharacterHairRepository()
|
||||
const characterHairs = await characterHairRepository.getAll()
|
||||
|
||||
for (const characterHair of characterHairs) {
|
||||
items.push(await characterHair.cache())
|
||||
}
|
||||
|
||||
return this.sendSuccess(res, items)
|
||||
}
|
||||
|
||||
/**
|
||||
* Serve a list of character types and send as JSON
|
||||
* @param req
|
||||
* @param res
|
||||
*/
|
||||
public async characterTypes(req: Request, res: Response) {
|
||||
const items: any[] = []
|
||||
|
||||
const characterTypeRepository = new CharacterTypeRepository()
|
||||
const characterTypes = await characterTypeRepository.getAll()
|
||||
|
||||
for (const characterType of characterTypes) {
|
||||
items.push(await characterType.cache())
|
||||
}
|
||||
|
||||
return this.sendSuccess(res, items)
|
||||
}
|
||||
|
||||
/**
|
||||
* Serve a list of sprites and send as JSON
|
||||
* @param req
|
||||
* @param res
|
||||
*/
|
||||
public async sprites(req: Request, res: Response) {
|
||||
const items: any[] = []
|
||||
|
||||
const spriteRepository = new SpriteRepository()
|
||||
const sprites = await spriteRepository.getAll()
|
||||
|
||||
for (const sprite of sprites) {
|
||||
items.push(await sprite.cache())
|
||||
}
|
||||
|
||||
return this.sendSuccess(res, items)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user