discord_embed: Fix logging, fix 404 detection, fix big int problem with mssql (for now), fix adding back /health route
continuous-integration/appveyor/branch AppVeyor build cancelled Details

master
Jonatan Nilsson 2022-10-17 14:57:13 +00:00
parent 3385058fc9
commit a13ac57bc8
3 changed files with 9 additions and 3 deletions

View File

@ -31,7 +31,7 @@ export default class ServeHandler extends Parent {
let videoLink = ctx.query.get('v') || ''
let imageLink = ctx.query.get('i') || ''
if (ctx.url.match(/^\/[a-zA-Z0-9][a-zA-Z0-9][a-zA-Z0-9]+$/)) {
if (ctx.url.match(/^\/[a-zA-Z0-9][a-zA-Z0-9][a-zA-Z0-9]+$/) && ctx.url.length < 7) {
try {
let id = AlphabeticID.decode(ctx.url.slice(1))
if (id) {
@ -39,12 +39,16 @@ export default class ServeHandler extends Parent {
if (res.first.length) {
videoLink = res.first[0].video_link
imageLink = res.first[0].image_link
} else {
ctx.status = 404
}
}
} catch (err) {
ctx.log.error(err)
ctx.log.error(err, 'Unable to fetch resource ' + ctx.url.slice(1))
ctx.state.error = 'Unknown error while fetching link.'
}
} else if (ctx.url !== '/') {
ctx.status = 404
}
let payload = {

View File

@ -1,6 +1,7 @@
import Redis from 'ioredis'
import config from '../base/config.mjs'
import Parent from '../base/server.mjs'
import StaticRoutes from '../base/static_routes.mjs'
import IndexPost from './post.mjs'
import ServeHandler from './serve.mjs'
@ -16,6 +17,7 @@ export default class Server extends Parent {
this.core.log.error(err)
})
this.routes = {
static: new StaticRoutes(),
post: new IndexPost({
frontend: config.get('frontend:url'),
})

View File

@ -1,6 +1,6 @@
{
"name": "discord_embed",
"version": "1.0.1",
"version": "1.0.2",
"port": 4120,
"description": "AV1 discord server embed helper",
"main": "index.js",