Merge remote-tracking branch 'upstream/dev/0.15.0' into dev/0.15.0

x-dev-15
xwashere 1 year ago
commit 275cb73290
No known key found for this signature in database
GPG Key ID: 042F8BFA1B0EF93B

@ -2,7 +2,7 @@ import { UserConfiguration, UserConfigTypeChecker, PostgresConfiguration, MongoD
import fs from 'fs-extra';
import { path } from '@tycrek/joint';
import { log } from './log';
import { log } from './log.js';
const FILEPATH = path.join('.ass-data/userconfig.json');

@ -8,15 +8,15 @@ import express, { Request, Response, NextFunction, RequestHandler, json as BodyP
import { path, isProd } from '@tycrek/joint';
import { epcss } from '@tycrek/express-postcss';
import { log } from './log';
import { get } from './data';
import { UserConfig } from './UserConfig';
import { DBManager } from './sql/database';
import { JSONDatabase } from './sql/json';
import { MySQLDatabase } from './sql/mysql';
import { PostgreSQLDatabase } from './sql/postgres';
import { MongoDBDatabase } from './sql/mongodb';
import { buildFrontendRouter } from './routers/_frontend';
import { log } from './log.js';
import { get } from './data.js';
import { UserConfig } from './UserConfig.js';
import { DBManager } from './sql/database.js';
import { JSONDatabase } from './sql/json.js';
import { MySQLDatabase } from './sql/mysql.js';
import { PostgreSQLDatabase } from './sql/postgres.js';
import { MongoDBDatabase } from './sql/mongodb.js';
import { buildFrontendRouter } from './routers/_frontend.js';
/**
* Top-level metadata exports

@ -1,8 +1,8 @@
import { AssFile, AssUser, NID } from 'ass';
import { log } from './log';
import { UserConfig } from './UserConfig';
import { DBManager } from './sql/database';
import { log } from './log.js';
import { UserConfig } from './UserConfig.js';
import { DBManager } from './sql/database.js';
/**
* Switcher type for exported functions

@ -1,8 +1,8 @@
import { Router } from 'express';
import { path } from '@tycrek/joint';
import { App } from '../app';
import { UserConfig } from '../UserConfig';
import { App } from '../app.js';
import { UserConfig } from '../UserConfig.js';
/**
* Builds a basic router for loading a page with frontend JS
@ -24,7 +24,7 @@ export const buildFrontendRouter = (page: string, onConfigReady = true) => {
// Load frontend JS
router.get('/ui.js', (_req, res) => ready()
? res.type('text/javascript').sendFile(path.join(`dist-frontend/${page}.mjs`))
? res.type('text/javascript').sendFile(path.join(`dist/frontend/${page}.mjs`))
: res.sendStatus(403));
return router;

@ -3,16 +3,16 @@ import { AssUser, AssUserNewReq } from 'ass';
import * as bcrypt from 'bcrypt'
import { Router, json as BodyParserJson, RequestHandler } from 'express';
import * as data from '../data';
import { log } from '../log';
import { nanoid } from '../generators';
import { UserConfig } from '../UserConfig';
import { rateLimiterMiddleware, setRateLimiter } from '../ratelimit';
import { DBManager } from '../sql/database';
import { JSONDatabase } from '../sql/json';
import { MySQLDatabase } from '../sql/mysql';
import { PostgreSQLDatabase } from '../sql/postgres';
import { MongoDBDatabase } from '../sql/mongodb';
import * as data from '../data.js';
import { log } from '../log.js';
import { nanoid } from '../generators.js';
import { UserConfig } from '../UserConfig.js';
import { rateLimiterMiddleware, setRateLimiter } from '../ratelimit.js';
import { DBManager } from '../sql/database.js';
import { JSONDatabase } from '../sql/json.js';
import { MySQLDatabase } from '../sql/mysql.js';
import { PostgreSQLDatabase } from '../sql/postgres.js';
import { MongoDBDatabase } from '../sql/mongodb.js';
const router = Router({ caseSensitive: true });

@ -6,13 +6,13 @@ import crypto from 'crypto';
import { Router } from 'express';
import { Readable } from 'stream';
import * as data from '../data';
import { log } from '../log';
import { App } from '../app';
import { random } from '../generators';
import { UserConfig } from '../UserConfig';
import { getFileS3, uploadFileS3 } from '../s3';
import { rateLimiterMiddleware } from '../ratelimit';
import * as data from '../data.js';
import { log } from '../log.js';
import { App } from '../app.js';
import { random } from '../generators.js';
import { UserConfig } from '../UserConfig.js';
import { getFileS3, uploadFileS3 } from '../s3.js';
import { rateLimiterMiddleware } from '../ratelimit.js';
const router = Router({ caseSensitive: true });

@ -12,8 +12,8 @@ import {
AbortMultipartUploadCommand,
} from "@aws-sdk/client-s3";
import { log } from './log';
import { UserConfig } from './UserConfig';
import { log } from './log.js';
import { UserConfig } from './UserConfig.js';
const NYR = 'S3 not ready';

@ -3,9 +3,9 @@ import { AssFile, AssUser, FilesSchema, UsersSchema } from 'ass';
import path, { resolve } from 'path';
import fs from 'fs-extra';
import { Database, DatabaseTable, DatabaseValue } from './database';
import { log } from '../log';
import { nanoid } from '../generators';
import { Database, DatabaseTable, DatabaseValue } from './database.js';
import { log } from '../log.js';
import { nanoid } from '../generators.js';
/**
* Absolute filepaths for JSON data files

@ -2,9 +2,9 @@ import { AssFile, AssUser, NID, UploadToken } from 'ass';
import mysql, { Pool } from 'mysql2/promise';
import { log } from '../log';
import { UserConfig } from '../UserConfig';
import { Database, DatabaseTable, DatabaseValue } from './database';
import { log } from '../log.js';
import { UserConfig } from '../UserConfig.js';
import { Database, DatabaseTable, DatabaseValue } from './database.js';
export class MySQLDatabase implements Database {
private _pool: Pool;

@ -1,16 +1,15 @@
import { PostgresConfiguration } from 'ass';
import { Client } from 'pg';
import { log } from '../log';
import { Database, DatabaseTable, DatabaseValue } from './database';
import { UserConfig } from '../UserConfig';
import pg from 'pg';
import { log } from '../log.js';
import { Database, DatabaseTable, DatabaseValue } from './database.js';
import { UserConfig } from '../UserConfig.js';
/**
* database adapter for postgresql
*/
export class PostgreSQLDatabase implements Database {
private _client: Client;
private _client: pg.Client;
/**
* validate config
@ -48,7 +47,7 @@ export class PostgreSQLDatabase implements Database {
let config = UserConfig.config.database!.options! as PostgresConfiguration;
// set up the client
this._client = new Client({
this._client = new pg.Client({
host: config.host,
port: config.port,
user: config.user,

@ -1,7 +1,7 @@
{
"extends": "@tsconfig/node20/tsconfig.json",
"compilerOptions": {
"outDir": "../dist-backend",
"outDir": "../dist/backend",
"strictPropertyInitialization": false
},
"include": [

@ -1,9 +1,10 @@
const fs = require('fs-extra');
const { path } = require('@tycrek/joint');
const log = new (require('@tycrek/log').TLog)();
import fs from 'fs-extra';
import { path } from '@tycrek/joint';
import { TLog } from '@tycrek/log';
const log = new TLog();
const FILES = {
prefix: 'dist-frontend',
prefix: 'dist/frontend',
suffix: '.mjs',
pages: [
'setup',

@ -1,7 +1,7 @@
{
"extends": "@tsconfig/node20/tsconfig.json",
"compilerOptions": {
"outDir": "../dist-frontend",
"outDir": "../dist/frontend",
"lib": [
"ES2022",
"DOM"

@ -2,22 +2,19 @@
"name": "ass",
"version": "0.15.0-indev",
"description": "The simple self-hosted ShareX server",
"main": "dist-backend/app.js",
"main": "dist/backend/app.js",
"type": "module",
"engines": {
"node": "^20",
"npm": "^10"
"node": "^20"
},
"scripts": {
"dev": "npm run build && npm start",
"fresh": "rm -dr .ass-data/ & npm run dev",
"build": "rm -dr dist-*/ & npm run build:backend && npm run build:frontend",
"build": "rm -dr dist/ & npm run build:backend && npm run build:frontend && npm run build:fix-frontend",
"build:backend": "tsc -p backend/",
"build:frontend": "tsc -p frontend/",
"postbuild:frontend": "node common/fix-frontend-js.js",
"start": "node dist-backend/app.js",
"cli-setpassword": "node dist/tools/script.setpassword.js",
"cli-testpassword": "node dist/tools/script.testpassword.js",
"cli-adduser": "node dist/tools/script.adduser.js"
"build:fix-frontend": "node common/fix-frontend-js.js",
"start": "node dist/backend/app.js"
},
"repository": "github:tycrek/ass",
"keywords": [
@ -29,13 +26,13 @@
"bugs": "https://github.com/tycrek/ass/issues",
"homepage": "https://github.com/tycrek/ass#readme",
"dependencies": {
"@aws-sdk/client-s3": "^3.437.0",
"@shoelace-style/shoelace": "^2.11.2",
"@aws-sdk/client-s3": "^3.456.0",
"@shoelace-style/shoelace": "^2.12.0",
"@tinycreek/postcss-font-magician": "^4.2.0",
"@tsconfig/node20": "^20.1.2",
"@tycrek/discord-hookr": "^0.1.0",
"@tycrek/express-postcss": "^0.4.1",
"@tycrek/joint": "^1.0.0-1",
"@tycrek/joint": "1.0.0-1",
"@tycrek/log": "^0.7.5",
"@xoi/gps-metadata-remover": "^1.1.2",
"any-shell-escape": "^0.1.1",
@ -45,14 +42,14 @@
"cssnano": "^6.0.1",
"express": "^4.18.2",
"express-busboy": "^10.1.0",
"express-rate-limit": "^7.1.3",
"express-rate-limit": "^7.1.4",
"express-session": "^1.17.3",
"ffmpeg-static": "^5.2.0",
"fs-extra": "^11.1.1",
"luxon": "^3.4.3",
"luxon": "^3.4.4",
"memorystore": "^1.6.7",
"mongoose": "^8.0.0",
"mysql2": "^3.6.2",
"mysql2": "^3.6.5",
"node-vibrant": "^3.1.6",
"pg": "^8.11.3",
"pug": "^3.0.2",
@ -60,17 +57,17 @@
"shoelace-fontawesome-pug": "^6.4.3",
"shoelace-pug-loader": "^2.11.0",
"tailwindcss": "^3.3.5",
"typescript": "^5.2.2"
"typescript": "^5.3.2"
},
"devDependencies": {
"@types/bcrypt": "^5.0.1",
"@types/express": "^4.17.20",
"@types/express-busboy": "^8.0.2",
"@types/express-session": "^1.17.9",
"@types/ffmpeg-static": "^3.0.2",
"@types/fs-extra": "^11.0.3",
"@types/luxon": "^3.3.3",
"@types/node": "^20.8.9",
"@types/pg": "^8.10.7"
"@types/bcrypt": "^5.0.2",
"@types/express": "^4.17.21",
"@types/express-busboy": "^8.0.3",
"@types/express-session": "^1.17.10",
"@types/ffmpeg-static": "^3.0.3",
"@types/fs-extra": "^11.0.4",
"@types/luxon": "^3.3.5",
"@types/node": "^20.10.0",
"@types/pg": "^8.10.9"
}
}

File diff suppressed because it is too large Load Diff

@ -41,7 +41,7 @@ const migrate = (authFileName = 'auth.json'): Promise<Users> => new Promise(asyn
const oldUsers = fs.readJsonSync(authPath).users as OldUsers;
// Create a new users object
const newUsers: Users = { users: [], meta: {} };
const newUsers: Users = { users: [], meta: {}, cliKey: nanoid(32) };
newUsers.migrated = true;
// Loop through each user
@ -69,8 +69,9 @@ const migrate = (authFileName = 'auth.json'): Promise<Users> => new Promise(asyn
.catch(reject)
// Migrate the datafile (token => uploader)
.then(() => data().get())
.then((fileData: [string, FileData][]) =>
.then(() => (!data())
? (log.warn('data.json not found. This may be a new install?'), Promise.resolve())
: data().get().then((fileData: [string, FileData][]) =>
// ! A note about this block.
// I know it's gross. But using Promise.all crashes low-spec servers, so I had to do it this way. Sorry.
@ -100,7 +101,8 @@ const migrate = (authFileName = 'auth.json'): Promise<Users> => new Promise(asyn
runQueue(0);
}))
.catch((err: any) => log.warn(err.message))
)
// We did it hoofuckingray
.then(() => log.success('Migrated all auth & file data to new auth system'))
.then(() => resolve(newUsers))

Loading…
Cancel
Save