fix(): fix images in profile & log. small backend change related to profile, logs imgproxy and gitutil.
This commit is contained in:
parent
895725dc66
commit
608894ee1e
7
.idea/copyright/profiles_settings.xml
generated
Normal file
7
.idea/copyright/profiles_settings.xml
generated
Normal file
@ -0,0 +1,7 @@
|
||||
<component name="CopyrightManager">
|
||||
<settings default="gnu agpl alekswilc">
|
||||
<module2copyright>
|
||||
<element module="Project Files" copyright="gnu agpl alekswilc" />
|
||||
</module2copyright>
|
||||
</settings>
|
||||
</component>
|
10
.idea/inspectionProfiles/Project_Default.xml
generated
Normal file
10
.idea/inspectionProfiles/Project_Default.xml
generated
Normal file
@ -0,0 +1,10 @@
|
||||
<component name="InspectionProjectProfileManager">
|
||||
<profile version="1.0">
|
||||
<option name="myName" value="Project Default" />
|
||||
<inspection_tool class="DuplicatedCode" enabled="true" level="WEAK WARNING" enabled_by_default="true">
|
||||
<Languages>
|
||||
<language minSize="457" name="TypeScript" />
|
||||
</Languages>
|
||||
</inspection_tool>
|
||||
</profile>
|
||||
</component>
|
6
.idea/jsLibraryMappings.xml
generated
Normal file
6
.idea/jsLibraryMappings.xml
generated
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="JavaScriptLibraryMappings">
|
||||
<file url="file://$PROJECT_DIR$/packages/frontend" libraries="{script}" />
|
||||
</component>
|
||||
</project>
|
@ -64,7 +64,7 @@ export class LogRoute
|
||||
|
||||
if (process.env.IMGPROXY_KEY)
|
||||
{
|
||||
log.player.avatar = generateUrl(log.player.avatar);
|
||||
log.player.avatar = generateUrl(log.player.avatar, "rs:auto:256:256:1/f:png");
|
||||
}
|
||||
|
||||
res.status(200).json(new SuccessResponseBuilder().setCode(200).setData(log.toJSON()));
|
||||
|
@ -114,7 +114,7 @@ export class ProfilesRoute
|
||||
|
||||
if (process.env.IMGPROXY_KEY)
|
||||
{
|
||||
player.avatar = generateUrl(player.avatar);
|
||||
player.avatar = generateUrl(player.avatar, "rs:auto:256:256:1/f:png");
|
||||
}
|
||||
|
||||
res.json(
|
||||
|
@ -24,6 +24,7 @@ import { TrainsModule } from "./modules/trains.js";
|
||||
import { Server, Station, Train } from "@simrail/types";
|
||||
import dayjs from "dayjs";
|
||||
import { TMProfile } from "./mongo/profile.js";
|
||||
import { GitUtil } from "./util/git.js";
|
||||
|
||||
;(async () =>
|
||||
{
|
||||
@ -47,6 +48,7 @@ import { TMProfile } from "./mongo/profile.js";
|
||||
}
|
||||
|
||||
ApiModule.load(); // TODO: use fastify
|
||||
GitUtil.getData();
|
||||
|
||||
if (process.env.NODE_ENV === "development")
|
||||
{
|
||||
|
@ -18,9 +18,9 @@ import { execSync } from "child_process";
|
||||
|
||||
export class GitUtil
|
||||
{
|
||||
private static cache: { lastUpdated: number, version?: string, commit?: string } = undefined!;
|
||||
private static cache: { version?: string, commit?: string } = undefined!;
|
||||
|
||||
public static getLatestVersion()
|
||||
private static getLatestVersion()
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -32,7 +32,7 @@ export class GitUtil
|
||||
}
|
||||
}
|
||||
|
||||
public static getLatestCommit()
|
||||
private static getLatestCommit()
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -55,7 +55,6 @@ export class GitUtil
|
||||
const data = {
|
||||
version: this.getLatestVersion(),
|
||||
commit: this.getLatestCommit(),
|
||||
lastUpdated: Date.now(),
|
||||
};
|
||||
|
||||
this.cache = data;
|
||||
|
@ -26,7 +26,7 @@ export const imgProxySign = (target: string) =>
|
||||
return hmac.digest("base64url");
|
||||
};
|
||||
|
||||
export const generateUrl = (url: string, options: string = "preset:simrailpro") =>
|
||||
export const generateUrl = (url: string, options: string = "rs:auto:128:128:1/f:png") =>
|
||||
{
|
||||
if (url.includes('https://imgproxy.alekswilc.dev/')) return url;
|
||||
|
||||
|
@ -44,8 +44,8 @@ export const StationLog = ({ data }: { data: TLogStationData }) =>
|
||||
className="overflow-hidden rounded-sm border border-stroke bg-white shadow-default dark:border-strokedark dark:bg-boxdark">
|
||||
<div className="px-4 pt-6 text-center lg:pb-8 xl:pb-11.5">
|
||||
<div
|
||||
className="mx-auto w-full max-w-30 rounded-full bg-white/20 p-1 backdrop-blur sm:h-44 sm:max-w-44 sm:p-3">
|
||||
<div className="relative drop-shadow-2">
|
||||
className="mx-auto max-w-44 rounded-full">
|
||||
<div className="relative">
|
||||
<img className="rounded-full"
|
||||
src={ data.player.avatar }
|
||||
alt="Player"/>
|
||||
|
@ -44,8 +44,8 @@ export const TrainLog = ({ data }: { data: TLogTrainData }) =>
|
||||
className="overflow-hidden rounded-sm border border-stroke bg-white shadow-default dark:border-strokedark dark:bg-boxdark">
|
||||
<div className="px-4 pt-6 text-center lg:pb-8 xl:pb-11.5">
|
||||
<div
|
||||
className="mx-auto w-full max-w-30 rounded-full bg-white/20 p-1 backdrop-blur sm:h-44 sm:max-w-44 sm:p-3">
|
||||
<div className="relative drop-shadow-2">
|
||||
className="mx-auto max-w-44 rounded-full">
|
||||
<div className="relative">
|
||||
<img className="rounded-full"
|
||||
src={ data.player.avatar }
|
||||
alt="Player"/>
|
||||
|
@ -87,7 +87,7 @@ export const ProfileCard = ({ data }: { data: TProfileData }) =>
|
||||
className="overflow-hidden rounded-sm border border-stroke bg-white shadow-default dark:border-strokedark dark:bg-boxdark">
|
||||
<div className="px-4 pt-6 text-center lg:pb-8 xl:pb-11.5">
|
||||
<div
|
||||
className="mx-auto max-w-30 rounded-full p-1">
|
||||
className="mx-auto max-w-44 rounded-full">
|
||||
<div className="relative rounded-full">
|
||||
<img className="rounded-full" src={ data.player.avatar } alt="profile"/>
|
||||
{ data.active &&
|
||||
|
Loading…
x
Reference in New Issue
Block a user