diff --git a/.env.example b/.env.example index a10f7a4..d2b3d15 100644 --- a/.env.example +++ b/.env.example @@ -2,24 +2,6 @@ HOST=0.0.0.0 PORT=8080 -REDIS_URL=redis://dragonfly:6379 -REDIS_TTL=3600 # seconds - # this is only the default value if non is give in /id LANYARD_USER_ID=id-here LANYARD_INSTANCE=https://lanyard.rest - -# Required if you want to enable badges -BADGE_API_URL=http://localhost:8081 - -# Required if you want to enable reviews from reviewdb -REVIEW_DB=true - -#Timezone api url, aka: https://git.creations.works/creations/timezoneDB -TIMEZONE_API_URL= - -# https://www.steamgriddb.com/api/v2, if you want games to have images -STEAMGRIDDB_API_KEY=steamgrid_api_key - -# https://plausible.io -PLAUSIBLE_SCRIPT_HTML='' diff --git a/.gitignore b/.gitignore index 16498de..d0ef245 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,4 @@ /node_modules bun.lock .env -logs/ -.vscode/ -robots.txt -public/custom +logs/ \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..4a841f7 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "github-enterprise.uri": "https://git.creations.works" +} diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 2438f47..0000000 --- a/Dockerfile +++ /dev/null @@ -1,38 +0,0 @@ -# use the official Bun image -# see all versions at https://hub.docker.com/r/oven/bun/tags -FROM oven/bun:latest AS base -WORKDIR /usr/src/app - -FROM base AS install -RUN mkdir -p /temp/dev -COPY package.json bun.lock /temp/dev/ -RUN cd /temp/dev && bun install --frozen-lockfile - -# install with --production (exclude devDependencies) -RUN mkdir -p /temp/prod -COPY package.json bun.lock /temp/prod/ -RUN cd /temp/prod && bun install --frozen-lockfile --production - -# copy node_modules from temp directory -# then copy all (non-ignored) project files into the image -FROM base AS prerelease -COPY --from=install /temp/dev/node_modules node_modules -COPY . . - -# [optional] tests & build -ENV NODE_ENV=production - -# copy production dependencies and source code into final image -FROM base AS release -COPY --from=install /temp/prod/node_modules node_modules -COPY --from=prerelease /usr/src/app/src ./src -COPY --from=prerelease /usr/src/app/public ./public -COPY --from=prerelease /usr/src/app/package.json . -COPY --from=prerelease /usr/src/app/tsconfig.json . -COPY --from=prerelease /usr/src/app/config ./config -COPY --from=prerelease /usr/src/app/types ./types - -RUN mkdir -p /usr/src/app/logs && chown bun:bun /usr/src/app/logs - -USER bun -ENTRYPOINT [ "bun", "run", "start" ] diff --git a/LICENSE b/LICENSE index d93a942..6596881 100644 --- a/LICENSE +++ b/LICENSE @@ -1,28 +1,21 @@ -BSD 3-Clause License +MIT License -Copyright (c) 2025, creations.works +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: +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: -1. Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. -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. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md index f4b9394..81bfda2 100644 --- a/README.md +++ b/README.md @@ -1,36 +1,12 @@ # Discord Profile Page -A cool little web app that shows your Discord profile, current activity, and more. Built with Bun. +A cool little web app that shows your Discord profile, current activity, and more. Built with Bun and EJS. -# Preview -https://creations.works +## Prerequisite: Lanyard Backend ---- +This project depends on a self-hosted or public [Lanyard](https://github.com/Phineas/lanyard) instance for Discord presence data. -## Requirements - -This project depends on the following services to function properly: - -### 1. Lanyard Backend - -This project depends on a self-hosted or public [Lanyard](https://github.com/Phineas/lanyard) instance to fetch real-time Discord presence data. -Make sure the Lanyard instance is running and accessible before using this. - -### 2. Redis Instance - -A Redis-compatible key-value store is required to cache third-party data (e.g., SteamGridDB icons). -I recommend [Dragonfly](https://www.dragonflydb.io/), a high-performance drop-in replacement for Redis. - -### 3. Badge API - -A lightweight API to render Discord-style badges. ->Only needed if you want to show badges on profiles: -https://git.creations.works/creations/badgeAPI - -### 4. SteamGridDB - ->Only needed if you want to fetch game icons that Discord doesn’t provide: -https://www.steamgriddb.com/api/v2 +Make sure Lanyard is running and accessible before using this profile page. --- @@ -52,66 +28,35 @@ Copy the example environment file and update it: cp .env.example .env ``` -#### `.env` Variables +#### Required `.env` Variables -| Variable | Description | -|-----------------------|-----------------------------------------------------------------------------| -| `HOST` | Host to bind the Bun server (default: `0.0.0.0`) | -| `PORT` | Port to run the server on (default: `8080`) | -| `REDIS_URL` | Redis connection string | -| `LANYARD_USER_ID` | Your Discord user ID, for the default page | -| `LANYARD_INSTANCE` | Endpoint of the Lanyard instance | -| `BADGE_API_URL` | Badge API URL ([badgeAPI](https://git.creations.works/creations/badgeAPI)) | -| `REVIEW_DB` | Enables showing reviews from reviewdb on user pages | -| `TIMEZONE_API_URL` | Enables showing times from [timezoneDB](https://git.creations.works/creations/timezoneDB-rs) | -| `STEAMGRIDDB_API_KEY` | SteamGridDB API key for fetching game icons | +| Variable | Description | +|--------------------|--------------------------------------------------| +| `HOST` | Host to bind the Bun server (default: `0.0.0.0`) | +| `PORT` | Port to run the server on (default: `8080`) | +| `LANYARD_USER_ID` | Your Discord user ID | +| `LANYARD_INSTANCE` | Lanyard WebSocket endpoint URL | -#### Optional Lanyard KV Variables (per-user customization) +#### Optional Lanyard KV Vars (per-user customization) -These can be defined in Lanyard's KV store to customize the page: +These are expected to be defined in Lanyard's KV store: -| Variable | Description | -|-----------|--------------------------------------------------------------------| -| `snow` | Enables snow background (`true` / `false`) | -| `rain` | Enables rain background (`true` / `false`) | -| `stars` | Enables starfield background (`true` / `false`) | -| `badges` | Enables badge fetching (`true` / `false`) | -| `readme` | URL to a README displayed on the profile (`.md` or `.html`) | -| `css` | URL to a css to change styles on the page, no import or require allowed | -| `optout` | Allows users to stop sharing there profile on the website (`true` / `false`) | -| `reviews` | Enables reviews from reviewdb (`true` / `false`) | -| `timezone`| Enables the showing of the current time from the timezone db API (`true` / `false`) | -| `timezone_12` | Sets the timezone to default show 12h format, default is 24h | +| Variable | Description | +|-----------|-------------------------------------------------------------| +| `snow` | Enables snow background effect (`true`) | +| `rain` | Enables rain background effect (`true`) | +| `readme` | URL to a README file displayed on your profile | +| `colors` | Enables avatar-based color theme (uses `node-vibrant`) | --- -### 3. Start the Instance +### 3. Start the App ```bash bun run start ``` ---- - -## Optional: Analytics with Plausible - -You can enable [Plausible Analytics](https://plausible.io) tracking by setting a script snippet in your environment. - -### `.env` Variable - -| Variable | Description | -|-------------------------|------------------------------------------------------------------------| -| `PLAUSIBLE_SCRIPT_HTML` | Full `' -``` - -- The script will only be injected if this variable is set. -- Plausible provides the correct script when you add a domain. -- Be sure to wrap it in single quotes (`'`) so it works in `.env`. +Then open `http://localhost:8080` in your browser. --- @@ -123,23 +68,20 @@ PLAUSIBLE_SCRIPT_HTML=' + + <% if (allowSnow) { %> + + <% } %> + <% if(allowRain) { %> + + <% } %> + + + + +<%- include('partial/style.ejs') %> + +
+