Started backend database

This commit is contained in:
WardPearce
2026-02-13 22:45:43 +13:00
parent 1cb79ca67c
commit 700a93b83c
7 changed files with 1519 additions and 7 deletions
+1431
View File
File diff suppressed because it is too large Load Diff
+6
View File
@@ -32,10 +32,16 @@
"eslint-config-prettier": "^10.1.8",
"eslint-plugin-svelte": "^3.13.0",
"jsdom": "^28.0.0",
"mariadb": "^3.4.5",
"mysql2": "^3.17.1",
"patch-package": "^8.0.1",
"pg": "^8.18.0",
"pg-hstore": "^2.3.4",
"prettier": "^3.6.2",
"prettier-plugin-svelte": "^3.4.0",
"psl": "^1.15.0",
"sequelize": "^6.37.7",
"sqlite3": "^5.1.7",
"svelte": "^5.47.0",
"svelte-awesome-color-picker": "^4.1.1",
"svelte-check": "^4.3.3",
+18
View File
@@ -0,0 +1,18 @@
import { isOwnBackend } from '$lib/backend';
import { sequelize } from '$lib/backendOnly/database';
let sequelizeAuthenticated = false;
export async function handle({ event, resolve }) {
const resolved = await resolve(event);
if (!isOwnBackend()?.internalAuth) {
return resolved;
}
if (!sequelizeAuthenticated) {
await sequelize.authenticate();
sequelizeAuthenticated = true;
}
return resolved;
}
@@ -0,0 +1,49 @@
import { Sequelize, DataTypes } from 'sequelize';
import { DATABASE_CONNECTION_URI } from '$env/static/private';
export const sequelize = new Sequelize(
// Use sqlite::memory: if not provided.
DATABASE_CONNECTION_URI ? DATABASE_CONNECTION_URI : 'sqlite::memory:'
);
export const UserTable = sequelize.define('User', {
id: {
type: DataTypes.UUIDV4,
allowNull: false,
primaryKey: true
},
username: {
type: DataTypes.STRING,
allowNull: false
},
passwordHash: {
type: DataTypes.STRING,
allowNull: false
},
create: {
type: DataTypes.DATE,
allowNull: false
}
});
export const ChannelSubscriptionTable = sequelize.define('Subscriptions', {
channelId: {
type: DataTypes.STRING,
allowNull: false
},
channelName: {
type: DataTypes.STRING,
allowNull: false
},
lastRSSFetch: {
type: DataTypes.DATE,
allowNull: false
},
userId: {
type: DataTypes.UUIDV4,
references: {
model: 'User',
key: 'id'
}
}
});
+1 -1
View File
@@ -1,7 +1,7 @@
import { isUnrestrictedPlatform, timeout } from '$lib/misc';
import { Capacitor } from '@capacitor/core';
const originalFetch = window.fetch;
export const originalFetch = window.fetch;
const corsProxyUrl =
Capacitor.getPlatform() === 'android'
? 'http://localhost:3000/'
@@ -1,5 +1,13 @@
import { isOwnBackend } from '$lib/backend';
import psl from 'psl';
import {
VITE_DEFAULT_DEARROW_THUMBNAIL_INSTANCE,
VITE_DEFAULT_DEARROW_INSTANCE,
VITE_DEFAULT_INVIDIOUS_INSTANCE,
VITE_DEFAULT_RETURNYTDISLIKES_INSTANCE,
VITE_DEFAULT_API_EXTENDED_INSTANCE,
VITE_DEFAULT_SYNCIOUS_INSTANCE
} from '$env/static/private';
const allowedDomains: string[] = [
'youtube.com',
@@ -12,12 +20,12 @@ const allowedDomains: string[] = [
];
const dynamicAllowDomains = [
process.env.VITE_DEFAULT_DEARROW_THUMBNAIL_INSTANCE,
process.env.VITE_DEFAULT_DEARROW_INSTANCE,
process.env.VITE_DEFAULT_INVIDIOUS_INSTANCE,
process.env.VITE_DEFAULT_RETURNYTDISLIKES_INSTANCE,
process.env.VITE_DEFAULT_API_EXTENDED_INSTANCE,
process.env.VITE_DEFAULT_SYNCIOUS_INSTANCE
VITE_DEFAULT_DEARROW_THUMBNAIL_INSTANCE,
VITE_DEFAULT_DEARROW_INSTANCE,
VITE_DEFAULT_INVIDIOUS_INSTANCE,
VITE_DEFAULT_RETURNYTDISLIKES_INSTANCE,
VITE_DEFAULT_API_EXTENDED_INSTANCE,
VITE_DEFAULT_SYNCIOUS_INSTANCE
];
dynamicAllowDomains.forEach((domain) => {