commit 25e7da24e6d3a15f7c0a8f7a362a96b4aa7c6904 Author: creations Date: Sun May 18 19:12:34 2025 -0400 first commit diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..d93a942 --- /dev/null +++ b/LICENSE @@ -0,0 +1,28 @@ +BSD 3-Clause License + +Copyright (c) 2025, creations.works + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..144fff6 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +## License + +[BSD 3](LICENSE) diff --git a/biome.json b/biome.json new file mode 100644 index 0000000..46ee8c9 --- /dev/null +++ b/biome.json @@ -0,0 +1,44 @@ +{ + "$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 + }, + "css": { + "formatter": { + "indentStyle": "tab", + "lineEnding": "lf" + } + }, + "linter": { + "enabled": true, + "rules": { + "recommended": true, + "correctness": { + "noUnusedImports": "error" + } + } + }, + "javascript": { + "formatter": { + "quoteStyle": "double", + "indentStyle": "tab", + "lineEnding": "lf", + "jsxQuoteStyle": "double", + "semicolons": "always" + } + } +} diff --git a/config/index.ts b/config/index.ts new file mode 100644 index 0000000..8eb0582 --- /dev/null +++ b/config/index.ts @@ -0,0 +1,36 @@ +import { logger } from "@creations.works/logger"; +import { normalizeFqdn } from "@lib/char"; + +const environment: Environment = { + port: Number.parseInt(process.env.PORT || "8080", 10), + host: process.env.HOST || "0.0.0.0", + development: + process.env.NODE_ENV === "development" || process.argv.includes("--dev"), + fqdn: normalizeFqdn(process.env.FQDN) || "http://localhost:8080", +}; + +function verifyRequiredVariables(): void { + const requiredVariables = [ + "HOST", + "PORT", + + "FQDN", + "BACKEND_URL", + ]; + + let hasError = false; + + for (const key of requiredVariables) { + const value = process.env[key]; + if (value === undefined || value.trim() === "") { + logger.error(`Missing or empty environment variable: ${key}`); + hasError = true; + } + } + + if (hasError) { + process.exit(1); + } +} + +export { environment, verifyRequiredVariables }; diff --git a/package.json b/package.json new file mode 100644 index 0000000..ed17f65 --- /dev/null +++ b/package.json @@ -0,0 +1,28 @@ +{ + "name": "atums.world.frontend", + "version": "0.0.0", + "description": "", + "private": true, + "type": "module", + "scripts": { + "start": "bun src/index.ts", + "dev": "bun src/index.ts --dev", + "build": "vite build", + "serve": "vite preview", + "lint": "bunx biome check", + "lint:fix": "bunx biome check --fix", + "cleanup": "rm -rf logs node_modules bun.lock" + }, + "license": "BSD-3-Clause", + "devDependencies": { + "@biomejs/biome": "^1.9.4", + "@types/bun": "^1.2.13", + "vite": "^6.3.5", + "vite-plugin-solid": "^2.11.6", + "vite-tsconfig-paths": "^5.1.4" + }, + "dependencies": { + "@creations.works/logger": "^1.0.3", + "solid-js": "^1.9.5" + } +} diff --git a/src/index.html b/src/index.html new file mode 100644 index 0000000..d62bd90 --- /dev/null +++ b/src/index.html @@ -0,0 +1,19 @@ + + + + + + + + + Solid App + + + + +
+ + + + + \ No newline at end of file diff --git a/src/index.ts b/src/index.ts new file mode 100644 index 0000000..d1695a2 --- /dev/null +++ b/src/index.ts @@ -0,0 +1,28 @@ +import { resolve } from "node:path"; +import { environment, verifyRequiredVariables } from "@config"; +import { logger } from "@creations.works/logger"; +import { createServer } from "vite"; +import solidPlugin from "vite-plugin-solid"; +import tsconfigPaths from "vite-tsconfig-paths"; + +verifyRequiredVariables(); + +const server = await createServer({ + root: resolve("src"), + publicDir: resolve("src/public"), + plugins: [solidPlugin(), tsconfigPaths()], + server: { + port: environment.port, + host: environment.host, + strictPort: true, + }, + build: { + target: "esnext", + }, +}); + +await server.listen(); + +logger.info( + `Server is running at http://${environment.host}:${environment.port}`, +); diff --git a/src/lib/char.ts b/src/lib/char.ts new file mode 100644 index 0000000..3d90743 --- /dev/null +++ b/src/lib/char.ts @@ -0,0 +1,5 @@ +export function normalizeFqdn(value?: string): string | null { + if (!value) return null; + if (!/^https?:\/\//.test(value)) return `https://${value}`; + return value; +} diff --git a/src/public/assets/favicon.ico b/src/public/assets/favicon.ico new file mode 100644 index 0000000..b836b2b Binary files /dev/null and b/src/public/assets/favicon.ico differ diff --git a/src/public/assets/logo.svg b/src/public/assets/logo.svg new file mode 100644 index 0000000..025aa30 --- /dev/null +++ b/src/public/assets/logo.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/views/App.tsx b/src/views/App.tsx new file mode 100644 index 0000000..8743f23 --- /dev/null +++ b/src/views/App.tsx @@ -0,0 +1,14 @@ +import type { Component } from "solid-js"; + +import styles from "@views/css/App.module.css"; + +const App: Component = () => { + return ( +
+
+
+
+ ); +}; + +export default App; diff --git a/src/views/css/App.module.css b/src/views/css/App.module.css new file mode 100644 index 0000000..d5c3782 --- /dev/null +++ b/src/views/css/App.module.css @@ -0,0 +1,33 @@ +.App { + text-align: center; +} + +.logo { + animation: logo-spin infinite 20s linear; + height: 40vmin; + pointer-events: none; +} + +.header { + background-color: #282c34; + min-height: 100vh; + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + font-size: calc(10px + 2vmin); + color: white; +} + +.link { + color: #b318f0; +} + +@keyframes logo-spin { + from { + transform: rotate(0deg); + } + to { + transform: rotate(360deg); + } +} diff --git a/src/views/css/index.css b/src/views/css/index.css new file mode 100644 index 0000000..e068437 --- /dev/null +++ b/src/views/css/index.css @@ -0,0 +1,13 @@ +body { + margin: 0; + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", + "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", + sans-serif; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} + +code { + font-family: source-code-pro, Menlo, Monaco, Consolas, "Courier New", + monospace; +} diff --git a/src/views/index.tsx b/src/views/index.tsx new file mode 100644 index 0000000..71637cf --- /dev/null +++ b/src/views/index.tsx @@ -0,0 +1,13 @@ +import { render } from "solid-js/web"; + +import "@views/css/index.css"; +import App from "@views/App"; + +const root = document.getElementById("root"); + +if (!(root instanceof HTMLElement)) { + throw new Error("Root element not found"); +} + +render(() => , root); + diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..7a08f4e --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,25 @@ +{ + "compilerOptions": { + "baseUrl": "./", + "paths": { + "@/*": ["src/*"], + "@views/*": ["src/views/*"], + "@config": ["config/index.ts"], + "@config/*": ["config/*"], + "@types/*": ["types/*"], + "@lib/*": ["src/lib/*"] + }, + "typeRoots": ["./src/types", "./node_modules/@types"], + "strict": true, + "target": "ESNext", + "module": "ESNext", + "moduleResolution": "node", + "allowSyntheticDefaultImports": true, + "esModuleInterop": true, + "jsx": "preserve", + "jsxImportSource": "solid-js", + "noEmit": true, + "isolatedModules": true + }, + "include": ["src", "types", "config"] +} diff --git a/types/config.d.ts b/types/config.d.ts new file mode 100644 index 0000000..1b60b8e --- /dev/null +++ b/types/config.d.ts @@ -0,0 +1,6 @@ +type Environment = { + port: number; + host: string; + development: boolean; + fqdn: string; +}; diff --git a/types/css.d.ts b/types/css.d.ts new file mode 100644 index 0000000..3f39e9d --- /dev/null +++ b/types/css.d.ts @@ -0,0 +1,4 @@ +declare module "*.module.css" { + const classes: { [key: string]: string }; + export default classes; +}