11.2025: new version released, sample folder added

This commit is contained in:
metacryst
2025-11-30 02:50:10 -06:00
parent 6e2b4dcdbd
commit ed6d885557
24 changed files with 2098 additions and 1505 deletions

2
Sample/.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
node_modules
package-lock.json

0
Sample/db/db.json Normal file
View File

18
Sample/package.json Normal file
View File

@@ -0,0 +1,18 @@
{
"name": "Quill Starter",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "node server/index.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"chalk": "^4.1.2",
"cors": "^2.8.5",
"express": "^4.18.2",
"moment": "^2.30.1"
}
}

12
Sample/server/db/db.js Normal file
View File

@@ -0,0 +1,12 @@
const fs = require('fs/promises');
export default class Database {
constructor() {
}
async saveData() {
}
}

100
Sample/server/index.js Normal file
View File

@@ -0,0 +1,100 @@
const express = require('express');
const cors = require('cors');
const http = require('http');
const chalk = require('chalk');
const moment = require('moment');
const path = require('path');
class Server {
db;
UIPath = path.join(__dirname, '../ui')
registerRoutes(router) {
router.post('/join', this.join)
router.post('/contact', this.contact)
router.get('/*', this.get)
return router
}
join = (req, res) => {
}
contact = (req, res) => {
}
get = async (req, res) => {
console.log(this.UIPath)
let url = req.url
let filePath;
if(url.startsWith("/_")) {
filePath = path.join(this.UIPath, url);
} else if(url.includes("75820185")) {
filePath = path.join(this.UIPath, url.split("75820185")[1]);
} else {
filePath = path.join(this.UIPath, "index.html");
}
res.sendFile(filePath);
}
logRequest(req, res, next) {
const formattedDate = moment().format('M.D');
const formattedTime = moment().format('h:mma');
if(req.url.includes("/api/")) {
console.log(chalk.blue(` ${req.method} ${req.url} | ${formattedDate} ${formattedTime}`));
} else {
if(req.url === "/")
console.log(chalk.gray(` ${req.method} ${req.url} | ${formattedDate} ${formattedTime}`));
}
next();
}
logResponse(req, res, next) {
const originalSend = res.send;
res.send = function (body) {
if(res.statusCode >= 400) {
console.log(chalk.blue( `<-${chalk.red(res.statusCode)}- ${req.method} ${req.url} | ${chalk.red(body)}`));
} else {
console.log(chalk.blue(`<-${res.statusCode}- ${req.method} ${req.url}`));
}
originalSend.call(this, body);
};
next();
}
constructor() {
const app = express();
app.use(cors({ origin: '*' }));
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
app.use(this.logRequest);
app.use(this.logResponse);
let router = express.Router();
this.registerRoutes(router)
app.use('/', router);
const server = http.createServer(app);
const PORT = 3004;
server.listen(PORT, () => {
console.log("\n")
console.log(chalk.yellow("*************** Comal YR ***************"))
console.log(chalk.yellowBright(`Server is running on port ${PORT}: http://localhost`));
console.log(chalk.yellow("***************************************"))
console.log("\n")
});
process.on('SIGINT', async () => {
console.log(chalk.red('Closing server...'));
console.log(chalk.green('Database connection closed.'));
process.exit(0);
});
Object.preventExtensions(this);
}
}
const server = new Server()

1047
Sample/ui/_/code/quill.js Normal file

File diff suppressed because one or more lines are too long

View File

View File

@@ -0,0 +1,7 @@
class Home extends Shadow {
render() {
}
}
register(Home)

13
Sample/ui/index.html Normal file
View File

@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Quill Starter</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" href="/_/icons/logo.svg">
<link rel="stylesheet" href="/_/code/shared.css">
<script src="/_/code/quill.js"></script>
<script type="module" src="75820185/index.js"></script>
</head>
<body style="margin: 0px">
</body>
</html>

2
Sample/ui/index.js Normal file
View File

@@ -0,0 +1,2 @@
import "./components/Home.js"
Home()