diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 6e87a00..0000000 --- a/.editorconfig +++ /dev/null @@ -1,13 +0,0 @@ -# Editor configuration, see http://editorconfig.org -root = true - -[*] -charset = utf-8 -indent_style = space -indent_size = 2 -insert_final_newline = true -trim_trailing_whitespace = true - -[*.md] -max_line_length = off -trim_trailing_whitespace = false diff --git a/.env b/.env index e69de29..5a74118 100644 --- a/.env +++ b/.env @@ -0,0 +1,19 @@ +<<<<<<< Updated upstream +======= +# When adding additional environment variables, the schema in "/src/env.js" +# should be updated accordingly. + +# Drizzle +DATABASE_URL="postgresql://postgres:hackme@localhost:5432/opengifame" + +# Next Auth +# You can generate a new secret on the command line with: +# openssl rand -base64 32 +# https://next-auth.js.org/configuration/options#secret +# NEXTAUTH_SECRET="" +NEXTAUTH_URL="http://localhost:3000" + +# Next Auth Discord Provider +DISCORD_CLIENT_ID="" +DISCORD_CLIENT_SECRET="" +>>>>>>> Stashed changes diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..5c019e2 --- /dev/null +++ b/.env.example @@ -0,0 +1,20 @@ +# Since the ".env" file is gitignored, you can use the ".env.example" file to +# build a new ".env" file when you clone the repo. Keep this file up-to-date +# when you add new variables to `.env`. + +# This file will be committed to version control, so make sure not to have any +# secrets in it. If you are cloning this repo, create a copy of this file named +# ".env" and populate it with your secrets. + +# When adding additional environment variables, the schema in "/src/env.js" +# should be updated accordingly. + +# Drizzle +DATABASE_URL="postgresql://postgres:password@localhost:5432/opengifame" + +# Next Auth +# You can generate a new secret on the command line with: +# openssl rand -base64 32 +# https://next-auth.js.org/configuration/options#secret +# NEXTAUTH_SECRET="" +NEXTAUTH_URL="http://localhost:3000" diff --git a/.eslintrc.cjs b/.eslintrc.cjs new file mode 100644 index 0000000..88c180d --- /dev/null +++ b/.eslintrc.cjs @@ -0,0 +1,61 @@ +/** @type {import("eslint").Linter.Config} */ +const config = { + "parser": "@typescript-eslint/parser", + "parserOptions": { + "project": true + }, + "plugins": [ + "@typescript-eslint", + "drizzle" + ], + "extends": [ + "next/core-web-vitals", + "plugin:@typescript-eslint/recommended-type-checked", + "plugin:@typescript-eslint/stylistic-type-checked" + ], + "rules": { + "@typescript-eslint/array-type": "off", + "@typescript-eslint/consistent-type-definitions": "off", + "@typescript-eslint/consistent-type-imports": [ + "warn", + { + "prefer": "type-imports", + "fixStyle": "inline-type-imports" + } + ], + "@typescript-eslint/no-unused-vars": [ + "warn", + { + "argsIgnorePattern": "^_" + } + ], + "@typescript-eslint/require-await": "off", + "@typescript-eslint/no-misused-promises": [ + "error", + { + "checksVoidReturn": { + "attributes": false + } + } + ], + "drizzle/enforce-delete-with-where": [ + "error", + { + "drizzleObjectName": [ + "db", + "ctx.db" + ] + } + ], + "drizzle/enforce-update-with-where": [ + "error", + { + "drizzleObjectName": [ + "db", + "ctx.db" + ] + } + ] + } +} +module.exports = config; \ No newline at end of file diff --git a/.eslintrc.json b/.eslintrc.json deleted file mode 100644 index f0f3abe..0000000 --- a/.eslintrc.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "extends": "next/core-web-vitals", - "rules": { - "@next/next/no-img-element": "off" - } -} diff --git a/.gitignore b/.gitignore index 2f23c6a..c24a835 100644 --- a/.gitignore +++ b/.gitignore @@ -8,9 +8,15 @@ # testing /coverage +# database +/prisma/db.sqlite +/prisma/db.sqlite-journal +db.sqlite + # next.js /.next/ /out/ +next-env.d.ts # production /build @@ -26,6 +32,8 @@ yarn-error.log* .pnpm-debug.log* # local env files +# do not commit any .env files to git, except for the .env.example file. https://create.t3.gg/en/usage/env-variables#using-environment-variables +.env .env*.local # vercel @@ -33,10 +41,6 @@ yarn-error.log* # typescript *.tsbuildinfo -next-env.d.ts -.vscode -.env.development -.env.production -public/uploads -.working/ +# idea files +.idea \ No newline at end of file diff --git a/.hintrc b/.hintrc deleted file mode 100644 index 798957b..0000000 --- a/.hintrc +++ /dev/null @@ -1,8 +0,0 @@ -{ - "extends": [ - "development" - ], - "hints": { - "apple-touch-icons": "off" - } -} \ No newline at end of file diff --git a/.idea/.gitignore b/.idea/.gitignore deleted file mode 100644 index b58b603..0000000 --- a/.idea/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -# Default ignored files -/shelf/ -/workspace.xml -# Editor-based HTTP Client requests -/httpRequests/ diff --git a/.idea/frasier-gifs.iml b/.idea/frasier-gifs.iml deleted file mode 100644 index 16cefcd..0000000 --- a/.idea/frasier-gifs.iml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml deleted file mode 100644 index 03d9549..0000000 --- a/.idea/inspectionProfiles/Project_Default.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml deleted file mode 100644 index 1a66899..0000000 --- a/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 35eb1dd..0000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.prettierrc b/.prettierrc deleted file mode 100644 index b84a01b..0000000 --- a/.prettierrc +++ /dev/null @@ -1,5 +0,0 @@ -{ - "singleAttributePerLine": true, - "singleQuote": true, - "semi": true -} diff --git a/.vercelignore b/.vercelignore deleted file mode 100644 index c68096e..0000000 --- a/.vercelignore +++ /dev/null @@ -1,2 +0,0 @@ -public/samples -public/uploads diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..bfe9c31 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "workbench.colorTheme": "SynthWave '84" +} \ No newline at end of file diff --git a/LICENSE b/LICENSE deleted file mode 100644 index 336f0e5..0000000 --- a/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2022 Fergal Moran - -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: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -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 41667f5..d89f750 100644 --- a/README.md +++ b/README.md @@ -1,3 +1 @@ -# Open Gifame - -Open source gif hosting for nerds. +# Warning, may contain traces of webp diff --git a/app/(site)/auth/error/page.tsx b/app/(site)/auth/error/page.tsx deleted file mode 100644 index 846debf..0000000 --- a/app/(site)/auth/error/page.tsx +++ /dev/null @@ -1,7 +0,0 @@ -import React from 'react'; - -const ErrorPage = () => { - return
ErrorPage
; -}; - -export default ErrorPage; diff --git a/app/(site)/request/page.tsx b/app/(site)/request/page.tsx deleted file mode 100644 index c690edc..0000000 --- a/app/(site)/request/page.tsx +++ /dev/null @@ -1,25 +0,0 @@ -import React from 'react'; - -const RequestPage = () => { - return ( -
-
-

- - Work in progress - - - Request a gif - -

-

- Here you can allow your users to request a gif, if you have the TV - Show module enabled you can allow Season/Episode/Timestamp/Duration - type stuff -

-
-
- ); -}; - -export default RequestPage; diff --git a/bun.lockb b/bun.lockb new file mode 100755 index 0000000..cd78744 Binary files /dev/null and b/bun.lockb differ diff --git a/drizzle.config.ts b/drizzle.config.ts new file mode 100644 index 0000000..16e1275 --- /dev/null +++ b/drizzle.config.ts @@ -0,0 +1,12 @@ +import { type Config } from "drizzle-kit"; + +import { env } from "@/env"; + +export default { + schema: "./src/server/db/schema.ts", + dialect: "postgresql", + dbCredentials: { + url: env.DATABASE_URL, + }, + tablesFilter: ["opengifame_*"], +} satisfies Config; diff --git a/drizzle/0000_sleepy_whizzer.sql b/drizzle/0000_sleepy_whizzer.sql new file mode 100644 index 0000000..fc70fdf --- /dev/null +++ b/drizzle/0000_sleepy_whizzer.sql @@ -0,0 +1,66 @@ +CREATE TABLE IF NOT EXISTS "opengifame_account" ( + "user_id" varchar(255) NOT NULL, + "type" varchar(255) NOT NULL, + "provider" varchar(255) NOT NULL, + "provider_account_id" varchar(255) NOT NULL, + "refresh_token" text, + "access_token" text, + "expires_at" integer, + "token_type" varchar(255), + "scope" varchar(255), + "id_token" text, + "session_state" varchar(255), + CONSTRAINT "opengifame_account_provider_provider_account_id_pk" PRIMARY KEY("provider","provider_account_id") +); +--> statement-breakpoint +CREATE TABLE IF NOT EXISTS "opengifame_post" ( + "id" serial PRIMARY KEY NOT NULL, + "name" varchar(256), + "created_by" varchar(255) NOT NULL, + "created_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + "updated_at" timestamp with time zone +); +--> statement-breakpoint +CREATE TABLE IF NOT EXISTS "opengifame_session" ( + "session_token" varchar(255) PRIMARY KEY NOT NULL, + "user_id" varchar(255) NOT NULL, + "expires" timestamp with time zone NOT NULL +); +--> statement-breakpoint +CREATE TABLE IF NOT EXISTS "opengifame_user" ( + "id" varchar(255) PRIMARY KEY NOT NULL, + "name" varchar(255), + "email" varchar(255) NOT NULL, + "email_verified" timestamp with time zone DEFAULT CURRENT_TIMESTAMP, + "image" varchar(255) +); +--> statement-breakpoint +CREATE TABLE IF NOT EXISTS "opengifame_verification_token" ( + "identifier" varchar(255) NOT NULL, + "token" varchar(255) NOT NULL, + "expires" timestamp with time zone NOT NULL, + CONSTRAINT "opengifame_verification_token_identifier_token_pk" PRIMARY KEY("identifier","token") +); +--> statement-breakpoint +DO $$ BEGIN + ALTER TABLE "opengifame_account" ADD CONSTRAINT "opengifame_account_user_id_opengifame_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."opengifame_user"("id") ON DELETE no action ON UPDATE no action; +EXCEPTION + WHEN duplicate_object THEN null; +END $$; +--> statement-breakpoint +DO $$ BEGIN + ALTER TABLE "opengifame_post" ADD CONSTRAINT "opengifame_post_created_by_opengifame_user_id_fk" FOREIGN KEY ("created_by") REFERENCES "public"."opengifame_user"("id") ON DELETE no action ON UPDATE no action; +EXCEPTION + WHEN duplicate_object THEN null; +END $$; +--> statement-breakpoint +DO $$ BEGIN + ALTER TABLE "opengifame_session" ADD CONSTRAINT "opengifame_session_user_id_opengifame_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."opengifame_user"("id") ON DELETE no action ON UPDATE no action; +EXCEPTION + WHEN duplicate_object THEN null; +END $$; +--> statement-breakpoint +CREATE INDEX IF NOT EXISTS "account_user_id_idx" ON "opengifame_account" USING btree ("user_id");--> statement-breakpoint +CREATE INDEX IF NOT EXISTS "created_by_idx" ON "opengifame_post" USING btree ("created_by");--> statement-breakpoint +CREATE INDEX IF NOT EXISTS "name_idx" ON "opengifame_post" USING btree ("name");--> statement-breakpoint +CREATE INDEX IF NOT EXISTS "session_user_id_idx" ON "opengifame_session" USING btree ("user_id"); \ No newline at end of file diff --git a/drizzle/meta/0000_snapshot.json b/drizzle/meta/0000_snapshot.json new file mode 100644 index 0000000..16077dc --- /dev/null +++ b/drizzle/meta/0000_snapshot.json @@ -0,0 +1,351 @@ +{ + "id": "eba24bbe-db75-4d3a-a69e-fc8fc26a5173", + "prevId": "00000000-0000-0000-0000-000000000000", + "version": "7", + "dialect": "postgresql", + "tables": { + "public.opengifame_account": { + "name": "opengifame_account", + "schema": "", + "columns": { + "user_id": { + "name": "user_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "provider": { + "name": "provider", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "provider_account_id": { + "name": "provider_account_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "refresh_token": { + "name": "refresh_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "access_token": { + "name": "access_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "expires_at": { + "name": "expires_at", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "token_type": { + "name": "token_type", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "scope": { + "name": "scope", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "id_token": { + "name": "id_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "session_state": { + "name": "session_state", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "account_user_id_idx": { + "name": "account_user_id_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "opengifame_account_user_id_opengifame_user_id_fk": { + "name": "opengifame_account_user_id_opengifame_user_id_fk", + "tableFrom": "opengifame_account", + "tableTo": "opengifame_user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "opengifame_account_provider_provider_account_id_pk": { + "name": "opengifame_account_provider_provider_account_id_pk", + "columns": [ + "provider", + "provider_account_id" + ] + } + }, + "uniqueConstraints": {} + }, + "public.opengifame_post": { + "name": "opengifame_post", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(256)", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "created_by_idx": { + "name": "created_by_idx", + "columns": [ + { + "expression": "created_by", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "name_idx": { + "name": "name_idx", + "columns": [ + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "opengifame_post_created_by_opengifame_user_id_fk": { + "name": "opengifame_post_created_by_opengifame_user_id_fk", + "tableFrom": "opengifame_post", + "tableTo": "opengifame_user", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "public.opengifame_session": { + "name": "opengifame_session", + "schema": "", + "columns": { + "session_token": { + "name": "session_token", + "type": "varchar(255)", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "expires": { + "name": "expires", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "session_user_id_idx": { + "name": "session_user_id_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "opengifame_session_user_id_opengifame_user_id_fk": { + "name": "opengifame_session_user_id_opengifame_user_id_fk", + "tableFrom": "opengifame_session", + "tableTo": "opengifame_user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "public.opengifame_user": { + "name": "opengifame_user", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "varchar(255)", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "email": { + "name": "email", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "email_verified": { + "name": "email_verified", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false, + "default": "CURRENT_TIMESTAMP" + }, + "image": { + "name": "image", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "public.opengifame_verification_token": { + "name": "opengifame_verification_token", + "schema": "", + "columns": { + "identifier": { + "name": "identifier", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "expires": { + "name": "expires", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "opengifame_verification_token_identifier_token_pk": { + "name": "opengifame_verification_token_identifier_token_pk", + "columns": [ + "identifier", + "token" + ] + } + }, + "uniqueConstraints": {} + } + }, + "enums": {}, + "schemas": {}, + "sequences": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/drizzle/meta/_journal.json b/drizzle/meta/_journal.json new file mode 100644 index 0000000..d5af5f8 --- /dev/null +++ b/drizzle/meta/_journal.json @@ -0,0 +1,13 @@ +{ + "version": "7", + "dialect": "postgresql", + "entries": [ + { + "idx": 0, + "version": "7", + "when": 1725317790880, + "tag": "0000_sleepy_whizzer", + "breakpoints": true + } + ] +} \ No newline at end of file diff --git a/hosting/Dockerfile b/hosting/Dockerfile deleted file mode 100644 index e0681bf..0000000 --- a/hosting/Dockerfile +++ /dev/null @@ -1,49 +0,0 @@ -# Install dependencies only when needed -FROM node:16-alpine AS deps - -RUN apk add --no-cache libc6-compat -WORKDIR /app - -COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* ./ -RUN \ - if [ -f yarn.lock ]; then yarn --frozen-lockfile; \ - elif [ -f package-lock.json ]; then npm ci; \ - elif [ -f pnpm-lock.yaml ]; then yarn global add pnpm && pnpm i --frozen-lockfile; \ - else echo "Lockfile not found." && exit 1; \ - fi - -# Rebuild the source code only when needed -FROM node:16-alpine AS builder -WORKDIR /app -COPY --from=deps /app/node_modules ./node_modules -COPY . . - -ENV NEXT_TELEMETRY_DISABLED 1 -RUN npx prisma generate -RUN yarn build - -FROM node:16-alpine AS runner -WORKDIR /app - -ENV NODE_ENV production -ENV NEXT_TELEMETRY_DISABLED 1 - -RUN addgroup --system --gid 1001 nodejs -RUN adduser --system --uid 1001 nextjs - -COPY --from=builder /app/public ./public -COPY --from=builder /app/prisma/seed.ts ./prisma/seed.ts -RUN npm install --global ts-node - -# Automatically leverage output traces to reduce image size -# https://nextjs.org/docs/advanced-features/output-file-tracing -COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./ -COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static -COPY --from=builder --chown=nextjs:nodejs /app/prisma ./prisma - -USER nextjs - -EXPOSE 3000 -ENV PORT 3000 - -CMD ["yarn", "start:prod:migrate"] diff --git a/hosting/docker-compose.yaml b/hosting/docker-compose.yaml deleted file mode 100644 index 7c5fb22..0000000 --- a/hosting/docker-compose.yaml +++ /dev/null @@ -1,38 +0,0 @@ -version: "3.3" - -services: - app: - image: ghcr.io/fergalmoran/opengifame - volumes: - - type: volume - source: uploads - target: /app/public/uploads - volume: - nocopy: true - ports: - - "3043:3000" - depends_on: - - "db" - environment: - - DB_CONNECTION=${DB_CONNECTION:-secret} - - ADMIN_USER=${ADMIN_USER:-fergal.moran+live@gmail.com} - - ADMIN_PASSWORD=${ADMIN_PASSWORD:-secret} - - DATABASE_URL=${DATABASE_URL:-postgresql://postgres:secret@db:5432/opengifame?schema=public} - - SECRET_KEY==${SECRET_KEY:-PLEASEDONTUSETHIS} - - NEXTAUTH_URL==${NEXTAUTH_URL:-https://dev.fergl.ie:3000} - db: - image: postgres:13 - volumes: - - type: volume - source: data - target: /var/lib/postgresql/data - volume: - nocopy: true - ports: - - "5432:5432" - environment: - - POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-secret} - - POSTGRES_DB=${POSTGRES_DB-opengifame} -volumes: - uploads: - data: diff --git a/lib/browser.ts b/lib/browser.ts deleted file mode 100644 index 8cd2b0b..0000000 --- a/lib/browser.ts +++ /dev/null @@ -1,22 +0,0 @@ -import cookie from 'cookie'; -import { ParsedUrlQuery } from 'querystring'; - -export const generateBrowserId = () => { - // always start with a letter (for DOM friendlyness) - var idstr = String.fromCharCode(Math.floor(Math.random() * 25 + 65)); - do { - // between numbers and characters (48 is 0 and 90 is Z (42-48 = 90) - var ascicode = Math.floor(Math.random() * 42 + 48); - if (ascicode < 58 || ascicode > 64) { - // exclude all chars between : (58) and @ (64) - idstr += String.fromCharCode(ascicode); - } - } while (idstr.length < 256); - - return idstr; -}; - -export const getBrowserId = (c: string) => { - const parsed = cookie.parse(c); - return parsed.bid; -}; diff --git a/lib/logger.ts b/lib/logger.ts deleted file mode 100644 index 6f40471..0000000 --- a/lib/logger.ts +++ /dev/null @@ -1,28 +0,0 @@ -import log from 'loglevel'; -import chalk from 'chalk'; -import prefix from 'loglevel-plugin-prefix'; - -const colours = { - TRACE: chalk.magenta, - DEBUG: chalk.cyan, - INFO: chalk.blue, - WARN: chalk.yellow, - ERROR: chalk.red, -}; -type ObjectKey = keyof typeof colours; - -if (process.env.NODE_ENV == 'development') { - log.setLevel('debug'); -} - -prefix.reg(log); - -prefix.apply(log, { - format(level, name, timestamp) { - return `${chalk.gray(`[${timestamp}]`)} ${colours[ - level.toUpperCase() as ObjectKey - ](level)} ${chalk.green(`${name}:`)}`; - }, -}); - -export { log as logger }; diff --git a/lib/mapping/gif.ts b/lib/mapping/gif.ts deleted file mode 100644 index 1cd122e..0000000 --- a/lib/mapping/gif.ts +++ /dev/null @@ -1,21 +0,0 @@ -import type { Gif as modelGif } from '@models'; -import { Gif } from '@prisma/client'; - -export const mapGif = ( - gif: Gif & { _count: { upVotes: number; downVotes: number } } -): modelGif => { - return { - id: gif.id, - slug: gif.slug, - title: gif.title, - description: gif.description, - fileName: `/uploads/${gif.id}.gif`, - searchTerms: gif.searchTerms, - dateCreated: gif.createdAt.toISOString(), - upVotes: gif._count.upVotes, - downVotes: gif._count.downVotes, - hasVoted: false, - fixedEmbedCode: `