-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feature: Api Server #43
base: rewrite
Are you sure you want to change the base?
Conversation
frontend/src/service/axios.ts
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we use axios?
fetch is globally available.
frontend/src/service/httpClient.ts
Outdated
message: string | ||
} | ||
|
||
export async function request<T extends object>({path, method = 'GET', auth = false}: FetchParams) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
export async function request<T extends object>({path, method = 'GET', auth = false}: FetchParams) { | |
export async function request<T extends Record<string | number, unknown> | unknown[]>({path, method = 'GET', auth = false}: FetchParams) { |
extends object
is certainly not what you want here, with the extends object
clause will allow any object, e.g request<string>()
is perfectly valid.
export const discordLoginUri = encodeURI(`https://discord.com/oauth2/authorize?client_id=${process.env.REACT_APP_CLIENT_ID}&response_type=code&redirect_uri=${process.env.REACT_APP_REDIRECT_URL}&scope=identify+guilds`); | ||
|
||
export function getUserAvatar(id: string, hash: string) { | ||
return `https://media.discordapp.net/avatars/${id}/${hash}.png?size=64`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should use the cdn, not the media proxy
frontend/src/page/admin/Guilds.tsx
Outdated
type GuildRowDef = { | ||
id: string, | ||
name: React.JSX.Element|string, | ||
cachedMembers: number, | ||
cachedChannels: number, | ||
cachedMessages: number, | ||
cachedRoles: number, | ||
enabledFeatures: string[], | ||
tagsCount: number, | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
type GuildRowDef = { | |
id: string, | |
name: React.JSX.Element|string, | |
cachedMembers: number, | |
cachedChannels: number, | |
cachedMessages: number, | |
cachedRoles: number, | |
enabledFeatures: string[], | |
tagsCount: number, | |
}; | |
interface GuildRowDef { | |
id: string, | |
name: React.JSX.Element|string, | |
cachedMembers: number, | |
cachedChannels: number, | |
cachedMessages: number, | |
cachedRoles: number, | |
enabledFeatures: string[], | |
tagsCount: number, | |
}; |
frontend/src/service/api.ts
Outdated
export type BotInfo = { | ||
nyxxVersion: string; | ||
version: string; | ||
platform: string; | ||
memoryUsageString: string; | ||
cachedChannels: number; | ||
cachedMessages: number; | ||
cachedGuilds: number; | ||
cachedUsers: number; | ||
cachedVoiceStates: number; | ||
shardCount: number; | ||
totalTagsCount: number; | ||
totalReminderCount: number; | ||
uptime: string; | ||
docsUpdate: string; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
export type BotInfo = { | |
nyxxVersion: string; | |
version: string; | |
platform: string; | |
memoryUsageString: string; | |
cachedChannels: number; | |
cachedMessages: number; | |
cachedGuilds: number; | |
cachedUsers: number; | |
cachedVoiceStates: number; | |
shardCount: number; | |
totalTagsCount: number; | |
totalReminderCount: number; | |
uptime: string; | |
docsUpdate: string; | |
}; | |
export interface BotInfo { | |
nyxxVersion: string; | |
version: string; | |
platform: string; | |
memoryUsageString: string; | |
cachedChannels: number; | |
cachedMessages: number; | |
cachedGuilds: number; | |
cachedUsers: number; | |
cachedVoiceStates: number; | |
shardCount: number; | |
totalTagsCount: number; | |
totalReminderCount: number; | |
uptime: string; | |
docsUpdate: string; | |
}; |
frontend/src/service/api.ts
Outdated
export type Guild = { | ||
id: string, | ||
name: string, | ||
banner?: string, | ||
icon?: string, | ||
cachedMembers: number, | ||
cachedChannels: number, | ||
cachedMessages: number, | ||
cachedRoles: number, | ||
enabledFeatures: string[], | ||
tagsCount: number, | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
export type Guild = { | |
id: string, | |
name: string, | |
banner?: string, | |
icon?: string, | |
cachedMembers: number, | |
cachedChannels: number, | |
cachedMessages: number, | |
cachedRoles: number, | |
enabledFeatures: string[], | |
tagsCount: number, | |
}; | |
export interface Guild { | |
id: string, | |
name: string, | |
banner?: string, | |
icon?: string, | |
cachedMembers: number, | |
cachedChannels: number, | |
cachedMessages: number, | |
cachedRoles: number, | |
enabledFeatures: string[], | |
tagsCount: number, | |
}; |
import {Base} from "../component/Base"; | ||
import {Container, Grid2, Paper, Typography} from "@mui/material"; | ||
import {BotInfoElement} from "../component/BotInfoElement"; | ||
import {formatRelative, parseISO} from "date-fns"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We dont need this module
function BotInfoWidget() { | ||
const botInfoStats = use(botInfoStatusPromise); | ||
|
||
const uptime = formatRelative(parseISO(botInfoStats.uptime), new Date()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const uptime = formatRelative(parseISO(botInfoStats.uptime), new Date()); | |
const uptime = (new Intl.RelativeTimeFormat('en-GB', { style: 'short' })).format(new Date(botInfoStats.uptime); |
import {parseISO} from "date-fns"; | ||
import {format} from "date-fns/format"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We dont need this
const enabledFeatures = data.enabledFeatures.map(f => { | ||
const enabledAt = format(parseISO(f.enabledAt), 'MM/dd/yyyy'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const enabledFeatures = data.enabledFeatures.map(f => { | |
const enabledAt = format(parseISO(f.enabledAt), 'MM/dd/yyyy'); | |
const dateFormat = new Intl.DateTimeFormat('en-GB', { dateStyle: 'short', timeStyle: 'short' }) | |
const enabledFeatures = data.enabledFeatures.map(f => { | |
const enabledAt = dateFormat.format(new Date(f.enabledAt)) |
Also, using MM/DD/YYY is wrong.
No description provided.