overhaul using augmented-ui
[browser-rts.git] / src / api.ts
index 75fa346f9b26c7c5a6327646c204a00c93479423..e5e155758823d74a42fdd6275c768254ccaf6714 100644 (file)
@@ -64,33 +64,6 @@ server.post<{body: {username: string, password: string}}, void>('/login', async
 
 });
 
-server.get<{}, string>('/city', async req => {
-       const account = await accountRepo.validate(req.authInfo.accountId, req.authInfo.token);
-       const city = await cityRepo.FindOne({ owner: account.id });
-
-
-       const buildQueues = await cityRepo.getBuildQueues(account.id);
-       const unitTrainingQueues = await cityRepo.getUnitTrainingQueues(account.id);
-
-       const buildings = await cityRepo.buildingRepository.list();
-       const units = await cityRepo.unitRepository.list();
-
-       let html = `
-       <h2>Kingom Overview</h2>
-       ${renderKingomOverview(city, account)}
-       <hr>
-       <h2>Land Development</h2>
-       ${renderLandDevelopment(city, buildings, buildQueues)}
-       <h2>Unit Training</h2>
-       ${renderUnitTraining(city, units, unitTrainingQueues)},
-       <h2>Map</h2>
-       ${renderOverworldMap(await cityRepo.FindAll(), city)}
-       <h2>Mail</h2>
-       ${renderMailroom(await mailRepo.listReceivedMessages(account.id))}
-       `;
-       return html;
-});
-
 server.post<{body: {
        soldiers: number,
        attackers: number,
@@ -125,7 +98,7 @@ server.get<{}, string>('/poll/overview', async req => {
        return renderKingomOverview(city, account);
 });
 
-server.get<{}, string>('/queue/construction', async req => {
+server.get<{}, string>('/poll/construction', async req => {
        const account = await accountRepo.validate(req.authInfo.accountId, req.authInfo.token);
        const city = await cityRepo.FindOne({ owner: account.id });
        const buildings = await cityRepo.buildingRepository.list();
@@ -134,7 +107,7 @@ server.get<{}, string>('/queue/construction', async req => {
        return renderLandDevelopment(city, buildings, buildQueues);
 });
 
-server.get<{}, string>('/queue/units', async req => {
+server.get<{}, string>('/poll/unit-training', async req => {
        const account = await accountRepo.validate(req.authInfo.accountId, req.authInfo.token);
        const city = await cityRepo.FindOne({ owner: account.id });
 
@@ -144,6 +117,19 @@ server.get<{}, string>('/queue/units', async req => {
        return renderUnitTraining(city, units, unitTrainingQueues);
 });
 
+server.get<{}, string>('/poll/map', async req => {
+       const account = await accountRepo.validate(req.authInfo.accountId, req.authInfo.token);
+       const city = await cityRepo.FindOne({ owner: account.id });
+
+       return renderOverworldMap(await cityRepo.FindAll(), city);
+});
+
+server.get<{}, string>('/poll/mailroom', async req => {
+       const account = await accountRepo.validate(req.authInfo.accountId, req.authInfo.token);
+
+       return renderMailroom(await mailRepo.listReceivedMessages(account.id));
+});
+
 
 server.post<{
        body: {