more database shit

This commit is contained in:
rift 2024-08-02 00:56:34 -05:00
parent e606fc9985
commit 5c492410be
4 changed files with 1418 additions and 2 deletions

BIN
database.sqlite Normal file

Binary file not shown.

1368
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -20,6 +20,7 @@
"fastify": "^4.28.1",
"nanostores": "^0.10.3",
"sequelize": "^6.37.3",
"sqlite3": "^5.1.7",
"tailwindcss": "^3.4.6",
"typescript": "^5.5.3"
}

View file

@ -28,11 +28,20 @@ const catalog_assets = sequelize.define("catalog_assets", {
},
tags: {
type: DataTypes.JSON,
allowNull: true,
},
version: {
type: DataTypes.TEXT,
},
image: {
type: DataTypes.TEXT,
allowNull: true,
},
script: {
video: {
type: DataTypes.TEXT,
allowNull: true,
},
payload: {
type: DataTypes.TEXT,
},
type: {
@ -49,6 +58,46 @@ app.register(fastifyStatic, {
wildcard: false,
});
app.get("/api", function (request, reply) {
reply.send({ hello: "world" });
});
app.get("/api/catalog-assets", async (request, reply) => {
try {
// i've literally never done shit like this before so lets hope its not shit
const assets = await catalog_assets.findAll();
const response = assets.reduce((acc, asset) => {
acc[asset.package_name] = {
title: asset.title,
description: asset.description,
tags: asset.tags,
version: asset.version,
image: asset.image, // @todo: change this to a route. like "/images/" + asset.package_name and return the image there.
video: asset.video, // same with video.
payload: asset.payload,
type: asset.type,
};
return acc;
}, {});
reply.send(response);
} catch (error) {
reply.status(500).send({ error: "there was an error" });
}
});
await catalog_assets.create({
package_name: "com.fortnite.jpeg",
title: "fortnite.jpeg",
version: "6.9.420",
description: "a man in a blessings shirt sticking his tounge out",
tags: ["Fortnite", "Shit out my ass"],
payload: "the DAMN CSS",
type: "theme",
});
catalog_assets.sync();
app.listen({
port: 8080,
host: "0.0.0.0",