basic version of forms

This commit is contained in:
metacryst
2025-12-22 04:53:00 -06:00
parent 80ceb48a62
commit 97bd02c59a
14 changed files with 153 additions and 1742 deletions

View File

@@ -9,13 +9,14 @@ import cors from 'cors'
import http from 'http'
import chalk from 'chalk'
import moment from 'moment'
import * as z from "zod";
import { initWebSocket } from './ws.js'
import Database from "./db/db.js"
import getAllDownloadsFiles from "./db/getDownloads.js"
import getAllDownloadsFiles from "./getDownloads.js"
import forms from "forms"
class Server {
db;
export default class Server {
store;
UIPath = path.join(__dirname, '../ui')
registerRoutes(router) {
@@ -81,8 +82,25 @@ class Server {
next();
}
async connectToForms() {
await this.store.connect()
this.store.register("log", z.toJSONSchema(z.object({
time: z.string(),
host: z.string(),
ip: z.string(),
path: z.string(),
method: z.string()
})))
this.store.add("log", {
time: "0100",
host: "parchment.page",
ip: "0.0.0.1",
path: "/asd",
method: "GET"
})
}
constructor() {
this.db = new Database()
const app = express();
app.use(cors({ origin: '*' }));
app.use(express.json());
@@ -94,12 +112,15 @@ class Server {
this.registerRoutes(router)
app.use('/', router);
this.store = new forms.client()
this.connectToForms()
const server = http.createServer(app);
initWebSocket(server);
const PORT = 80;
server.listen(PORT, () => {
console.log("\n")
console.log(chalk.yellow("**************Downloads****************"))
console.log(chalk.yellow("**************Parchment****************"))
console.log(chalk.yellowBright(`Server is running on port ${PORT}: http://localhost`));
console.log(chalk.yellow("***************************************"))
console.log("\n")
@@ -113,6 +134,4 @@ class Server {
Object.preventExtensions(this);
}
}
const server = new Server()
}