mirror of
https://github.com/fergalmoran/snapp.git
synced 2025-12-22 09:41:45 +00:00
v8
This commit is contained in:
@@ -1,15 +0,0 @@
|
|||||||
# .dockerignore
|
|
||||||
|
|
||||||
.vscode
|
|
||||||
node_modules
|
|
||||||
.env
|
|
||||||
.env.example
|
|
||||||
.git
|
|
||||||
./prisma/db.sqlite
|
|
||||||
.gitattributes
|
|
||||||
.eslintignore
|
|
||||||
.eslintrc.cjs
|
|
||||||
.prettierrc
|
|
||||||
.prettierignore
|
|
||||||
README.md
|
|
||||||
Dockerfile
|
|
||||||
18
.env.example
18
.env.example
@@ -1,11 +1,7 @@
|
|||||||
# Environment variables declared in this file are automatically made available to Prisma.
|
DATABASE_URL= # "file:./db.sqlite" | 'mysql://root:password@mariadb:3306/snappdb' | 'postgresql://root:password@postgres:5432/snappdb'
|
||||||
# See the documentation for more detail: https://pris.ly/d/prisma-schema#accessing-environment-variables-from-the-schema
|
DATABASE_PROVIDER= # sqlite | postgres | mysql
|
||||||
|
TOKEN_SECRET= # openssl rand -base64 32
|
||||||
# Prisma supports the native connection string format for PostgreSQL, MySQL, SQLite, SQL Server, MongoDB and CockroachDB.
|
ORIGIN=https://example.com # to avoid CROSS ORIGIN on Form Submission
|
||||||
# See the documentation for all the connection string options: https://pris.ly/d/connection-strings
|
ADMIN_USERNAME= # must be specified on first launch as it initiate the database
|
||||||
|
ADMIN_PASSWORD= # must be specified on first launch as it initiate the database
|
||||||
DATABASE_URL="file:./db.sqlite"
|
PORT=3000 # app port
|
||||||
TOKEN_SECRET=
|
|
||||||
ORIGIN=https://labs.urania.dev
|
|
||||||
APPNAME="Snapp.li"
|
|
||||||
PUBLIC_SNAPP_VERSION=0.8-beta
|
|
||||||
29
Dockerfile
Normal file
29
Dockerfile
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
FROM node:lts-alpine
|
||||||
|
|
||||||
|
# Set the working directory
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Copy package.json and package-lock.json
|
||||||
|
COPY package*.json ./
|
||||||
|
|
||||||
|
# Install dependencies
|
||||||
|
RUN npm install --legacy-peer-deps
|
||||||
|
|
||||||
|
# Copy the rest of the application code
|
||||||
|
COPY . .
|
||||||
|
ENV DATABASE_URL=file:./db.sqlite
|
||||||
|
RUN npx prisma generate
|
||||||
|
RUN npx prisma migrate dev -n init
|
||||||
|
RUN npm run build --production
|
||||||
|
# Copy the entrypoint script
|
||||||
|
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
|
||||||
|
|
||||||
|
# Set the entrypoint
|
||||||
|
ENTRYPOINT ["entrypoint.sh"]
|
||||||
|
ENV APPNAME="Snapp.li"
|
||||||
|
ENV PUBLIC_SNAPP_VERSION="0.8"
|
||||||
|
# Expose the port the app runs on
|
||||||
|
EXPOSE 3000
|
||||||
|
|
||||||
|
# Command to run the app
|
||||||
|
CMD node -r dotenv/config build
|
||||||
16
README.md
16
README.md
@@ -33,14 +33,14 @@ For the 0.8 version, you’ll need to migrate URLs using the CSV Exporter. Here
|
|||||||
```yml
|
```yml
|
||||||
services:
|
services:
|
||||||
snapp:
|
snapp:
|
||||||
image: uraniadev/snapp:0.8
|
image: uraniadev/snapp:0.8
|
||||||
ports:
|
ports:
|
||||||
- 3000:3000
|
- 3000:3000
|
||||||
environment:
|
environment:
|
||||||
DATABASE_URL: "file:./db.sqlite"
|
DATABASE_URL: "file:./db.sqlite"
|
||||||
DATABASE_PROVIDER: sqlite # mysql | sqlite | pg
|
DATABASE_PROVIDER: sqlite # mysql | sqlite | pg
|
||||||
TOKEN_SECRET: # openssl rand -base64 32
|
TOKEN_SECRET: # openssl rand -base64 32
|
||||||
ORIGIN: https://example.com
|
ORIGIN: https://example.com
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -2,13 +2,12 @@ services:
|
|||||||
snapp:
|
snapp:
|
||||||
image: uraniadev/snapp:0.8
|
image: uraniadev/snapp:0.8
|
||||||
ports:
|
ports:
|
||||||
- 5173:3000
|
- 3000:3000
|
||||||
environment:
|
environment:
|
||||||
DATABASE_URL: 'mysql://root:password@mariadb:3306/snappdb'
|
DATABASE_URL: 'mysql://root:password@mariadb:3306/snappdb'
|
||||||
TOKEN_SECRET: # openssl rand -base64 32
|
TOKEN_SECRET: # openssl rand -base64 32
|
||||||
ORIGIN: https://labs.urania.dev
|
ORIGIN: https://example.com
|
||||||
DATABASE_PROVIDER: mysql
|
DATABASE_PROVIDER: mysql
|
||||||
NODE_ENV: production
|
|
||||||
depends_on:
|
depends_on:
|
||||||
- mariadb
|
- mariadb
|
||||||
networks:
|
networks:
|
||||||
|
|||||||
@@ -2,14 +2,12 @@ services:
|
|||||||
snapp:
|
snapp:
|
||||||
image: uraniadev/snapp:0.8
|
image: uraniadev/snapp:0.8
|
||||||
ports:
|
ports:
|
||||||
- 5173:3000
|
- 3000:3000
|
||||||
environment:
|
environment:
|
||||||
DATABASE_URL: 'postgresql://root:password@postgres:5432/snappdb'
|
DATABASE_URL: 'postgresql://root:password@postgres:5432/snappdb'
|
||||||
TOKEN_SECRET: # openssl rand -base64 32
|
TOKEN_SECRET: # openssl rand -base64 32
|
||||||
ORIGIN: https://labs.urania.dev
|
ORIGIN: https://example.com
|
||||||
DATABASE_PROVIDER: postgresql
|
DATABASE_PROVIDER: postgresql
|
||||||
NODE_ENV: production
|
|
||||||
ADMIN_PASSWORD: beppuzzo
|
|
||||||
depends_on:
|
depends_on:
|
||||||
- postgres
|
- postgres
|
||||||
networks:
|
networks:
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
services:
|
services:
|
||||||
snapp:
|
snapp:
|
||||||
image: uraniadev/snapp:0.8
|
image: uraniadev/snapp:0.8
|
||||||
|
ports:
|
||||||
|
- 3000:3000
|
||||||
environment:
|
environment:
|
||||||
TOKEN_SECRET: oB15eltUnM5acp7+C4nR3RXMdw/kgfDTxQ6U4LbOiWs=
|
TOKEN_SECRET: # openssl rand -base64 32
|
||||||
ORIGIN: https://labs.urania.dev
|
ORIGIN: https://example.com
|
||||||
|
|||||||
BIN
prisma/db.sqlite
BIN
prisma/db.sqlite
Binary file not shown.
@@ -1,134 +0,0 @@
|
|||||||
-- CreateTable
|
|
||||||
CREATE TABLE "users" (
|
|
||||||
"id" TEXT NOT NULL PRIMARY KEY,
|
|
||||||
"username" TEXT NOT NULL,
|
|
||||||
"password_hash" TEXT NOT NULL,
|
|
||||||
"email" TEXT NOT NULL,
|
|
||||||
"notes" TEXT,
|
|
||||||
"role" TEXT NOT NULL DEFAULT 'user',
|
|
||||||
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
"updatedAt" DATETIME NOT NULL
|
|
||||||
);
|
|
||||||
|
|
||||||
-- CreateTable
|
|
||||||
CREATE TABLE "sessions" (
|
|
||||||
"id" TEXT NOT NULL PRIMARY KEY,
|
|
||||||
"userId" TEXT NOT NULL,
|
|
||||||
"expiresAt" DATETIME NOT NULL,
|
|
||||||
CONSTRAINT "sessions_userId_fkey" FOREIGN KEY ("userId") REFERENCES "users" ("id") ON DELETE CASCADE ON UPDATE CASCADE
|
|
||||||
);
|
|
||||||
|
|
||||||
-- CreateTable
|
|
||||||
CREATE TABLE "password_reset" (
|
|
||||||
"token_hash" TEXT NOT NULL,
|
|
||||||
"userId" TEXT NOT NULL,
|
|
||||||
"expiresAt" DATETIME NOT NULL
|
|
||||||
);
|
|
||||||
|
|
||||||
-- CreateTable
|
|
||||||
CREATE TABLE "settings" (
|
|
||||||
"id" TEXT NOT NULL PRIMARY KEY,
|
|
||||||
"field" TEXT NOT NULL,
|
|
||||||
"value" TEXT NOT NULL,
|
|
||||||
"userId" TEXT,
|
|
||||||
"created" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
CONSTRAINT "settings_userId_fkey" FOREIGN KEY ("userId") REFERENCES "users" ("id") ON DELETE CASCADE ON UPDATE CASCADE
|
|
||||||
);
|
|
||||||
|
|
||||||
-- CreateTable
|
|
||||||
CREATE TABLE "tokens" (
|
|
||||||
"key" TEXT NOT NULL PRIMARY KEY,
|
|
||||||
"userId" TEXT NOT NULL,
|
|
||||||
"created" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
CONSTRAINT "tokens_userId_fkey" FOREIGN KEY ("userId") REFERENCES "users" ("id") ON DELETE CASCADE ON UPDATE CASCADE
|
|
||||||
);
|
|
||||||
|
|
||||||
-- CreateTable
|
|
||||||
CREATE TABLE "Vtapicache" (
|
|
||||||
"id" TEXT NOT NULL PRIMARY KEY,
|
|
||||||
"created" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
"domain" TEXT NOT NULL,
|
|
||||||
"result" TEXT NOT NULL
|
|
||||||
);
|
|
||||||
|
|
||||||
-- CreateTable
|
|
||||||
CREATE TABLE "watchlists" (
|
|
||||||
"id" TEXT NOT NULL PRIMARY KEY,
|
|
||||||
"created" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
"username" TEXT,
|
|
||||||
"domain" TEXT,
|
|
||||||
"allowed" BOOLEAN NOT NULL
|
|
||||||
);
|
|
||||||
|
|
||||||
-- CreateTable
|
|
||||||
CREATE TABLE "snapps" (
|
|
||||||
"id" TEXT NOT NULL PRIMARY KEY,
|
|
||||||
"shortcode" TEXT NOT NULL,
|
|
||||||
"original_url" TEXT NOT NULL,
|
|
||||||
"created" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
"secret" TEXT,
|
|
||||||
"max_usages" INTEGER NOT NULL DEFAULT -1,
|
|
||||||
"hit" INTEGER NOT NULL DEFAULT 0,
|
|
||||||
"used" INTEGER NOT NULL DEFAULT 0,
|
|
||||||
"notes" TEXT,
|
|
||||||
"expiration" DATETIME,
|
|
||||||
"disabled" BOOLEAN NOT NULL DEFAULT false,
|
|
||||||
"userId" TEXT NOT NULL,
|
|
||||||
CONSTRAINT "snapps_userId_fkey" FOREIGN KEY ("userId") REFERENCES "users" ("id") ON DELETE CASCADE ON UPDATE CASCADE
|
|
||||||
);
|
|
||||||
|
|
||||||
-- CreateTable
|
|
||||||
CREATE TABLE "usages" (
|
|
||||||
"id" TEXT NOT NULL PRIMARY KEY,
|
|
||||||
"timestamp" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
"snappId" TEXT NOT NULL,
|
|
||||||
"snappUserId" TEXT NOT NULL,
|
|
||||||
"language" TEXT,
|
|
||||||
"user_agent" TEXT,
|
|
||||||
"referrer" TEXT,
|
|
||||||
"device" TEXT,
|
|
||||||
"country" TEXT,
|
|
||||||
"region" TEXT,
|
|
||||||
"city" TEXT,
|
|
||||||
"os" TEXT,
|
|
||||||
"browser" TEXT,
|
|
||||||
"cpu" TEXT,
|
|
||||||
CONSTRAINT "usages_snappUserId_fkey" FOREIGN KEY ("snappUserId") REFERENCES "users" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
|
|
||||||
CONSTRAINT "usages_snappId_fkey" FOREIGN KEY ("snappId") REFERENCES "snapps" ("id") ON DELETE CASCADE ON UPDATE CASCADE
|
|
||||||
);
|
|
||||||
|
|
||||||
-- CreateIndex
|
|
||||||
CREATE UNIQUE INDEX "users_username_key" ON "users"("username");
|
|
||||||
|
|
||||||
-- CreateIndex
|
|
||||||
CREATE UNIQUE INDEX "users_email_key" ON "users"("email");
|
|
||||||
|
|
||||||
-- CreateIndex
|
|
||||||
CREATE UNIQUE INDEX "password_reset_token_hash_key" ON "password_reset"("token_hash");
|
|
||||||
|
|
||||||
-- CreateIndex
|
|
||||||
CREATE INDEX "password_reset_userId_idx" ON "password_reset"("userId");
|
|
||||||
|
|
||||||
-- CreateIndex
|
|
||||||
CREATE UNIQUE INDEX "settings_id_key" ON "settings"("id");
|
|
||||||
|
|
||||||
-- CreateIndex
|
|
||||||
CREATE INDEX "settings_field_idx" ON "settings"("field");
|
|
||||||
|
|
||||||
-- CreateIndex
|
|
||||||
CREATE INDEX "settings_field_userId_idx" ON "settings"("field", "userId");
|
|
||||||
|
|
||||||
-- CreateIndex
|
|
||||||
CREATE UNIQUE INDEX "Vtapicache_domain_key" ON "Vtapicache"("domain");
|
|
||||||
|
|
||||||
-- CreateIndex
|
|
||||||
CREATE UNIQUE INDEX "snapps_shortcode_key" ON "snapps"("shortcode");
|
|
||||||
|
|
||||||
-- CreateIndex
|
|
||||||
CREATE INDEX "snapps_shortcode_idx" ON "snapps"("shortcode");
|
|
||||||
|
|
||||||
-- CreateIndex
|
|
||||||
CREATE INDEX "snapps_created_idx" ON "snapps"("created");
|
|
||||||
|
|
||||||
-- CreateIndex
|
|
||||||
CREATE INDEX "snapps_shortcode_created_idx" ON "snapps"("shortcode", "created");
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
# Please do not edit this file manually
|
|
||||||
# It should be added in your version-control system (i.e. Git)
|
|
||||||
provider = "sqlite"
|
|
||||||
@@ -1,134 +0,0 @@
|
|||||||
// This is your Prisma schema file,
|
|
||||||
// learn more about it in the docs: https://pris.ly/d/prisma-schema
|
|
||||||
|
|
||||||
generator client {
|
|
||||||
provider = "prisma-client-js"
|
|
||||||
}
|
|
||||||
|
|
||||||
datasource db {
|
|
||||||
provider = "sqlite"
|
|
||||||
url = env("DATABASE_URL")
|
|
||||||
}
|
|
||||||
|
|
||||||
model User {
|
|
||||||
id String @id
|
|
||||||
sessions Session[]
|
|
||||||
username String @unique
|
|
||||||
password_hash String
|
|
||||||
email String @unique
|
|
||||||
settings Setting[]
|
|
||||||
notes String?
|
|
||||||
role String @default("user")
|
|
||||||
token Token[]
|
|
||||||
snapps Snapp[]
|
|
||||||
createdAt DateTime @default(now())
|
|
||||||
updatedAt DateTime @updatedAt
|
|
||||||
usages Usages[]
|
|
||||||
|
|
||||||
@@map("users")
|
|
||||||
}
|
|
||||||
|
|
||||||
model Session {
|
|
||||||
id String @id
|
|
||||||
userId String
|
|
||||||
expiresAt DateTime
|
|
||||||
|
|
||||||
user User @relation(references: [id], fields: [userId], onDelete: Cascade)
|
|
||||||
|
|
||||||
@@map("sessions")
|
|
||||||
}
|
|
||||||
|
|
||||||
model Password_reset {
|
|
||||||
token_hash String @unique
|
|
||||||
userId String
|
|
||||||
expiresAt DateTime
|
|
||||||
|
|
||||||
@@index(userId)
|
|
||||||
@@map("password_reset")
|
|
||||||
}
|
|
||||||
|
|
||||||
model Setting {
|
|
||||||
id String @id @unique @default(cuid())
|
|
||||||
field String
|
|
||||||
value String
|
|
||||||
userId String?
|
|
||||||
user User? @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
||||||
created DateTime @default(now())
|
|
||||||
|
|
||||||
@@index([field])
|
|
||||||
@@index([field, userId])
|
|
||||||
@@map("settings")
|
|
||||||
}
|
|
||||||
|
|
||||||
model Token {
|
|
||||||
key String @id
|
|
||||||
userId String
|
|
||||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
||||||
created DateTime @default(now())
|
|
||||||
|
|
||||||
@@map("tokens")
|
|
||||||
}
|
|
||||||
|
|
||||||
model Vtapicache {
|
|
||||||
id String @id @default(cuid())
|
|
||||||
created DateTime @default(now())
|
|
||||||
domain String @unique
|
|
||||||
result String
|
|
||||||
}
|
|
||||||
|
|
||||||
model Watchlist {
|
|
||||||
id String @id @default(cuid())
|
|
||||||
created DateTime @default(now())
|
|
||||||
username String?
|
|
||||||
domain String?
|
|
||||||
allowed Boolean
|
|
||||||
|
|
||||||
@@map("watchlists")
|
|
||||||
}
|
|
||||||
|
|
||||||
model Snapp {
|
|
||||||
id String @id @default(cuid())
|
|
||||||
shortcode String @unique
|
|
||||||
original_url String
|
|
||||||
created DateTime @default(now())
|
|
||||||
|
|
||||||
secret String?
|
|
||||||
max_usages Int @default(-1)
|
|
||||||
hit Int @default(0)
|
|
||||||
used Int @default(0)
|
|
||||||
notes String?
|
|
||||||
|
|
||||||
expiration DateTime?
|
|
||||||
disabled Boolean @default(false)
|
|
||||||
|
|
||||||
userId String
|
|
||||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
||||||
usages Usages[]
|
|
||||||
|
|
||||||
@@index(shortcode)
|
|
||||||
@@index([created])
|
|
||||||
@@index([shortcode, created])
|
|
||||||
@@map("snapps")
|
|
||||||
}
|
|
||||||
|
|
||||||
model Usages {
|
|
||||||
id String @id @default(cuid())
|
|
||||||
timestamp DateTime @default(now())
|
|
||||||
snappId String
|
|
||||||
snappUserId String
|
|
||||||
language String?
|
|
||||||
user_agent String?
|
|
||||||
referrer String?
|
|
||||||
device String?
|
|
||||||
country String?
|
|
||||||
region String?
|
|
||||||
city String?
|
|
||||||
os String?
|
|
||||||
browser String?
|
|
||||||
cpu String?
|
|
||||||
|
|
||||||
user User @relation(fields: [snappUserId], references: [id], onDelete: Cascade)
|
|
||||||
snapp Snapp @relation(fields: [snappId], references: [id], onDelete: Cascade)
|
|
||||||
|
|
||||||
@@map("usages")
|
|
||||||
}
|
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 65 MiB |
Reference in New Issue
Block a user