WIP: It's bun time

This commit is contained in:
Holly Stubbs 2025-01-08 08:19:11 +00:00
parent 24247d938f
commit 301a3ac595
Signed by: tgpholly
GPG key ID: B8583C4B7D18119E
8 changed files with 36 additions and 2041 deletions

BIN
bun.lockb Executable file

Binary file not shown.

View file

@ -1,3 +1,4 @@
import DashboardViewModel from "../models/home/DashboardViewModel";
import Config from "../objects/Config";
import HashFS from "../objects/HashFS";
import UserService from "../services/UserService";
@ -5,9 +6,13 @@ import Controller from "./Controller";
import { randomBytes } from "crypto";
export default class HomeController extends Controller {
public Index_Get_AllowAnonymous() {
public async Index_Get_AllowAnonymous() {
if (this.session) {
return this.view("dashboard");
const dashboardViewModel: DashboardViewModel = {
recentUploads: await UserService.GetRecentUploads(this.session.userId)
}
return this.view("dashboard",dashboardViewModel);
}
return this.view();

View file

@ -100,7 +100,7 @@ fastify.addHook("onSend", (req, res, _payload, done) => {
fastify.setNotFoundHandler(async (req, res) => {
return res.status(404).view("views/404.ejs", { session: null });
return res.status(404).view("views/404.ejs");
});
HashFS.STARTUP_DIR = __dirname;

View file

@ -0,0 +1,5 @@
import Media from "../../entities/Media";
export default interface DashboardViewModel {
recentUploads: Array<Media>
}

2034
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -12,7 +12,8 @@
"type": "commonjs",
"scripts": {
"updateCheck": "check-outdated",
"dev": "nodemon --watch './**/*.ts' index.ts",
"dev:legacy_node": "nodemon --watch './**/*.ts' index.ts",
"dev": "bun --watch index.ts",
"build": "tsc --build"
},
"devDependencies": {

View file

@ -1,5 +1,13 @@
<%- include("./base/header", { title: "404", session }) %>
<%- include("./base/header", { title: "404" }) %>
<div class="row">
<div class="col">
<div class="card">
<div class="card-body">
<h1>404</h1>
</div>
</div>
</div>
</div>
<%- include("./base/footer") %>

View file

@ -10,7 +10,17 @@
<div class="col text-end"><a aria-label="View All Uploads" href="/imagelist">View All >></a></div>
</div>
</div>
<div class="card-body"></div>
<div class="card-body">
<table>
<tbody>
<% for (const upload of recentUploads) { %>
<tr>
<td><%= upload.FileName %></td>
</tr>
<% } %>
</tbody>
</table>
</div>
</div>
</div>
<!-- Stats -->