diff --git a/.gitignore b/.gitignore old mode 100644 new mode 100755 index ceaea36..6d858fe --- a/.gitignore +++ b/.gitignore @@ -1,132 +1,25 @@ -# ---> Node -# Logs -logs -*.log -npm-debug.log* -yarn-debug.log* -yarn-error.log* -lerna-debug.log* -.pnpm-debug.log* +node_modules -# Diagnostic reports (https://nodejs.org/api/report.html) -report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json +# Output +.output +.vercel +.netlify +.wrangler +/.svelte-kit +/build -# Runtime data -pids -*.pid -*.seed -*.pid.lock +# OS +.DS_Store +Thumbs.db -# Directory for instrumented libs generated by jscoverage/JSCover -lib-cov - -# Coverage directory used by tools like istanbul -coverage -*.lcov - -# nyc test coverage -.nyc_output - -# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) -.grunt - -# Bower dependency directory (https://bower.io/) -bower_components - -# node-waf configuration -.lock-wscript - -# Compiled binary addons (https://nodejs.org/api/addons.html) -build/Release - -# Dependency directories -node_modules/ -jspm_packages/ - -# Snowpack dependency directory (https://snowpack.dev/) -web_modules/ - -# TypeScript cache -*.tsbuildinfo - -# Optional npm cache directory -.npm - -# Optional eslint cache -.eslintcache - -# Optional stylelint cache -.stylelintcache - -# Microbundle cache -.rpt2_cache/ -.rts2_cache_cjs/ -.rts2_cache_es/ -.rts2_cache_umd/ - -# Optional REPL history -.node_repl_history - -# Output of 'npm pack' -*.tgz - -# Yarn Integrity file -.yarn-integrity - -# dotenv environment variable files +# Env .env -.env.development.local -.env.test.local -.env.production.local -.env.local +.env.* +!.env.example +!.env.test -# parcel-bundler cache (https://parceljs.org/) -.cache -.parcel-cache - -# Next.js build output -.next -out - -# Nuxt.js build / generate output -.nuxt -dist - -# Gatsby files -.cache/ -# Comment in the public line in if your project uses Gatsby and not Next.js -# https://nextjs.org/blog/next-9-1#public-directory-support -# public - -# vuepress build output -.vuepress/dist - -# vuepress v2.x temp and cache directory -.temp -.cache - -# Docusaurus cache and generated files -.docusaurus - -# Serverless directories -.serverless/ - -# FuseBox cache -.fusebox/ - -# DynamoDB Local files -.dynamodb/ - -# TernJS port file -.tern-port - -# Stores VSCode versions used for testing VSCode extensions -.vscode-test - -# yarn v2 -.yarn/cache -.yarn/unplugged -.yarn/build-state.yml -.yarn/install-state.gz -.pnp.* +# Vite +vite.config.js.timestamp-* +vite.config.ts.timestamp-* +bun.lock diff --git a/package.json b/package.json new file mode 100755 index 0000000..b80ccf9 --- /dev/null +++ b/package.json @@ -0,0 +1,40 @@ +{ + "name": "humandex-web", + "private": true, + "version": "0.0.1", + "type": "module", + "scripts": { + "start": "bun run build && node server/server.js", + "dev": "vite dev --host", + "build": "vite build" + }, + "devDependencies": { + "@skeletonlabs/skeleton": "^3.2.2", + "@skeletonlabs/skeleton-svelte": "^1.5.3", + "@sveltejs/adapter-auto": "^4.0.0", + "@sveltejs/kit": "^2.47.3", + "@sveltejs/vite-plugin-svelte": "^5.1.1", + "@tailwindcss/forms": "^0.5.10", + "@tailwindcss/typography": "^0.5.19", + "@tailwindcss/vite": "^4.1.16", + "mdsvex": "^0.12.6", + "svelte": "^5.41.2", + "svelte-check": "^4.3.3", + "tailwindcss": "^4.1.16", + "typescript": "^5.9.3", + "vite": "^6.4.1" + }, + "dependencies": { + "@auth/sveltekit": "^1.11.0", + "@iconify/svelte": "^5.0.2", + "@sveltejs/adapter-node": "^5.4.0", + "axios": "^1.12.2", + "bufferutil": "^4.0.9", + "cors": "^2.8.5", + "discord.js": "^14.23.2", + "dotenv": "^16.6.1", + "express": "^5.1.0", + "mongoose": "^8.19.2", + "ms": "^2.1.3" + } +} diff --git a/server/server.js b/server/server.js new file mode 100755 index 0000000..bf8d692 --- /dev/null +++ b/server/server.js @@ -0,0 +1,28 @@ +// @ts-nocheck +import { handler } from '../build/handler.js'; +import dotenv from 'dotenv'; +import http from 'http'; +import express from 'express'; +import cors from 'cors'; + +dotenv.config(); + +const app = express(); +const server = http.Server(app); + +app.use(cors()); + +app.use(handler); + +server.listen(process.env.PORT, () => { + console.log(`listening on port http://localhost:${process.env.PORT}`); +}); + +process.on('unhandledRejection', (reason, promise) => { + console.log('Unhandled Rejection at:', reason.stack || reason); +}); + +process.on('uncaughtException', (error) => { + console.log('Uncaught Exception thrown'); + console.error(error); +}); \ No newline at end of file diff --git a/src/app.css b/src/app.css new file mode 100755 index 0000000..00969f1 --- /dev/null +++ b/src/app.css @@ -0,0 +1,9 @@ +@import 'tailwindcss'; +@plugin '@tailwindcss/forms'; +@plugin '@tailwindcss/typography'; + +@import '@skeletonlabs/skeleton'; +@import '@skeletonlabs/skeleton/optional/presets'; +@import '@skeletonlabs/skeleton/themes/cerberus'; + +@source '../node_modules/@skeletonlabs/skeleton-svelte/dist'; \ No newline at end of file diff --git a/src/app.d.ts b/src/app.d.ts new file mode 100755 index 0000000..da08e6d --- /dev/null +++ b/src/app.d.ts @@ -0,0 +1,13 @@ +// See https://svelte.dev/docs/kit/types#app.d.ts +// for information about these interfaces +declare global { + namespace App { + // interface Error {} + // interface Locals {} + // interface PageData {} + // interface PageState {} + // interface Platform {} + } +} + +export {}; diff --git a/src/app.html b/src/app.html new file mode 100755 index 0000000..9198cf0 --- /dev/null +++ b/src/app.html @@ -0,0 +1,12 @@ + + + + + + + %sveltekit.head% + + +
%sveltekit.body%
+ + diff --git a/src/lib/components/DexEntry.svelte b/src/lib/components/DexEntry.svelte new file mode 100644 index 0000000..ba8dbc4 --- /dev/null +++ b/src/lib/components/DexEntry.svelte @@ -0,0 +1,105 @@ + + +
+
+ {#if editable} +
{ if (e.key === 'Enter' || e.key === ' ' || e.key === 'Spacebar') { e.preventDefault(); onClick(); } }} title="Click to replace image"> + {#if imageSrc} + {displayName} + {:else} +
+
{displayName}
+
Click to add your photo
+
+ {/if} +
+ +
+
+ {:else} +
+ {#if imageSrc} + {displayName} + {:else} +
+
{displayName}
+
No image
+
+ {/if} +
+ Open +
+
+ {/if} +
+
{name}
+
#{id}
+
+
+ + +
+ + \ No newline at end of file diff --git a/src/lib/components/Footer.svelte b/src/lib/components/Footer.svelte new file mode 100644 index 0000000..107d6e1 --- /dev/null +++ b/src/lib/components/Footer.svelte @@ -0,0 +1,110 @@ + + + + + diff --git a/src/lib/components/NavBar.svelte b/src/lib/components/NavBar.svelte new file mode 100644 index 0000000..5314ced --- /dev/null +++ b/src/lib/components/NavBar.svelte @@ -0,0 +1,64 @@ + + + \ No newline at end of file diff --git a/src/lib/ts/Userdb.ts b/src/lib/ts/Userdb.ts new file mode 100755 index 0000000..547ce05 --- /dev/null +++ b/src/lib/ts/Userdb.ts @@ -0,0 +1,51 @@ +import mongoose from 'mongoose'; + +const reqString = { + type: String, + required: true, +} + +const userSchema = new mongoose.Schema({ + id: reqString, + image: String, +}); + + +export interface UserData { + id: string; // Discord ID + image?: string; // Base64 encoded image string +} + + +export default class Userdb { + model: mongoose.Model; + upsert: { upsert: boolean; }; + constructor() { + this.model = mongoose.model('users', userSchema); + this.upsert = { upsert: true }; + } + + async create(id: string, email: string, uuid: string): Promise { + await this.model.findOneAndUpdate({ id: id }, { id: id }, this.upsert); + return await this.get(id); + } + + async getAll(): Promise { + return await this.model.find(); + } + + async get(Id: string): Promise { + return await this.model.findOne({ id: Id }); + } + + + async update(Id: string, data: any): Promise { + await this.model.findOneAndUpdate({ id: Id }, data, this.upsert); + return await this.get(Id); + } + + async delete(Id: string): Promise { + return await this.model.findOneAndDelete({ id: Id }); + } + +} \ No newline at end of file diff --git a/src/lib/ts/db.ts b/src/lib/ts/db.ts new file mode 100755 index 0000000..ae356ba --- /dev/null +++ b/src/lib/ts/db.ts @@ -0,0 +1,20 @@ +import { SECRET_DB_URI } from "$env/static/private"; +import mongoose from "mongoose"; + +import Playerdb from "./Userdb"; + +class DB { + dbs: any; + players: Playerdb; + constructor() { + this.players = new Playerdb(); + this.connect(); + } + + connect() { + mongoose.set('strictQuery', true); + mongoose.connect(SECRET_DB_URI).then(() => { console.log("Connected to DataBase") }); + } +} + +export const db = new DB(); \ No newline at end of file diff --git a/src/routes/+error.svelte b/src/routes/+error.svelte new file mode 100755 index 0000000..d3dea71 --- /dev/null +++ b/src/routes/+error.svelte @@ -0,0 +1,3 @@ +
+

404 or 500 or idk :(

+
\ No newline at end of file diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte new file mode 100755 index 0000000..ca25383 --- /dev/null +++ b/src/routes/+layout.svelte @@ -0,0 +1,26 @@ + + + + HumanDex + + + + + + + + +
+ +
+ {@render children()} +
+
+
diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte new file mode 100755 index 0000000..ea9385a --- /dev/null +++ b/src/routes/+page.svelte @@ -0,0 +1,87 @@ + + +
+

HumanDex — Pokémon Pokedex for Humans

+ +
+ {#each generations as gen (gen.id)} +
{ if ((e.currentTarget as HTMLDetailsElement).open) loadGeneration(gen.id); }}> + +
{gen.name}
+
{genData[gen.id]?.loaded ? `${genData[gen.id].pokemon.length} Pokémon` : genData[gen.id]?.loading ? 'Loading…' : 'Open to load'}
+
+ + {#if genData[gen.id]?.loading} +
Loading {gen.name}…
+ {:else if genData[gen.id]?.loaded} +
+ {#each genData[gen.id].pokemon as p (p.id)} + + {/each} +
+ {:else} +
Open the generation to load Pokémon.
+ {/if} +
+ {/each} +
+
\ No newline at end of file diff --git a/src/routes/dex/[number]/+page.svelte b/src/routes/dex/[number]/+page.svelte new file mode 100644 index 0000000..22ea4b8 --- /dev/null +++ b/src/routes/dex/[number]/+page.svelte @@ -0,0 +1,117 @@ + + +{#if loading} +
Loading pokedex entry #{pokeId}…
+{:else} +
+
+
+ +
+
+

{name} #{pokeId}

+ +
+ + +
+ +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ +
+ + +
+
+
+
+{/if} + + diff --git a/static/favicon.png b/static/favicon.png new file mode 100644 index 0000000..5c35653 Binary files /dev/null and b/static/favicon.png differ diff --git a/svelte.config.js b/svelte.config.js new file mode 100755 index 0000000..a88e026 --- /dev/null +++ b/svelte.config.js @@ -0,0 +1,14 @@ +import { mdsvex } from "mdsvex"; +import adapter from '@sveltejs/adapter-node'; +import { vitePreprocess } from '@sveltejs/vite-plugin-svelte'; + +/** @type {import('@sveltejs/kit').Config} */ +const config = { + preprocess: [mdsvex({ extensions: ['.svx', '.md'] }), vitePreprocess()], + kit: { + adapter: adapter() + }, + extensions: ['.svelte', '.svx', '.md'], +}; + +export default config; diff --git a/tsconfig.json b/tsconfig.json new file mode 100755 index 0000000..0b2d886 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,19 @@ +{ + "extends": "./.svelte-kit/tsconfig.json", + "compilerOptions": { + "allowJs": true, + "checkJs": true, + "esModuleInterop": true, + "forceConsistentCasingInFileNames": true, + "resolveJsonModule": true, + "skipLibCheck": true, + "sourceMap": true, + "strict": true, + "moduleResolution": "bundler" + } + // Path aliases are handled by https://svelte.dev/docs/kit/configuration#alias + // except $lib which is handled by https://svelte.dev/docs/kit/configuration#files + // + // If you want to overwrite includes/excludes, make sure to copy over the relevant includes/excludes + // from the referenced tsconfig.json - TypeScript does not merge them in +} diff --git a/vite.config.ts b/vite.config.ts new file mode 100755 index 0000000..3ca802f --- /dev/null +++ b/vite.config.ts @@ -0,0 +1,7 @@ +import tailwindcss from "@tailwindcss/vite"; +import { sveltekit } from '@sveltejs/kit/vite'; +import { defineConfig } from 'vite'; + +export default defineConfig({ + plugins: [tailwindcss(), sveltekit()] +});