discord_embed: Fix logging, fix 404 detection, fix big int problem with mssql (for now), fix adding back /health route
Some checks reported errors
continuous-integration/appveyor/branch AppVeyor build cancelled
Some checks reported errors
continuous-integration/appveyor/branch AppVeyor build cancelled
This commit is contained in:
parent
3385058fc9
commit
a13ac57bc8
3 changed files with 9 additions and 3 deletions
|
@ -31,7 +31,7 @@ export default class ServeHandler extends Parent {
|
||||||
let videoLink = ctx.query.get('v') || ''
|
let videoLink = ctx.query.get('v') || ''
|
||||||
let imageLink = ctx.query.get('i') || ''
|
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 {
|
try {
|
||||||
let id = AlphabeticID.decode(ctx.url.slice(1))
|
let id = AlphabeticID.decode(ctx.url.slice(1))
|
||||||
if (id) {
|
if (id) {
|
||||||
|
@ -39,12 +39,16 @@ export default class ServeHandler extends Parent {
|
||||||
if (res.first.length) {
|
if (res.first.length) {
|
||||||
videoLink = res.first[0].video_link
|
videoLink = res.first[0].video_link
|
||||||
imageLink = res.first[0].image_link
|
imageLink = res.first[0].image_link
|
||||||
|
} else {
|
||||||
|
ctx.status = 404
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} 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.'
|
ctx.state.error = 'Unknown error while fetching link.'
|
||||||
}
|
}
|
||||||
|
} else if (ctx.url !== '/') {
|
||||||
|
ctx.status = 404
|
||||||
}
|
}
|
||||||
|
|
||||||
let payload = {
|
let payload = {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import Redis from 'ioredis'
|
import Redis from 'ioredis'
|
||||||
import config from '../base/config.mjs'
|
import config from '../base/config.mjs'
|
||||||
import Parent from '../base/server.mjs'
|
import Parent from '../base/server.mjs'
|
||||||
|
import StaticRoutes from '../base/static_routes.mjs'
|
||||||
import IndexPost from './post.mjs'
|
import IndexPost from './post.mjs'
|
||||||
import ServeHandler from './serve.mjs'
|
import ServeHandler from './serve.mjs'
|
||||||
|
|
||||||
|
@ -16,6 +17,7 @@ export default class Server extends Parent {
|
||||||
this.core.log.error(err)
|
this.core.log.error(err)
|
||||||
})
|
})
|
||||||
this.routes = {
|
this.routes = {
|
||||||
|
static: new StaticRoutes(),
|
||||||
post: new IndexPost({
|
post: new IndexPost({
|
||||||
frontend: config.get('frontend:url'),
|
frontend: config.get('frontend:url'),
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "discord_embed",
|
"name": "discord_embed",
|
||||||
"version": "1.0.1",
|
"version": "1.0.2",
|
||||||
"port": 4120,
|
"port": 4120,
|
||||||
"description": "AV1 discord server embed helper",
|
"description": "AV1 discord server embed helper",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
|
|
Loading…
Reference in a new issue