From 85f28115cf355e04ca8891c088a0ceeaf630369e Mon Sep 17 00:00:00 2001
From: alekswilc
Date: Sat, 9 Nov 2024 00:04:05 +0100
Subject: [PATCH] feat(backend): preview version
---
packages/backend/src/http/routes/stations.ts | 23 ----
packages/backend/src/http/routes/trains.ts | 70 ----------
packages/backend/src/http/server.ts | 29 ++--
.../src/http/views/_modules/footer.ejs | 16 ---
.../src/http/views/_modules/header.ejs | 14 --
packages/backend/src/http/views/home.ejs | 125 ------------------
.../src/http/views/leaderboard/index.ejs | 86 ------------
.../src/http/views/leaderboard/station.ejs | 9 --
.../src/http/views/leaderboard/train.ejs | 11 --
.../backend/src/http/views/profiles/index.ejs | 123 -----------------
.../src/http/views/profiles/private.ejs | 47 -------
.../src/http/views/stations/details.ejs | 91 -------------
.../backend/src/http/views/stations/index.ejs | 98 --------------
.../backend/src/http/views/trains/details.ejs | 102 --------------
.../backend/src/http/views/trains/index.ejs | 104 ---------------
packages/backend/src/index.ts | 2 +-
packages/backend/src/modules/stations.ts | 6 +-
packages/backend/src/modules/trains.ts | 9 +-
packages/backend/src/types/typings.d.ts | 1 -
packages/backend/src/util/time.ts | 2 +-
20 files changed, 19 insertions(+), 949 deletions(-)
delete mode 100644 packages/backend/src/http/views/_modules/footer.ejs
delete mode 100644 packages/backend/src/http/views/_modules/header.ejs
delete mode 100644 packages/backend/src/http/views/home.ejs
delete mode 100644 packages/backend/src/http/views/leaderboard/index.ejs
delete mode 100644 packages/backend/src/http/views/leaderboard/station.ejs
delete mode 100644 packages/backend/src/http/views/leaderboard/train.ejs
delete mode 100644 packages/backend/src/http/views/profiles/index.ejs
delete mode 100644 packages/backend/src/http/views/profiles/private.ejs
delete mode 100644 packages/backend/src/http/views/stations/details.ejs
delete mode 100644 packages/backend/src/http/views/stations/index.ejs
delete mode 100644 packages/backend/src/http/views/trains/details.ejs
delete mode 100644 packages/backend/src/http/views/trains/index.ejs
diff --git a/packages/backend/src/http/routes/stations.ts b/packages/backend/src/http/routes/stations.ts
index 06b0f3a..53f1a37 100644
--- a/packages/backend/src/http/routes/stations.ts
+++ b/packages/backend/src/http/routes/stations.ts
@@ -59,29 +59,6 @@ export class StationsRoute
);
});
- app.get("/details/:id", async (req, res) =>
- {
- if (!req.params.id)
- {
- return res.redirect("/stations/");
- }
- const record = await MLog.findOne({ id: req.params.id });
- const blacklist = await MBlacklist.findOne({ steam: record?.userSteamId! });
- if (blacklist && blacklist.status)
- {
- return res.redirect("/stations/");
- }
- const player = await SteamUtil.getPlayer(record?.userSteamId!);
-
- res.render("stations/details.ejs", {
- record,
- dayjs,
- player,
- msToTime,
- ...GitUtil.getData()
- });
- });
-
return app;
}
}
\ No newline at end of file
diff --git a/packages/backend/src/http/routes/trains.ts b/packages/backend/src/http/routes/trains.ts
index 53a23e7..d9accc1 100644
--- a/packages/backend/src/http/routes/trains.ts
+++ b/packages/backend/src/http/routes/trains.ts
@@ -56,78 +56,8 @@ export class TrainsRoute
.setData({ records: records.map(x => removeProperties>(x, [ "_id", "__v" ])) })
.toJSON(),
);
-
- // res.render('trains/index.ejs', {
- // records,
- // dayjs,
- // q: req.query.q,
- // msToTime,
- // ...GitUtil.getData()
- // });
});
- app.get("/details/:id", async (req, res) =>
- {
- if (!req.params.id)
- {
- return res.redirect("/trains/");
- }
- const record = await MTrainLog.findOne({ id: req.params.id });
- const player = await SteamUtil.getPlayer(record?.userSteamId!);
- const blacklist = await MBlacklist.findOne({ steam: record?.userSteamId! });
- if (blacklist && blacklist.status)
- {
- return res.redirect("/trains/");
- }
-
- res.render("trains/details.ejs", {
- record,
- dayjs,
- player,
- msToTime,
- ...GitUtil.getData(),
- });
- });
-
- app.get("/leaderboard/", async (req, res) =>
- {
- const s = req.query.q?.toString().split(",").map(x => new RegExp(x, "i"));
-
- const data = Object.keys(raw_schema)
- .reduce((o, key) => ({ ...o, [ key ]: `$${ key }` }), {});
-
- const filter: PipelineStage[] = [
- {
- $project: {
- // record.leftDate - record.joinedDate
- result: { $subtract: [ "$leftDate", "$joinedDate" ] },
- ...data,
- },
- },
- ];
-
- s && filter.unshift(
- {
- $match: {
- $and: [
- ...s.map(x => ({ $or: generateSearch(x) })),
- ],
- },
- },
- );
-
-
- const records = await MTrainLog.aggregate(filter)
- .sort({ result: -1 })
- .limit(30);
- res.render("trains/leaderboard.ejs", {
- records,
- dayjs,
- q: req.query.q,
- msToTime
- });
- })
-
return app;
}
}
\ No newline at end of file
diff --git a/packages/backend/src/http/server.ts b/packages/backend/src/http/server.ts
index 98aa045..1cacefd 100644
--- a/packages/backend/src/http/server.ts
+++ b/packages/backend/src/http/server.ts
@@ -1,39 +1,30 @@
-import express from "express";
+import express, { Router } from "express";
import { fileURLToPath } from "node:url";
import path from "node:path";
import { StationsRoute } from "./routes/stations.js";
import { TrainsRoute } from "./routes/trains.js";
import { ProfilesRoute } from "./routes/profile.js";
import { LeaderboardRoute } from "./routes/leaderboard.js";
-import { MProfile } from "../mongo/profile.js";
-import { GitUtil } from "../util/git.js";
import cors from "cors";
import { StatsRoute } from "./routes/stats.js";
import { LogRoute } from "./routes/log.js";
-const __filename = fileURLToPath(import.meta.url);
-const __dirname = path.dirname(__filename);
-
-
export class ApiModule
{
public static load()
{
const app = express();
-
- app.set("view engine", "ejs");
- app.set("views", __dirname + "/views");
- app.get("/", (_, res) => res.render("home", GitUtil.getData()));
app.use(cors());
- // backward compatible
- app.get("/details/:id", (req, res) => res.redirect("/stations/details/" + req.params.id));
- app.use("/stations/", StationsRoute.load());
- app.use("/trains/", TrainsRoute.load());
- app.use("/profiles/", ProfilesRoute.load());
- app.use("/leaderboard/", LeaderboardRoute.load());
- app.use("/stats/", StatsRoute.load());
- app.use("/log/", LogRoute.load());
+ const router = Router();
+ router.use("/stations/", StationsRoute.load());
+ router.use("/trains/", TrainsRoute.load());
+ router.use("/profiles/", ProfilesRoute.load());
+ router.use("/leaderboard/", LeaderboardRoute.load());
+ router.use("/stats/", StatsRoute.load());
+ router.use("/log/", LogRoute.load());
+
+ app.use("/api/v1", router);
app.listen(2005);
}
diff --git a/packages/backend/src/http/views/_modules/footer.ejs b/packages/backend/src/http/views/_modules/footer.ejs
deleted file mode 100644
index 3ab5565..0000000
--- a/packages/backend/src/http/views/_modules/footer.ejs
+++ /dev/null
@@ -1,16 +0,0 @@
-
\ No newline at end of file
diff --git a/packages/backend/src/http/views/_modules/header.ejs b/packages/backend/src/http/views/_modules/header.ejs
deleted file mode 100644
index 1fd5f1e..0000000
--- a/packages/backend/src/http/views/_modules/header.ejs
+++ /dev/null
@@ -1,14 +0,0 @@
-
\ No newline at end of file
diff --git a/packages/backend/src/http/views/home.ejs b/packages/backend/src/http/views/home.ejs
deleted file mode 100644
index c1c5464..0000000
--- a/packages/backend/src/http/views/home.ejs
+++ /dev/null
@@ -1,125 +0,0 @@
-
-
-
-
-
-
- simrail.alekswilc.dev
-
-
-
-
-
-
-
-
-
-
-
-
-<%- include('_modules/header.ejs', { section:'home' }) %>
-
-Prosty projekt, logujący wyjścia z posterunków.
-Cele projektu
-Główne założenia
-
-
-Rozwój aplikacji
-Planowane funkcjonalności
-
-
- Nowy wygląd aplikacji
-
-
-
-Podziękowania dla
-
- Społeczności discorda Simrail24
- AQUALYTH
- osób lajkujących posta
-
- osób użytkujących strone
- Społeczności SimRail ❤️
-
-
-Informacje dodatkowe
-
-
- Zgłaszanie błędów i propozycji
-
-
- Zgłaszanie błedów
-
- Otwórz https://git.alekswilc.dev/alekswilc/simrail-logs/issues
-
- Zaloguj się (np poprzez Discorda)
- Naciśnij przycisk "New issue" ("Nowe zgłoszenie")
- W tytule napisz krótki opis (np. Problem z wyświetleniem strony)
- Opisz problem (kiedy występuje, podaj linki, postaraj sie napisać jak moge odtworzyć ten błąd, jak
- powinna zachowywać sie aplikacja bez tego błędu)
-
- Poczekaj na informacje z mojej strony
- Dziekuje :)
-
-
-
-
-
- Zgłaszanie propozycji
-
- Otwórz https://git.alekswilc.dev/alekswilc/simrail-logs/issues
-
- Zaloguj się (np poprzez Discorda)
- Naciśnij przycisk "New issue" ("Nowe zgłoszenie")
- W tytule napisz krótki opis (np. Logi wejścia i wyjścia z pociągów)
- Opisz propozycje (dokładnie co z dyżurkami ale dla pociągów)
- Poczekaj na informacje z mojej strony
- Dziekuje :)
-
-
-
-
-
-
-Licencja
-
-
- Copyright (C) 2024 Aleksander
- Wilczyński
-
-
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as
- published by the Free Software Foundation, either version 3 of the
- License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see https://www.gnu.org/licenses/.
-
-
-
-<%- include('_modules/footer.ejs', { thanks: true, version, commit }) %>
-
-
-
-
-
\ No newline at end of file
diff --git a/packages/backend/src/http/views/leaderboard/index.ejs b/packages/backend/src/http/views/leaderboard/index.ejs
deleted file mode 100644
index 8c194e2..0000000
--- a/packages/backend/src/http/views/leaderboard/index.ejs
+++ /dev/null
@@ -1,86 +0,0 @@
-
-
-
-
-
-
- simrail.alekswilc.dev
-
-
-
-
-
-
-
-
-
-
-
-
-
-<%- include('../_modules/header.ejs', { section: 'leaderboard' }) %>
-
-Tablica wyników
-
-
-
-
Szukaj
-
Wyczyść
-
-
Użyj przecinka, aby wyszukać wiele wartości: pl2,Łazy
-
-
-
-
- <% records.forEach(record=> { %>
-
- <%- type === 'train' ? include('train.ejs', { record, msToTime }) : include('station.ejs', { record, msToTime }) %>
-
- <% }) %>
-
-
-<% if (!records.length) { %>
-Nie znaleziono wyników dla twojego zapytania.
-<% } %>
-
-
-
-
-Dane do rankingu zbierane są od dnia 19.08.2024.
-
-<%- include('../_modules/footer.ejs', { thanks: false, version, commit }) %>
-
-
-
\ No newline at end of file
diff --git a/packages/backend/src/http/views/leaderboard/station.ejs b/packages/backend/src/http/views/leaderboard/station.ejs
deleted file mode 100644
index 0aaaf6d..0000000
--- a/packages/backend/src/http/views/leaderboard/station.ejs
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
- <%= record.steamName %>
-
- <%= msToTime(record.dispatcherTime) %>
-
- Spędzona liczba godzin: <%= msToTime(record.dispatcherTime, true) || 'Brak' %>
- Więcej
-
\ No newline at end of file
diff --git a/packages/backend/src/http/views/leaderboard/train.ejs b/packages/backend/src/http/views/leaderboard/train.ejs
deleted file mode 100644
index 03d7828..0000000
--- a/packages/backend/src/http/views/leaderboard/train.ejs
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
- <%= record.steamName %>
- -
- <%= record.trainPoints %> pkt.
-
- Spędzona liczba godzin: <%= msToTime(record.trainTime, true) %>
- Przejechane kilometry: <%= record.trainDistance / 1000 %>km
- Zdobyte punkty: <%= record.trainPoints %>
- Więcej
-
\ No newline at end of file
diff --git a/packages/backend/src/http/views/profiles/index.ejs b/packages/backend/src/http/views/profiles/index.ejs
deleted file mode 100644
index 0046021..0000000
--- a/packages/backend/src/http/views/profiles/index.ejs
+++ /dev/null
@@ -1,123 +0,0 @@
-
-
-
-
-
-
- simrail.alekswilc.dev
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-<%- include('../_modules/header.ejs', { section: 'profiles' }) %>
-
-
-
-
- <% if (steamStats.stats) { %>
-
- Statystyki Steam
- Zdobyte punkty: <%- steamStats.stats.find(x => x.name === 'SCORE')?.value ?? "0" %>
- Przejechane
- kilometry: <%- (steamStats.stats.find(x => x.name === 'DISTANCE_M')?.value / 1000) ?? "0" %>
- Czas spędzony jako dyżurny
- ruchu: <%- msToTime((steamStats.stats.find(x => x.name === 'DISPATCHER_TIME')?.value ?? 0) * 1_000_000, true) || 'Nigdy nie wszedł w tryb dyżurnego ruchu.' %>
-
- UWAGA: powyższe statystyki udostępnia platforma STEAM, mogą one być z
- łatwością manipulowane.
-
-
- <% } %>
-
-
Statystyki pociągów
- <% if (player.trainTime) { %>
-
Spędzony czas: <%- msToTime(player.trainTime) %>
-
Przejechane kilometry: <%- player.trainDistance / 1000 %>km
-
Zdobyte punkty: <%- player.trainPoints %>
-
Średnia prędkość: <%- ((player.trainDistance / (player.trainTime / 1000)) * 3.6).toFixed(2) %> km/h
- <% } %>
- <% if (player.trainStats && Object.keys(player.trainStats).length) { %>
-
- <% Object.keys(player.trainStats).forEach(name => { %>
-
-
- <%- name %>
- Przejechany dystans: <%- player.trainStats[ name ].distance / 1000 %>km
- Spędzony czas: <%- msToTime(player.trainStats[ name ].time, true) %>
- Zdobyte punkty: <%- player.trainStats[ name ].score %>
- Średnia
- prędkość: <%- ((player.trainStats[ name ].distance / (player.trainStats[ name ].time / 1000)) * 3.6).toFixed(2) %>
- km/h
-
-
-
- <% }) %>
-
- <% } else { %>
-
Brak danych
- <% } %>
-
-
Statystyki posterunków
- <% if (player.dispatcherTime) { %>
-
Spędzony czas: <%- msToTime(player.dispatcherTime) %>
- <% } %>
- <% if (player.dispatcherStats && Object.keys(player.dispatcherStats).length) { %>
-
- <% Object.keys(player.dispatcherStats).forEach(name => { %>
-
-
- <%- name %>
- Spędzony czas: <%- msToTime(player.dispatcherStats[ name ].time, true) %>
-
-
-
- <% }) %>
-
- <% } else { %>
-
Brak danych
- <% } %>
-
-
-
- Kopiuj link
-
-
-
-Dane do rankingu zbierane są od dnia 19.08.2024.
-<%- include('../_modules/footer.ejs', { thanks: false, version, commit }) %>
-
-
-
-
\ No newline at end of file
diff --git a/packages/backend/src/http/views/profiles/private.ejs b/packages/backend/src/http/views/profiles/private.ejs
deleted file mode 100644
index da89871..0000000
--- a/packages/backend/src/http/views/profiles/private.ejs
+++ /dev/null
@@ -1,47 +0,0 @@
-
-
-
-
-
-
- simrail.alekswilc.dev
-
-
-
-
-
-
-
-
-
-
-
-
-
-<%- include('../_modules/header.ejs', { section: 'profiles' }) %>
-
-
-
Profil gracza jest prywatny.
-
-
-
-<%- include('../_modules/footer.ejs', { thanks: false, version, commit }) %>
-
-
-
-
\ No newline at end of file
diff --git a/packages/backend/src/http/views/stations/details.ejs b/packages/backend/src/http/views/stations/details.ejs
deleted file mode 100644
index 40581c1..0000000
--- a/packages/backend/src/http/views/stations/details.ejs
+++ /dev/null
@@ -1,91 +0,0 @@
-
-
-
-
-
-
- simrail.alekswilc.dev
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-<%- include('../_modules/header.ejs', { section: 'stations' }) %>
-
-
-
-
Użytkownik:
- <%- record.userUsername %>
-
-
Stacja: <%- record.stationName %>
-
-
Serwer: <%- record.server.toUpperCase() %>
-
-
Data wejścia: <%- record.joinedDate ? dayjs(record.joinedDate).format('HH:mm DD/MM/YYYY') : '--:-- --/--/--'
- %> (<%- record.joinedDate ? dayjs(record.joinedDate).fromNow() : '--' %>)
-
Data wyjścia: <%- dayjs(record.leftDate).format('HH:mm DD/MM/YYYY') %> (<%- dayjs(record.leftDate).fromNow()
- %>)
-
Spędzony czas: <%- record.joinedDate ? msToTime(record.leftDate - record.joinedDate, true) : '--' %>
-
-
-
-
;station: <%- record.stationName %>
- ;steam: <%- record.userSteamId %>
- ;server: <%- record.server %>
- ;name: <%- record.userUsername %>
- ;joined: <%- record.joinedDate ? dayjs(record.joinedDate).format() : 'no-data' %>
- ;left: <%- dayjs(record.leftDate).format() %>
- ;url: https://simrail.alekswilc.dev/stations/details/<%- record.id %>/
-
-
-
- Kopiuj link
-
-
-
-
-
-<%- include('../_modules/footer.ejs', { thanks: false, version, commit }) %>
-
-
-
-
\ No newline at end of file
diff --git a/packages/backend/src/http/views/stations/index.ejs b/packages/backend/src/http/views/stations/index.ejs
deleted file mode 100644
index 4999faa..0000000
--- a/packages/backend/src/http/views/stations/index.ejs
+++ /dev/null
@@ -1,98 +0,0 @@
-
-
-
-
-
-
- simrail.alekswilc.dev
-
-
-
-
-
-
-
-
-
-
-
-
-<%- include('../_modules/header.ejs', { section: 'stations' }) %>
-
-Wyszukaj posterunek, osobe lub serwer
-
-
-
-
Szukaj
-
Wyczyść
-
-
Użyj przecinka, aby wyszukać wiele wartości: pl2,Łazy
-
-
-
- <% records.forEach(record=> { %>
-
-
- [
- <%- record.server.toUpperCase() %>
- ]
- <%- record.stationName %>
- -
- <%- record.userUsername %>
-
-
- <%- dayjs(record.leftDate).format('HH:mm DD/MM/YYYY') %>
-
-
- Data dołączenia: <%- record.joinedDate ? dayjs(record.joinedDate).format('HH:mm DD/MM/YYYY')
- : '--:-- --/--/--' %> (<%- record.joinedDate ? dayjs(record.joinedDate).fromNow() : '--' %>)
-
- Data wyjścia: <%- dayjs(record.leftDate).format('HH:mm DD/MM/YYYY') %> (<%-
- dayjs(record.leftDate).fromNow() %>)
- Spędzony czas: <%- record.joinedDate ? msToTime(record.leftDate - record.joinedDate) : '--' %>
-
-
-
- Więcej
-
-
-
- <% }) %>
-
-
-<% if (!records.length) { %>
-Nie znaleziono wyników dla twojego zapytania.
-<% } %>
-
-
-<%- include('../_modules/footer.ejs', { thanks: false, version, commit }) %>
-
-
-
-
-
-
\ No newline at end of file
diff --git a/packages/backend/src/http/views/trains/details.ejs b/packages/backend/src/http/views/trains/details.ejs
deleted file mode 100644
index 60bda2c..0000000
--- a/packages/backend/src/http/views/trains/details.ejs
+++ /dev/null
@@ -1,102 +0,0 @@
-
-
-
-
-
-
- simrail.alekswilc.dev
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-<%- include('../_modules/header.ejs', { section: 'trains' }) %>
-
-
-
-
Użytkownik:
- <%- record.userUsername %>
-
-
-
Pociąg: <%- record.trainName %> <%- record.trainNumber %>
-
-
Data wejścia: <%- record.joinedDate ? dayjs(record.joinedDate).format('HH:mm DD/MM/YYYY') : '--:-- --/--/--'
- %> (<%- record.joinedDate ? dayjs(record.joinedDate).fromNow() : '--' %>)
-
Data wyjścia: <%- dayjs(record.leftDate).format('HH:mm DD/MM/YYYY') %> (<%- dayjs(record.leftDate).fromNow()
- %>)
-
Spędzony czas: <%- record.joinedDate ? msToTime(record.leftDate - record.joinedDate, true) : '--' %>
-
- <% if (record.distance) { %>
-
Przejechane kilometry: <%- record.distance / 1000 %>
-
Zdobyte punkty: <%- record.points %>
-
Średnia
- prędkość: <%- ((record.distance / ((record.leftDate - record.joinedDate) / 1000)) * 3.6).toFixed(2) %>
- km/h
- <% } %>
-
-
-
-
;train: <%- record.trainNumber %>
- ;steam: <%- record.userSteamId %>
- ;server: <%- record.server %>
- ;name: <%- record.userUsername %>
- ;joined: <%- record.joinedDate ? dayjs(record.joinedDate).format() : 'no-data' %>
- ;left: <%- dayjs(record.leftDate).format() %>
- <% if (record.distance) { %>
- ;distance: <%- record.distance / 1000 %>
- ;points: <%- record.points %>
- <% } %>
- ;url: https://simrail.alekswilc.dev/trains/details/<%- record.id %>/
-
-
-
- Kopiuj link
-
-
-
-
-
-<%- include('../_modules/footer.ejs', { thanks: false, version, commit }) %>
-
-
-
-
\ No newline at end of file
diff --git a/packages/backend/src/http/views/trains/index.ejs b/packages/backend/src/http/views/trains/index.ejs
deleted file mode 100644
index ad5323a..0000000
--- a/packages/backend/src/http/views/trains/index.ejs
+++ /dev/null
@@ -1,104 +0,0 @@
-
-
-
-
-
-
- simrail.alekswilc.dev
-
-
-
-
-
-
-
-
-
-
-
-
-<%- include('../_modules/header.ejs', { section: 'trains' }) %>
-
-Wyszukaj pociąg, osobe lub serwer
-
-
-
-
Szukaj
-
Wyczyść
-
-
Użyj przecinka, aby wyszukać wiele wartości: pl2,1413
-
-
-
- <% records.forEach(record=> { %>
-
-
- [
- <%- record.server.toUpperCase() %>
- ]
- <%- record.trainName %>
- -
- <%- record.trainNumber %>
- -
- <%- record.userUsername %>
-
-
- <%- dayjs(record.leftDate).format('HH:mm DD/MM/YYYY') %>
-
-
- Data dołączenia: <%- record.joinedDate ? dayjs(record.joinedDate).format('HH:mm DD/MM/YYYY')
- : '--:-- --/--/--' %> (<%- record.joinedDate ? dayjs(record.joinedDate).fromNow() : '--' %>)
-
- Data wyjścia: <%- dayjs(record.leftDate).format('HH:mm DD/MM/YYYY') %> (<%-
- dayjs(record.leftDate).fromNow() %>)
- Spędzony czas: <%- record.joinedDate ? msToTime(record.leftDate - record.joinedDate) : '--' %>
- <% if (record.distance) { %>
-
Przejechane kilometry: <%- record.distance / 1000 %>
- Zdobyte punkty: <%- record.points %>
- <% } %>
-
-
-
- Więcej
-
-
-
- <% }) %>
-
-
-<% if (!records.length) { %>
-Nie znaleziono wyników dla twojego zapytania.
-<% } %>
-
-
-<%- include('../_modules/footer.ejs', { thanks: false, version, commit }) %>
-
-
-
-
-
-
\ No newline at end of file
diff --git a/packages/backend/src/index.ts b/packages/backend/src/index.ts
index dd60faf..4a50c78 100644
--- a/packages/backend/src/index.ts
+++ b/packages/backend/src/index.ts
@@ -29,7 +29,7 @@ import dayjs from "dayjs";
StationsModule.load();
TrainsModule.load();
}
-
+
ApiModule.load(); // TODO: use fastify
if (process.env.NODE_ENV === "development")
diff --git a/packages/backend/src/modules/stations.ts b/packages/backend/src/modules/stations.ts
index 3753777..10ced48 100644
--- a/packages/backend/src/modules/stations.ts
+++ b/packages/backend/src/modules/stations.ts
@@ -51,7 +51,7 @@ export class StationsModule
await MProfile.findOneAndUpdate({ id: userProfile.id }, { dispatcherStats: userProfile.dispatcherStats, dispatcherTime: userProfile.dispatcherTime });
}
- MLog.create({
+ await MLog.create({
id: v4(),
userSteamId: player.steamid,
userAvatar: player.avatarfull,
@@ -60,8 +60,8 @@ export class StationsModule
leftDate: date.getTime(),
stationName: station.Name,
stationShort: station.Prefix,
- server: server.ServerCode
+ server: server.ServerCode,
});
- })
+ });
}
}
\ No newline at end of file
diff --git a/packages/backend/src/modules/trains.ts b/packages/backend/src/modules/trains.ts
index f933ec1..14b8cfa 100644
--- a/packages/backend/src/modules/trains.ts
+++ b/packages/backend/src/modules/trains.ts
@@ -1,5 +1,4 @@
-import { Server, Station, Train } from "@simrail/types";
-import { MLog } from "../mongo/logs.js";
+import { Server, Train } from "@simrail/types";
import { IPlayer } from "../types/player.js";
import { SimrailClientEvents } from "../util/SimrailClient.js";
import { v4 } from "uuid";
@@ -63,7 +62,7 @@ export class TrainsModule
await MProfile.findOneAndUpdate({ id: userProfile.id }, { trainStats: userProfile.trainStats, trainTime: userProfile.trainTime, trainPoints: userProfile.trainPoints, trainDistance: userProfile.trainDistance });
}
- MTrainLog.create({
+ await MTrainLog.create({
id: v4(),
userSteamId: player.steamid,
userAvatar: player.avatarfull,
@@ -73,8 +72,8 @@ export class TrainsModule
trainNumber: train.TrainNoLocal,
server: server.ServerCode,
distance, points,
- trainName: train.TrainName
+ trainName: train.TrainName,
});
- })
+ });
}
}
\ No newline at end of file
diff --git a/packages/backend/src/types/typings.d.ts b/packages/backend/src/types/typings.d.ts
index 59cc21f..108c47e 100644
--- a/packages/backend/src/types/typings.d.ts
+++ b/packages/backend/src/types/typings.d.ts
@@ -5,5 +5,4 @@ declare global
{
declare var redis: RedisClientType,
client: SimrailClient;
-
}
\ No newline at end of file
diff --git a/packages/backend/src/util/time.ts b/packages/backend/src/util/time.ts
index 7bade90..47da178 100644
--- a/packages/backend/src/util/time.ts
+++ b/packages/backend/src/util/time.ts
@@ -19,4 +19,4 @@ export const msToTime = (duration: number, long = false) =>
}
return time.humanize();
-}
\ No newline at end of file
+};
\ No newline at end of file