mirror of
https://github.com/spacebarchat/server.git
synced 2024-11-25 11:43:07 +01:00
Dev portal + categories load db
This commit is contained in:
parent
5c525c1eef
commit
b01a26cdce
42
api/client_test/developers.html
Normal file
42
api/client_test/developers.html
Normal file
@ -0,0 +1,42 @@
|
||||
<!DOCTYPE html>
|
||||
<html class="theme-dark" data-theme="dark">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta content="width=device-width, initial-scale=1.0, maximum-scale=1, user-scalable=no" name="viewport" />
|
||||
|
||||
<link rel="stylesheet" href="/assets/532.03aaeef88460fae60534.css" integrity="" />
|
||||
<link rel="icon" href="/assets/07dca80a102d4149e9736d4b162cff6f.ico" />
|
||||
<title>Discord Test Client Developer Portal</title>
|
||||
<meta charset="utf-8" data-react-helmet="true" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="app-mount"></div>
|
||||
<script>
|
||||
window.GLOBAL_ENV = {
|
||||
API_VERSION: 9,
|
||||
API_ENDPOINT: "/api",
|
||||
WEBAPP_ENDPOINT: "",
|
||||
CDN_HOST: `${location.hostname}:3003`,
|
||||
|
||||
BRAINTREE_KEY: "production_5st77rrc_49pp2rp4phym7387",
|
||||
STRIPE_KEY: "pk_live_CUQtlpQUF0vufWpnpUmQvcdi",
|
||||
MARKETING_ENDPOINT: "//discord.com",
|
||||
RELEASE_CHANNEL: "stable",
|
||||
ALGOLIA_KEY: "aca0d7082e4e63af5ba5917d5e96bed0"
|
||||
};
|
||||
GLOBAL_ENV.MEDIA_PROXY_ENDPOINT = location.protocol + "//" + GLOBAL_ENV.CDN_HOST;
|
||||
const localStorage = window.localStorage;
|
||||
// TODO: remote auth
|
||||
// window.GLOBAL_ENV.REMOTE_AUTH_ENDPOINT = window.GLOBAL_ENV.GATEWAY_ENDPOINT.replace(/wss?:/, "");
|
||||
localStorage.setItem("gatewayURL", window.GLOBAL_ENV.GATEWAY_ENDPOINT);
|
||||
localStorage.setItem(
|
||||
"DeveloperOptionsStore",
|
||||
`{"trace":false,"canary":false,"logGatewayEvents":true,"logOverlayEvents":true,"logAnalyticsEvents":true,"sourceMapsEnabled":false,"axeEnabled":false}`
|
||||
);
|
||||
</script>
|
||||
<script src="/assets/41fde19fdf180f3d4315.js" integrity=""></script>
|
||||
<script src="/assets/7b04a3ab10e05dd9054e.js" integrity=""></script>
|
||||
<script src="/assets/d1f811da193e5648048b.js" integrity=""></script>
|
||||
</body>
|
||||
</html>
|
@ -83,6 +83,15 @@ export default function TestClient(app: Application) {
|
||||
|
||||
return res.send(buffer);
|
||||
});
|
||||
app.get("/developers*", (req: Request, res: Response) => {
|
||||
const { useTestClient } = Config.get().client;
|
||||
res.set("Cache-Control", "public, max-age=" + 60 * 60 * 24);
|
||||
res.set("content-type", "text/html");
|
||||
|
||||
if(!useTestClient) return res.send("Test client is disabled on this instance. Use a stand-alone client to connect this instance.")
|
||||
|
||||
res.send(fs.readFileSync(path.join(__dirname, "..", "..", "client_test", "developers.html"), { encoding: "utf8" }));
|
||||
});
|
||||
app.get("*", (req: Request, res: Response) => {
|
||||
const { useTestClient } = Config.get().client;
|
||||
res.set("Cache-Control", "public, max-age=" + 60 * 60 * 24);
|
||||
|
@ -5,7 +5,7 @@ const router: Router = Router();
|
||||
|
||||
router.get("/", route({}), async (req: Request, res: Response) => {
|
||||
//TODO
|
||||
res.json([]).status(200);
|
||||
res.send([]).status(200);
|
||||
});
|
||||
|
||||
export default router;
|
||||
|
11
api/src/routes/applications/index.ts
Normal file
11
api/src/routes/applications/index.ts
Normal file
@ -0,0 +1,11 @@
|
||||
import { Request, Response, Router } from "express";
|
||||
import { route } from "@fosscord/api";
|
||||
|
||||
const router: Router = Router();
|
||||
|
||||
router.get("/", route({}), async (req: Request, res: Response) => {
|
||||
//TODO
|
||||
res.send([]).status(200);
|
||||
});
|
||||
|
||||
export default router;
|
@ -13,12 +13,10 @@ router.get("/", route({}), async (req: Request, res: Response) => {
|
||||
// TODO: implement this with default typeorm query
|
||||
// const guilds = await Guild.find({ where: { features: "DISCOVERABLE" } }); //, take: Math.abs(Number(limit)) });
|
||||
let guilds;
|
||||
let total;
|
||||
if (categories == undefined) {
|
||||
guilds = showAllGuilds
|
||||
? await Guild.find({ take: Math.abs(Number(limit || configLimit)) })
|
||||
: await Guild.find({ where: `"features" LIKE '%DISCOVERABLE%'`, take: Math.abs(Number(limit || configLimit)) });
|
||||
total = guilds.length;
|
||||
} else {
|
||||
guilds = showAllGuilds
|
||||
? await Guild.find({ where: `"primary_category_id" = ${categories}`, take: Math.abs(Number(limit || configLimit)) })
|
||||
@ -26,8 +24,10 @@ router.get("/", route({}), async (req: Request, res: Response) => {
|
||||
where: `"primary_category_id" = ${categories} AND "features" LIKE '%DISCOVERABLE%'`,
|
||||
take: Math.abs(Number(limit || configLimit))
|
||||
});
|
||||
total = guilds.length;
|
||||
}
|
||||
|
||||
const total = guilds ? guilds.length : undefined;
|
||||
|
||||
res.send({ total: total, guilds: guilds, offset: Number(offset || Config.get().guild.discovery.offset), limit: Number(limit || configLimit) });
|
||||
});
|
||||
|
||||
|
@ -1,29 +1,16 @@
|
||||
import { Categories } from "@fosscord/util";
|
||||
import { Router, Response, Request } from "express";
|
||||
import { route } from "@fosscord/api";
|
||||
|
||||
const router = Router();
|
||||
|
||||
router.get("/categories", route({}), (req: Request, res: Response) => {
|
||||
router.get("/categories", route({}), async (req: Request, res: Response) => {
|
||||
// TODO:
|
||||
// Load categories from db instead of hardcoding
|
||||
// Get locale instead
|
||||
|
||||
const { locale, primary_only } = req.query;
|
||||
|
||||
let categories;
|
||||
|
||||
let out;
|
||||
|
||||
|
||||
|
||||
switch (locale) {
|
||||
case "en-US":
|
||||
switch (primary_only) {
|
||||
case "false":
|
||||
out = [{"id": 0, "is_primary": true, "name": "General"}, {"id": 10, "is_primary": true, "name": "Travel & Food"}, {"id": 15, "is_primary": false, "name": "Esports"}, {"id": 30, "is_primary": false, "name": "LFG"}, {"id": 32, "is_primary": false, "name": "Theorycraft"}, {"id": 36, "is_primary": false, "name": "Business"}, {"id": 39, "is_primary": false, "name": "Fandom"}, {"id": 43, "is_primary": true, "name": "Emoji"}, {"id": 18, "is_primary": false, "name": "Books"}, {"id": 23, "is_primary": false, "name": "Podcasts"}, {"id": 28, "is_primary": false, "name": "Investing"}, {"id": 7, "is_primary": true, "name": "Sports"}, {"id": 13, "is_primary": true, "name": "Other"}, {"id": 2, "is_primary": true, "name": "Music"}, {"id": 3, "is_primary": true, "name": "Entertainment"}, {"id": 4, "is_primary": true, "name": "Creative Arts"}, {"id": 6, "is_primary": true, "name": "Education"}, {"id": 9, "is_primary": true, "name": "Relationships & Identity"}, {"id": 11, "is_primary": true, "name": "Fitness & Health"}, {"id": 12, "is_primary": true, "name": "Finance"}, {"id": 45, "is_primary": false, "name": "Mobile"}, {"id": 16, "is_primary": false, "name": "Anime & Manga"}, {"id": 17, "is_primary": false, "name": "Movies & TV"}, {"id": 19, "is_primary": false, "name": "Art"}, {"id": 20, "is_primary": false, "name": "Writing"}, {"id": 22, "is_primary": false, "name": "Programming"}, {"id": 25, "is_primary": false, "name": "Memes"}, {"id": 27, "is_primary": false, "name": "Cryptocurrency"}, {"id": 31, "is_primary": false, "name": "Customer Support"}, {"id": 33, "is_primary": false, "name": "Events"}, {"id": 34, "is_primary": false, "name": "Roleplay"}, {"id": 37, "is_primary": false, "name": "Local Group"}, {"id": 38, "is_primary": false, "name": "Collaboration"}, {"id": 40, "is_primary": false, "name": "Wiki & Guide"}, {"id": 42, "is_primary": false, "name": "Subreddit"}, {"id": 1, "is_primary": true, "name": "Gaming"}, {"id": 5, "is_primary": true, "name": "Science & Tech"}, {"id": 8, "is_primary": true, "name": "Fashion & Beauty"}, {"id": 14, "is_primary": true, "name": "General Chatting"}, {"id": 21, "is_primary": false, "name": "Crafts, DIY, & Making"}, {"id": 48, "is_primary": false, "name": "Game Developer"}, {"id": 49, "is_primary": true, "name": "Bots"}, {"id": 24, "is_primary": false, "name": "Tabletop Games"}, {"id": 26, "is_primary": false, "name": "News & Current Events"}, {"id": 29, "is_primary": false, "name": "Studying & Teaching"}, {"id": 35, "is_primary": false, "name": "Content Creator"}, {"id": 44, "is_primary": false, "name": "Comics & Cartoons"}, {"id": 46, "is_primary": false, "name": "Console"}, {"id": 47, "is_primary": false, "name": "Charity & Nonprofit"}]
|
||||
case "true":
|
||||
out = [{"id": 0, "is_primary": true, "name": "General"}, {"id": 10, "is_primary": true, "name": "Travel & Food"}, {"id": 43, "is_primary": true, "name": "Emoji"}, {"id": 7, "is_primary": true, "name": "Sports"}, {"id": 13, "is_primary": true, "name": "Other"}, {"id": 2, "is_primary": true, "name": "Music"}, {"id": 3, "is_primary": true, "name": "Entertainment"}, {"id": 4, "is_primary": true, "name": "Creative Arts"}, {"id": 6, "is_primary": true, "name": "Education"}, {"id": 9, "is_primary": true, "name": "Relationships & Identity"}, {"id": 11, "is_primary": true, "name": "Fitness & Health"}, {"id": 12, "is_primary": true, "name": "Finance"}, {"id": 1, "is_primary": true, "name": "Gaming"}, {"id": 5, "is_primary": true, "name": "Science & Tech"}, {"id": 8, "is_primary": true, "name": "Fashion & Beauty"}, {"id": 14, "is_primary": true, "name": "General Chatting"}]
|
||||
}
|
||||
}
|
||||
const out = primary_only ? await Categories.find() : await Categories.find({ where: `"is_primary" = "true"` });
|
||||
|
||||
res.send(out);
|
||||
});
|
||||
|
@ -5,7 +5,7 @@ const router = Router();
|
||||
|
||||
router.get("/", route({}), (req: Request, res: Response) => {
|
||||
// TODO:
|
||||
res.send({ fingerprint: "", assignments: [] });
|
||||
res.send({ fingerprint: "", assignments: [], guild_experiments:[] });
|
||||
});
|
||||
|
||||
export default router;
|
||||
|
@ -11,10 +11,13 @@ router.get("/", route({}), async (req: Request, res: Response) => {
|
||||
// ! this only works using SQL querys
|
||||
// TODO: implement this with default typeorm query
|
||||
// const guilds = await Guild.find({ where: { features: "DISCOVERABLE" } }); //, take: Math.abs(Number(limit)) });
|
||||
|
||||
const genLoadId = (size: Number) => [...Array(size)].map(() => Math.floor(Math.random() * 16).toString(16)).join('');
|
||||
|
||||
const guilds = showAllGuilds
|
||||
? await Guild.find({ take: Math.abs(Number(limit || 24)) })
|
||||
: await Guild.find({ where: `"features" LIKE '%DISCOVERABLE%'`, take: Math.abs(Number(limit || 24)) });
|
||||
res.send({ recommended_guilds: guilds });
|
||||
res.send({ recommended_guilds: guilds, load_id: `server_recs/${genLoadId(32)}`}).status(200);
|
||||
});
|
||||
|
||||
export default router;
|
||||
|
11
api/src/routes/teams.ts
Normal file
11
api/src/routes/teams.ts
Normal file
@ -0,0 +1,11 @@
|
||||
import { Request, Response, Router } from "express";
|
||||
import { route } from "@fosscord/api";
|
||||
|
||||
const router: Router = Router();
|
||||
|
||||
router.get("/", route({}), async (req: Request, res: Response) => {
|
||||
//TODO
|
||||
res.send([]);
|
||||
});
|
||||
|
||||
export default router;
|
@ -15,15 +15,15 @@ import { BaseClassWithoutId } from "./BaseClass";
|
||||
// }]
|
||||
|
||||
@Entity("categories")
|
||||
export class CategoryEntity extends BaseClassWithoutId { // Not using snowflake
|
||||
export class Categories extends BaseClassWithoutId { // Not using snowflake
|
||||
|
||||
@PrimaryColumn()
|
||||
id: number;
|
||||
|
||||
@Column()
|
||||
default: string;
|
||||
name: string;
|
||||
|
||||
@Column({ type: "simple-json", nullable: false })
|
||||
@Column({ type: "simple-json" })
|
||||
localizations: string;
|
||||
|
||||
@Column()
|
||||
|
Loading…
Reference in New Issue
Block a user