add more parsable error pages
This commit is contained in:
parent
8cdd4c7cbb
commit
225ec3fb49
|
|
@ -17,6 +17,7 @@
|
||||||
"@elysiajs/static": "^1.4.0",
|
"@elysiajs/static": "^1.4.0",
|
||||||
"@types/html-minifier-next": "^2.1.0",
|
"@types/html-minifier-next": "^2.1.0",
|
||||||
"@types/pg": "^8.11.10",
|
"@types/pg": "^8.11.10",
|
||||||
|
"age-encryption": "^0.2.4",
|
||||||
"date-fns": "^4.1.0",
|
"date-fns": "^4.1.0",
|
||||||
"elysia": "^1.1.25",
|
"elysia": "^1.1.25",
|
||||||
"eta": "^4.0.1",
|
"eta": "^4.0.1",
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import { Elysia } from 'elysia';
|
import { Elysia } from 'elysia';
|
||||||
import { m, eta } from '@/utils/html'
|
import { m, eta, error } from '@/utils/html'
|
||||||
const app = new Elysia()
|
const app = new Elysia()
|
||||||
|
|
||||||
app.get('/', async ({ set }) => {
|
app.get('/', async ({ set }) => {
|
||||||
|
|
@ -65,4 +65,5 @@ app.get('/donate', async ({ set }) => {
|
||||||
}))
|
}))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
app.onError(error)
|
||||||
export default app;
|
export default app;
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import { Elysia } from 'elysia';
|
import { Elysia } from 'elysia';
|
||||||
import { db } from '@/utils/database'
|
import { db } from '@/utils/database'
|
||||||
import { createSitemapXML, createSitemapIndexXML } from '@/utils/sitemap'
|
import { createSitemapXML, createSitemapIndexXML } from '@/utils/sitemap'
|
||||||
import { m, eta } from '@/utils/html'
|
import { m, eta, error } from '@/utils/html'
|
||||||
import redis from '@/utils/redis';
|
import redis from '@/utils/redis';
|
||||||
|
|
||||||
const app = new Elysia()
|
const app = new Elysia()
|
||||||
|
|
@ -67,4 +67,5 @@ app.get('/sitemap-:index.xml', async ({ set, params: { index }, error, path }) =
|
||||||
return error(404)
|
return error(404)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
app.onError(error)
|
||||||
export default app
|
export default app
|
||||||
|
|
@ -3,7 +3,7 @@ import { RedisRateLimiter } from 'rolling-rate-limiter'
|
||||||
|
|
||||||
import { db } from '@/utils/database'
|
import { db } from '@/utils/database'
|
||||||
import { validateVideo, validateChannel } from '@/utils/regex'
|
import { validateVideo, validateChannel } from '@/utils/regex'
|
||||||
import { m, eta } from '@/utils/html'
|
import { m, eta, error } from '@/utils/html'
|
||||||
import redis from '@/utils/redis';
|
import redis from '@/utils/redis';
|
||||||
|
|
||||||
const app = new Elysia()
|
const app = new Elysia()
|
||||||
|
|
@ -59,4 +59,5 @@ app.get('/search/channel', async ({ query: { url }, error, redirect }) => {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
app.onError(error)
|
||||||
export default app
|
export default app
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import { Elysia } from 'elysia';
|
import { Elysia } from 'elysia';
|
||||||
|
|
||||||
import { db } from '@/utils/database'
|
import { db } from '@/utils/database'
|
||||||
import { m, eta } from '@/utils/html'
|
import { m, eta, error } from '@/utils/html'
|
||||||
import redis from '@/utils/redis';
|
import redis from '@/utils/redis';
|
||||||
|
|
||||||
const app = new Elysia()
|
const app = new Elysia()
|
||||||
|
|
@ -52,4 +52,5 @@ app.get('/transparency/:id', async ({ params: { id }, set, error }) => {
|
||||||
return html
|
return html
|
||||||
})
|
})
|
||||||
|
|
||||||
|
app.onError(error)
|
||||||
export default app
|
export default app
|
||||||
|
|
@ -4,7 +4,7 @@ import DOMPurify from 'isomorphic-dompurify'
|
||||||
import { db } from '@/utils/database'
|
import { db } from '@/utils/database'
|
||||||
import { getChannel, getChannelVideos } from '@/utils/metadata';
|
import { getChannel, getChannelVideos } from '@/utils/metadata';
|
||||||
import { convertRelativeToDate } from '@/utils/common';
|
import { convertRelativeToDate } from '@/utils/common';
|
||||||
import { m, eta } from '@/utils/html'
|
import { m, eta, error } from '@/utils/html'
|
||||||
import redis from '@/utils/redis';
|
import redis from '@/utils/redis';
|
||||||
|
|
||||||
const app = new Elysia()
|
const app = new Elysia()
|
||||||
|
|
@ -170,4 +170,5 @@ app.get('/channel/:id/videos', async ({ params: { id }, set }) => {
|
||||||
return html
|
return html
|
||||||
})
|
})
|
||||||
|
|
||||||
|
app.onError(error)
|
||||||
export default app
|
export default app
|
||||||
|
|
@ -7,6 +7,7 @@ import { checkCaptcha, createDatabaseVideo } from '@/utils/common';
|
||||||
import { downloadVideo } from '@/utils/download';
|
import { downloadVideo } from '@/utils/download';
|
||||||
import { uploadVideo } from '@/utils/upload';
|
import { uploadVideo } from '@/utils/upload';
|
||||||
import { getChannelVideos } from '@/utils/metadata';
|
import { getChannelVideos } from '@/utils/metadata';
|
||||||
|
import { error } from '@/utils/html'
|
||||||
import redis from '@/utils/redis';
|
import redis from '@/utils/redis';
|
||||||
|
|
||||||
const app = new Elysia()
|
const app = new Elysia()
|
||||||
|
|
@ -182,4 +183,5 @@ app.ws('/savechannel', {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
app.onError(error)
|
||||||
export default app
|
export default app
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import { minify } from 'html-minifier-next';
|
import { minify } from 'html-minifier-next';
|
||||||
|
import * as age from 'age-encryption'
|
||||||
import { Eta } from 'eta';
|
import { Eta } from 'eta';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
|
||||||
|
|
@ -11,3 +12,23 @@ export const m = async (html: string) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
export const eta = new Eta({ views: path.join(__dirname, '../templates'), functionHeader: `const hostname = "${process.env.SERVER_NICKNAME}"` })
|
export const eta = new Eta({ views: path.join(__dirname, '../templates'), functionHeader: `const hostname = "${process.env.SERVER_NICKNAME}"` })
|
||||||
|
|
||||||
|
export const error = async ({ error }: any) => {
|
||||||
|
const debuggingInfo = {
|
||||||
|
serverNickname: process.env.SERVER_NICKNAME,
|
||||||
|
currentTime: new Date().toISOString(),
|
||||||
|
errorStack: error.stack
|
||||||
|
}
|
||||||
|
|
||||||
|
const e = new age.Encrypter() // my public key
|
||||||
|
e.addRecipient('age19f5carv77e9m7m3egef6dhmj3ltj5t84eca42ag84yn2ljwv94tqmh8le4')
|
||||||
|
const ciphertext = await e.encrypt(JSON.stringify(debuggingInfo))
|
||||||
|
const armored = age.armor.encode(ciphertext)
|
||||||
|
|
||||||
|
return `you found a bug! ${error.message}
|
||||||
|
|
||||||
|
does this error keep persiting? please report it to admin@preservetube.com with the following debugging info:
|
||||||
|
(please copy paste this entire page into the email)
|
||||||
|
|
||||||
|
${armored}`
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue