base project

This commit is contained in:
Seth 2025-04-20 23:15:41 -04:00
parent 79f300a918
commit 4fedd38df1
33 changed files with 407 additions and 2514 deletions

50
.gitignore vendored
View file

@ -1,24 +1,34 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*
# dependencies (bun install)
node_modules
dist
dist-ssr
*.local
# Editor directories and files
.vscode/*
!.vscode/extensions.json
# output
out
dist
*.tgz
# code coverage
coverage
*.lcov
# logs
logs
_.log
report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json
# dotenv environment variable files
.env
.env.development.local
.env.test.local
.env.production.local
.env.local
# caches
.eslintcache
.cache
*.tsbuildinfo
# IntelliJ based IDEs
.idea
# Finder (MacOS) folder config
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?

View file

@ -1,2 +1,15 @@
# ipv4.army
To install dependencies:
```bash
bun install
```
To run:
```bash
bun run index.ts
```
This project was created using `bun init` in bun v1.2.11. [Bun](https://bun.sh) is a fast all-in-one JavaScript runtime.

View file

@ -1,35 +0,0 @@
{
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
"vcs": {
"enabled": true,
"clientKind": "git",
"useIgnoreFile": false
},
"files": {
"ignoreUnknown": true,
"ignore": []
},
"formatter": {
"enabled": true,
"indentStyle": "tab",
"lineEnding": "lf"
},
"organizeImports": {
"enabled": true
},
"linter": {
"enabled": true,
"rules": {
"recommended": true
}
},
"javascript": {
"formatter": {
"quoteStyle": "double",
"indentStyle": "tab",
"lineEnding": "lf",
"jsxQuoteStyle": "double",
"semicolons": "always"
}
}
}

2166
bun.lock

File diff suppressed because it is too large Load diff

2
bunfig.toml Normal file
View file

@ -0,0 +1,2 @@
[loader]
".woff2" = "file"

View file

@ -1,15 +0,0 @@
<!doctype html>
<html lang="en" data-bs-theme="dark" data-bs-core="default">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="color-scheme" content="dark">
<meta name="description" content="A Dedicated Backend Developer." />
<title>Seth @ IPv4 dot Army</title>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.tsx" defer></script>
</body>
</html>

134
index.ts Normal file
View file

@ -0,0 +1,134 @@
import { build, serve, gzipSync, file, type BunRequest, gc } from "bun";
import pkg from "./package.json";
const development = process.env.NODE_ENV === "development";
require("fs/promises").rm("./dist", { recursive: true, force: true }).catch(() => {
// ignore
});
await build({
entrypoints: ['./src/index.html'],
outdir: './dist',
minify: !development,
sourcemap: (development ? "inline" : "none"),
splitting: true,
publicPath: "/assets/",
loader: {
".woff2": "file"
},
})
serve({
routes: {
"/": async () => {
return new Response(gzipSync(await file("./dist/index.html").arrayBuffer()), {
headers: {
"Content-Type": "text/html",
"Cache-Control": "no-cache",
"Content-Encoding": "gzip",
}
})
},
"/assets/:file": async (req: BunRequest<"/assets/:file">) => {
const reqFile = file(`./dist/${req.params.file}`)
return new Response(gzipSync(await reqFile.arrayBuffer()), {
headers: {
"Content-Type": reqFile.type,
"Cache-Control": "public, max-age=31536000",
"Content-Encoding": "gzip",
}
})
},
"/public/:file": async (req: BunRequest<"/public/:file">) => {
const reqFile = file(`./public/${req.params.file}`)
let fileRes = await reqFile.text()
fileRes = fileRes.replace("{{LANYARD}}", `${JSON.stringify({ example: "lanyard data" })}`)
fileRes = fileRes.replace("{{HYPERATE}}", `${JSON.stringify({ example: "hyperate data" })}`)
return new Response(gzipSync(fileRes), {
headers: {
"Content-Type": reqFile.type,
"Cache-Control": "public, max-age=31536000",
"Content-Encoding": "gzip",
}
})
},
"/public/font/:file": async (req: BunRequest<"/public/font/:file">) => {
const reqFile = file(`./public/font/${req.params.file}`)
return new Response(gzipSync(await reqFile.arrayBuffer()), {
headers: {
"Content-Type": reqFile.type,
"Cache-Control": "public, max-age=31536000",
"Content-Encoding": "gzip",
}
})
},
"/api/server": () => {
const string = JSON.stringify(process)
const json = JSON.parse(string)
// clear possibly data that could be sensitive
json.argv = {}
json.debugPort = 0
json.env = {}
json.execArgv = []
json.execPath = ""
json.stderr = {}
json.stdin = {}
json.stdout = {}
json.title = ""
json.availableMemory = process.availableMemory()
json.constrainedMemory = process.constrainedMemory()
json.cpuUsage = process.cpuUsage()
json.memoryUsage = process.memoryUsage()
json.uptime = process.uptime()
json.package = pkg
return new Response(gzipSync(JSON.stringify({ data: json })), {
headers: {
"Content-Type": "application/json",
"Cache-Control": "no-cache",
"Content-Encoding": "gzip",
}
})
},
"/api/health": () => {
return new Response(gzipSync(JSON.stringify({ data: "ok" })), {
headers: {
"Content-Type": "application/json",
"Cache-Control": "no-cache",
"Content-Encoding": "gzip",
}
})
},
"/api/status": () => {
return new Response(gzipSync(JSON.stringify({ data: process.uptime() })), {
headers: {
"Content-Type": "application/json",
"Cache-Control": "no-cache",
"Content-Encoding": "gzip",
}
})
},
"/api/gc": () => {
gc(true)
return new Response(gzipSync(JSON.stringify({ data: "triggered" })), {
headers: {
"Content-Type": "application/json",
"Cache-Control": "no-cache",
"Content-Encoding": "gzip",
}
})
},
},
development,
port: 3000,
});

View file

@ -1,25 +1,20 @@
{
"name": "ipv4.army-vite",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "bunx --bun vite",
"lint": "bunx biome check --fix --unsafe",
"build": "bunx --bun tsc -b && bunx --bun vite build",
"preview": "bunx --bun vite preview"
},
"dependencies": {
"halfmoon": "^2.0.2",
"lucide-preact": "^0.487.0",
"preact": "^10.26.2"
},
"devDependencies": {
"@biomejs/biome": "1.9.4",
"@fullhuman/postcss-purgecss": "^7.0.2",
"@preact/preset-vite": "^2.10.1",
"lightningcss": "^1.29.3",
"typescript": "~5.7.2",
"vite": "^6.2.0"
}
}
"name": "ipv4.army",
"module": "index.ts",
"scripts": {
"dev": "NODE_ENV=development bun run --hot . --watch",
"start": "bun run ."
},
"devDependencies": {
"@biomejs/biome": "1.9.4",
"@types/bun": "latest"
},
"peerDependencies": {
"typescript": "^5.8.3"
},
"private": true,
"type": "module",
"dependencies": {
"tsx-dom": "^3.1.0"
}
}

BIN
public/font/Black.woff2 Normal file

Binary file not shown.

Binary file not shown.

BIN
public/font/Bold.woff2 Normal file

Binary file not shown.

Binary file not shown.

BIN
public/font/Book.woff2 Normal file

Binary file not shown.

Binary file not shown.

BIN
public/font/Medium.woff2 Normal file

Binary file not shown.

Binary file not shown.

17
public/font/rename.ts Normal file
View file

@ -0,0 +1,17 @@
import { Glob } from "bun";
const woff2 = new Glob("./*.woff2");
for await (const file of woff2.scan(".")) {
const font = Bun.file(file);
const name = font.name?.split("-")[1];
await Bun.write(`./${name}`, await font.arrayBuffer());
console.log(`Renamed ${file} to ${name}`);
await font.delete();
console.log(`Deleted original font file: ${file}`);
}
console.log("Done")

3
src/App.tsx Normal file
View file

@ -0,0 +1,3 @@
export default () => {
return <div>Hello, World!</div>
}

View file

@ -1,13 +0,0 @@
import Container from "./container";
import Navbar from "./navbar";
import "./app.css";
export default () => {
return (
<>
<Navbar />
<Container />
</>
);
};

View file

@ -1,49 +0,0 @@
import { useState } from "preact/hooks";
import Heart from "../heart";
const statusMap = {
online: "border-success-subtle",
idle: "border-warning-subtle",
dnd: "border-danger-subtle",
offline: "border-light-subtle",
};
export default () => {
const [status, setStatus] = useState<keyof typeof statusMap>("offline");
fetch("https://lanyard.creations.works/v1/users/1273447359417942128")
.then((req) => req.json())
.then((res) => {
if (res.data.discord_status) {
setStatus(res.data.discord_status);
} else {
setStatus("offline");
}
});
return (
<>
<div class="container bg-body-tertiary shadow text-center position-absolute top-50 start-50 translate-middle mx-auto py-4">
<img
src="favicon.svg"
class={`img-thumbnail rounded-circle border border-4 ${statusMap[status]}`}
alt="..."
width="100px"
height="100px"
/>
<br />
<h1>Seth</h1>
<h2 class="lead">
Dedicated Backend Developer
<br />
<br />
<small class="text-body-secondary">
With a passsion for high-fidelity audio, gaming, and web development
</small>
</h2>
<Heart />
</div>
</>
);
};

View file

@ -1,18 +0,0 @@
:root {
--bpm: 0;
}
@keyframes pulse {
0%,
100% {
transform: scale(1);
}
50% {
transform: scale(1.1);
}
}
.heart {
animation: pulse calc(60s / var(--bpm)) infinite ease;
}

View file

@ -1,71 +0,0 @@
import { useState } from "preact/hooks";
import "./index.css";
export default () => {
const [heartrate, setHeartrate] = useState(0);
const ws = new WebSocket(
"wss://app.hyperate.io/socket/websocket?token=wv39nM6iyrNJulvpmMQrimYPIXy2dVrYRjkuHpbRapKT2VSh65ngDGHdCdCtmEN9",
);
let hrTimeout: ReturnType<typeof setTimeout>;
const setHrInterval = () => {
hrTimeout = setTimeout(() => {
return setHeartrate(0);
}, 6000);
};
ws.onopen = () => {
ws.send(
JSON.stringify({
topic: "hr:0BCA",
event: "phx_join",
payload: {},
ref: 0,
}),
);
setInterval(() => {
ws.send(
JSON.stringify({
topic: "phoenix",
event: "heartbeat",
payload: {},
ref: 0,
}),
);
}, 10000);
return setHrInterval();
};
ws.onmessage = ({ data }) => {
const { event, payload } = JSON.parse(data);
switch (event) {
case "hr_update": {
clearTimeout(hrTimeout);
setHrInterval();
setHeartrate(payload.hr);
break;
}
default: {
break;
}
}
};
return (
<>
<div
style={heartrate === 0 ? "display:none" : `--bpm: ${heartrate};`}
class="heart"
>
<br />
<span>{heartrate} BPM</span>
</div>
</>
);
};

View file

@ -1,46 +0,0 @@
import { Minimize, Minus, X } from "lucide-preact";
const close = () => {
window.close();
window.history.back();
};
export default () => {
return (
<>
<nav
class="navbar shadow fixed-top"
style="background-color: var(--bs-content-bg); border-bottom: var(--bs-border-width) solid var(--bs-content-border-color);"
>
<div class="container-fluid">
<div class="navbar-brand">
<img
src="favicon.svg"
alt="Logo"
width="24"
height="24"
class="d-inline-block align-text-top"
/>
Seth
</div>
<span class="navbar-text">IPv4 dot Army</span>
<div class="d-flex hstack gap-2">
<button type="button" class="btn btn-outline-success btn-sm">
<Minus size={20} />
</button>
<button type="button" class="btn btn-outline-warning btn-sm">
<Minimize size={20} />
</button>
<button
type="button"
class="btn btn-outline-danger btn-sm"
onClick={close}
>
<X size={20} />
</button>
</div>
</div>
</nav>
</>
);
};

View file

@ -0,0 +1,28 @@
@import "./App.css";
:root {
--color-background-primary: #1a1d1f;
--color-background-secondary: #24282b;
--color-background-tertiary: #222527;
--color-text-primary: #DEDEDE;
--color-text-secondary: #ACACAC;
--color-link: #7289DA;
--color-link-hover: #4E5D94;
--color-link-active: #5B6EAE;
}
html,
head,
body {
margin: 0;
padding: 0;
font-family: 'Circular Std', sans-serif;
}
body {
background-color: var(--color-background-primary);
color: var(--color-text-primary);
font-size: 16px;
line-height: 1.5;
}

23
src/index.html Normal file
View file

@ -0,0 +1,23 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="theme-color" content="#1a1d1f">
<meta name="description"
content="A Dedicated Backend Developer, with a passion for high-fidelity audio, gaming, and web development.">
<meta name="keywords" content="Seth, IPv4, Army, Seth@IPv4, web development, audio, gaming">
<meta name="author" content="Seth">
<title>Seth @ IPv4 dot Army</title>
<link rel="icon" href="/public/favicon.svg" />
<meta name="color-scheme" content="dark" />
<link rel="stylesheet" href="index.css" />
<style id="font"></style>
</head>
<body>
<script src="index.tsx"></script>
</body>
</html>

72
src/index.tsx Normal file
View file

@ -0,0 +1,72 @@
import "tsx-dom";
import App from './App';
document.getElementById("font")!.innerText = `@font-face {
font-family: 'Circular Std';
src: url('/public/font/Black.woff2') format('woff2');
font-weight: black;
font-style: normal;
font-display: swap
}
@font-face {
font-family: 'Circular Std';
src: url('/public/font/BlackItalic.woff2') format('woff2');
font-weight: black;
font-style: italic;
font-display: swap
}
@font-face {
font-family: 'Circular Std';
src: url('/public/font/Bold.woff2') format('woff2');
font-weight: bold;
font-style: normal;
font-display: swap
}
@font-face {
font-family: 'Circular Std';
src: url('/public/font/BoldItalic.woff2') format('woff2');
font-weight: bold;
font-style: italic;
font-display: swap
}
@font-face {
font-family: 'Circular Std';
src: url('/public/font/Book.woff2') format('woff2');
font-weight: normal;
font-style: normal;
font-display: swap
}
@font-face {
font-family: 'Circular Std';
src: url('/public/font/BookItalic.woff2') format('woff2');
font-weight: normal;
font-style: italic;
font-display: swap
}
@font-face {
font-family: 'Circular Std';
src: url('/public/font/Medium.woff2') format('woff2');
font-weight: 500;
font-style: normal;
font-display: swap
}
@font-face {
font-family: 'Circular Std';
src: url('/public/font/MediumItalic.woff2') format('woff2');
font-weight: 500;
font-style: italic;
font-display: swap
}`
document.body.appendChild(<App />);
// You're garbage, let me collect you.
fetch("/api/gc")

View file

@ -1,9 +0,0 @@
import { render } from "preact";
import "./index.css";
import "halfmoon/css/halfmoon.min.css";
import App from "./components/app.tsx";
render(
<App />,
(document.getElementById("app") as HTMLElement) || document.body,
);

1
src/vite-env.d.ts vendored
View file

@ -1 +0,0 @@
/// <reference types="vite/client" />

View file

@ -1,27 +0,0 @@
{
"compilerOptions": {
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
"target": "ES2020",
"useDefineForClassFields": true,
"module": "ESNext",
"lib": ["ES2020", "DOM", "DOM.Iterable"],
"skipLibCheck": true,
"paths": {
"react": ["./node_modules/preact/compat/"],
"react-dom": ["./node_modules/preact/compat/"]
},
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"isolatedModules": true,
"moduleDetection": "force",
"noEmit": true,
"jsx": "react-jsx",
"jsxImportSource": "preact",
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true,
"noUncheckedSideEffectImports": true
},
"include": ["src"]
}

View file

@ -1,11 +1,29 @@
{
"files": [],
"references": [
{
"path": "./tsconfig.app.json"
},
{
"path": "./tsconfig.node.json"
}
]
}
"compilerOptions": {
// Environment setup & latest features
"lib": [
"ESNext",
"DOM",
],
"target": "ESNext",
"module": "ESNext",
"moduleDetection": "force",
"jsx": "react-jsx",
"jsxImportSource": "tsx-dom",
"allowJs": true,
// Bundler mode
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"verbatimModuleSyntax": true,
"noEmit": true,
// Best practices
"strict": true,
"skipLibCheck": true,
"noFallthroughCasesInSwitch": true,
"noUncheckedIndexedAccess": true,
// Some stricter flags (disabled by default)
"noUnusedLocals": false,
"noUnusedParameters": false,
"noPropertyAccessFromIndexSignature": false
}
}

View file

@ -1,20 +0,0 @@
{
"compilerOptions": {
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
"target": "ES2022",
"lib": ["ES2023"],
"module": "ESNext",
"skipLibCheck": true,
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"isolatedModules": true,
"moduleDetection": "force",
"noEmit": true,
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true,
"noUncheckedSideEffectImports": true
},
"include": ["vite.config.ts"]
}

View file

@ -1,28 +0,0 @@
/// <reference types="vite/client" />
import preact from "@preact/preset-vite";
import { defineConfig } from "vite";
import postCSSPurgeCSS from "@fullhuman/postcss-purgecss";
// https://vite.dev/config/
export default defineConfig({
css: {
...(import.meta.env.NODE_ENV === "production"
? {
transformer: "postcss",
postcss: {
plugins: [
postCSSPurgeCSS({
content: ["./index.html", "./src/**/*.{ts,tsx}"],
}),
],
},
}
: { transformer: "lightningcss" }),
},
build: {
cssMinify: "lightningcss",
},
plugins: [preact()],
});