more database shit
This commit is contained in:
parent
e606fc9985
commit
5c492410be
4 changed files with 1418 additions and 2 deletions
BIN
database.sqlite
Normal file
BIN
database.sqlite
Normal file
Binary file not shown.
1368
package-lock.json
generated
1368
package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
|
@ -20,6 +20,7 @@
|
||||||
"fastify": "^4.28.1",
|
"fastify": "^4.28.1",
|
||||||
"nanostores": "^0.10.3",
|
"nanostores": "^0.10.3",
|
||||||
"sequelize": "^6.37.3",
|
"sequelize": "^6.37.3",
|
||||||
|
"sqlite3": "^5.1.7",
|
||||||
"tailwindcss": "^3.4.6",
|
"tailwindcss": "^3.4.6",
|
||||||
"typescript": "^5.5.3"
|
"typescript": "^5.5.3"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
51
server.js
51
server.js
|
|
@ -28,11 +28,20 @@ const catalog_assets = sequelize.define("catalog_assets", {
|
||||||
},
|
},
|
||||||
tags: {
|
tags: {
|
||||||
type: DataTypes.JSON,
|
type: DataTypes.JSON,
|
||||||
|
allowNull: true,
|
||||||
|
},
|
||||||
|
version: {
|
||||||
|
type: DataTypes.TEXT,
|
||||||
},
|
},
|
||||||
image: {
|
image: {
|
||||||
type: DataTypes.TEXT,
|
type: DataTypes.TEXT,
|
||||||
|
allowNull: true,
|
||||||
},
|
},
|
||||||
script: {
|
video: {
|
||||||
|
type: DataTypes.TEXT,
|
||||||
|
allowNull: true,
|
||||||
|
},
|
||||||
|
payload: {
|
||||||
type: DataTypes.TEXT,
|
type: DataTypes.TEXT,
|
||||||
},
|
},
|
||||||
type: {
|
type: {
|
||||||
|
|
@ -49,6 +58,46 @@ app.register(fastifyStatic, {
|
||||||
wildcard: false,
|
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({
|
app.listen({
|
||||||
port: 8080,
|
port: 8080,
|
||||||
host: "0.0.0.0",
|
host: "0.0.0.0",
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue