commit c78e96994d6f9e16d59abcd875402b3da7c74bd3 Author: Fernando Araoz Date: Sun Jan 26 15:00:34 2025 -0500 Init diff --git a/.env b/.env new file mode 100644 index 0000000..e4fa827 --- /dev/null +++ b/.env @@ -0,0 +1 @@ +VITE_BACKEND_URL=http://localhost:8000/api diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..76add87 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +node_modules +dist \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..8d9b3cd --- /dev/null +++ b/README.md @@ -0,0 +1,13 @@ +# Reezer + +Yet another rewrite of deemix, this time with: + +- Rust in the backend + - Rocket.rs as server + - Swagger API docs +- Solidjs in the frontend + - SPA mode + - Bun + - UnoCSS +- Docker + diff --git a/bun.lockb b/bun.lockb new file mode 100755 index 0000000..2471ce6 Binary files /dev/null and b/bun.lockb differ diff --git a/eslint.config.js b/eslint.config.js new file mode 100644 index 0000000..58eeab9 --- /dev/null +++ b/eslint.config.js @@ -0,0 +1,70 @@ +import globals from "globals" +import pluginJs from "@eslint/js" +import tseslint from "typescript-eslint" +import solid from "eslint-plugin-solid/configs/typescript" + +/** @type {import('eslint').Linter.Config[]} */ +export default [ + { files: ["**/*.{js,mjs,cjs,ts,jsx,tsx}"] }, + { languageOptions: { globals: globals.browser } }, + pluginJs.configs.recommended, + ...tseslint.configs.recommended, + solid, + { + rules: { + "indent": ["error", "tab"], + "brace-style": ["error", "allman"], + "no-tabs": "off", + "quotes": ["error", "double"], + "semi": ["error", "never"], + "semi-spacing": ["error", { "before": false, "after": true }], + "no-multiple-empty-lines": ["error", { "max": 1, "maxEOF": 1 }], + // migrated + "prefer-const": "error", + "no-const-assign": "error", + "no-var": "error", + "array-callback-return": "error", + "prefer-template": "error", + "template-curly-spacing": "error", + "no-useless-escape": "error", + "wrap-iife": "error", + "no-loop-func": "error", + "default-param-last": "error", + "space-before-function-paren": ["error", "never"], + "space-before-blocks": "error", + "no-param-reassign": "error", + "function-paren-newline": "error", + "comma-dangle": ["error", "always-multiline"], + "arrow-spacing": "error", + "arrow-parens": "error", + "arrow-body-style": "error", + "no-confusing-arrow": "error", + "implicit-arrow-linebreak": "error", + "no-duplicate-imports": "error", + "object-curly-newline": "error", + "dot-notation": "error", + "one-var": ["error", "never"], + "no-multi-assign": "error", + "no-plusplus": "error", + "operator-linebreak": "error", + "eqeqeq": "error", + "no-case-declarations": "error", + "no-nested-ternary": "error", + "no-unneeded-ternary": "error", + "no-mixed-operators": "error", + "nonblock-statement-body-position": "error", + "keyword-spacing": "error", + "space-infix-ops": "error", + "eol-last": "error", + "newline-per-chained-call": "error", + "no-whitespace-before-property": "error", + "space-in-parens": "error", + "array-bracket-spacing": "error", + "key-spacing": "error", + "no-trailing-spaces": "error", + "comma-style": "error", + "radix": "error", + "no-new-wrappers": "error", + }, + }, +] diff --git a/index.html b/index.html new file mode 100644 index 0000000..f3f8ef8 --- /dev/null +++ b/index.html @@ -0,0 +1,39 @@ + + + + + + + + + + Solid App + + + + + + +
+ + + + diff --git a/package.json b/package.json new file mode 100644 index 0000000..c45a137 --- /dev/null +++ b/package.json @@ -0,0 +1,36 @@ +{ + "name": "vite-template-solid", + "version": "0.0.0", + "description": "", + "type": "module", + "scripts": { + "start": "vite", + "dev": "vite", + "lint": "eslint . --fix", + "build": "vite build", + "serve": "vite preview" + }, + "license": "MIT", + "devDependencies": { + "@eslint/js": "^9.17.0", + "@types/bun": "latest", + "@typescript-eslint/eslint-plugin": "^8.19.0", + "@unocss/preset-wind": "^0.65.3", + "eslint": "^9.17.0", + "eslint-plugin-solid": "^0.14.5", + "globals": "^15.14.0", + "typescript": "^5.7.2", + "typescript-eslint": "^8.19.0", + "unocss": "^0.65.3", + "vite": "^6.0.0", + "vite-plugin-solid": "^2.11.0" + }, + "dependencies": { + "@solidjs/router": "^0.15.2", + "@tanstack/solid-query": "^5.62.10", + "@unocss/reset": "^0.65.3", + "add": "^2.0.6", + "solid-js": "^1.9.3" + }, + "module": "index.ts" +} diff --git a/src/assets/favicon.ico b/src/assets/favicon.ico new file mode 100644 index 0000000..b836b2b Binary files /dev/null and b/src/assets/favicon.ico differ diff --git a/src/components/input.tsx b/src/components/input.tsx new file mode 100644 index 0000000..dcead8b --- /dev/null +++ b/src/components/input.tsx @@ -0,0 +1,18 @@ +export function Input(props: { + id?: string, + name?: string, + type?: string, + placeholder: string, +}) +{ + return ( + + ) +} diff --git a/src/index.tsx b/src/index.tsx new file mode 100644 index 0000000..5f18a87 --- /dev/null +++ b/src/index.tsx @@ -0,0 +1,27 @@ +/* @refresh reload */ +import { render } from "solid-js/web" +import { Route, HashRouter } from "@solidjs/router" +import { QueryClientProvider } from "@tanstack/solid-query" +import { query_client } from "./utils/query" + +import "virtual:uno.css" +import "@unocss/reset/tailwind.css" + +import { IndexPage } from "./pages" +import { LoginPage } from "./pages/login" + +const root = document.getElementById("root") + +if (import.meta.env.DEV && !(root instanceof HTMLElement)) +{ + throw new Error("Root element not found. Did you forget to add it to your index.html? Or maybe the id attribute got misspelled?") +} + +render(() => ( + + + + + + +), root!) diff --git a/src/pages/index.tsx b/src/pages/index.tsx new file mode 100644 index 0000000..ca86d54 --- /dev/null +++ b/src/pages/index.tsx @@ -0,0 +1,8 @@ +export function IndexPage() +{ + return ( +
+ :D (happy) +
+ ) +} diff --git a/src/pages/login.tsx b/src/pages/login.tsx new file mode 100644 index 0000000..1855a2e --- /dev/null +++ b/src/pages/login.tsx @@ -0,0 +1,44 @@ +import { Input } from "../components/input" +import { fetch_api } from "../utils/query" + +export function LoginPage() +{ + async function onSubmit(ev: SubmitEvent) + { + fetch_api("/login", { + method: "post", + }) + ev.preventDefault() + console.log("loggin :D (submit)") + } + + return ( +
+

+ Login to Reezer +

+ +
+
+ +
+ +
+
+ +
+ +
+ +
+
+ ) +} diff --git a/src/utils/query.ts b/src/utils/query.ts new file mode 100644 index 0000000..e901af2 --- /dev/null +++ b/src/utils/query.ts @@ -0,0 +1,21 @@ +import { QueryClient } from "@tanstack/solid-query" + +const backend_url = import.meta.env.VITE_BACKEND_URL + +export async function fetch_api(url: string, options?: RequestInit) +{ + const response = await fetch(`${backend_url}${url}`, { + credentials: "include", + ...options, + }) + if (!response.ok) throw new Error("API error") + return response.json() +} + +export const query_client = new QueryClient({ + defaultOptions: { + queries: { + queryFn: ({ queryKey }) => fetch_api(queryKey[0]), + }, + }, +}) diff --git a/src/utils/types.ts b/src/utils/types.ts new file mode 100644 index 0000000..d48b08f --- /dev/null +++ b/src/utils/types.ts @@ -0,0 +1 @@ +export type Result = [Result | null, Error | null]; diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..249b273 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,15 @@ +{ + "compilerOptions": { + "strict": true, + "target": "ESNext", + "module": "ESNext", + "moduleResolution": "node", + "allowSyntheticDefaultImports": true, + "esModuleInterop": true, + "jsx": "preserve", + "jsxImportSource": "solid-js", + "types": ["vite/client"], + "noEmit": true, + "isolatedModules": true + } +} diff --git a/uno.config.ts b/uno.config.ts new file mode 100644 index 0000000..244a855 --- /dev/null +++ b/uno.config.ts @@ -0,0 +1,20 @@ +import presetWind from "@unocss/preset-wind" +import { defineConfig } from "unocss" + +export default defineConfig({ + // ...UnoCSS options + presets: [ + presetWind(), + ], + theme: { + colors: { + "c-bg": "var(--bg)", + "c-on-bg": "var(--on-bg)", + "c-root-color": "var(--root-color)", + "c-primary": "var(--primary)", + "c-on-primary": "var(--on-primary)", + "c-outline": "var(--outline)", + "c-on-surface-variant": "var(--on-surface-variant)", + }, + }, +}) diff --git a/vite.config.ts b/vite.config.ts new file mode 100644 index 0000000..988e8bd --- /dev/null +++ b/vite.config.ts @@ -0,0 +1,16 @@ +import UnoCSS from "unocss/vite" +import { defineConfig } from "vite" +import solidPlugin from "vite-plugin-solid" + +export default defineConfig({ + plugins: [ + UnoCSS(), + solidPlugin(), + ], + server: { + port: 3000, + }, + build: { + target: "esnext", + }, +})