Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
ITJesse committed Nov 13, 2023
2 parents 2ea2576 + 5739543 commit 4cfebf4
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 3 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"express": "^4.18.2",
"fluent-ffmpeg": "^2.1.2",
"fp-ts": "^2.13.1",
"helmet": "^7.1.0",
"io-ts": "^2.2.20",
"io-ts-types": "^0.5.19",
"ioredis": "^5.2.5",
Expand Down
2 changes: 2 additions & 0 deletions src/server/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import express from 'express'
import fs from 'fs'
import helmet from 'helmet'
import morgan from 'morgan'

import { config } from '@/lib/config'
Expand All @@ -26,6 +27,7 @@ if (config.sentryDsn) {
app.use(Sentry.Handlers.tracingHandler())
}

app.use(helmet({ crossOriginResourcePolicy: false }))
app.use(
morgan('dev', {
...(config.log.accessLog === 'stdout'
Expand Down
2 changes: 1 addition & 1 deletion src/server/routes/animation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ router.head('/', async (req, res) => {
'Content-Type': `video/${format}`,
'Cache-Control': 'public, max-age=31536000, must-revalidate',
'x-image-cache': cacheStatus.toUpperCase(),
age: `${age}`,
'x-image-age': `${age}`,
})
res.end()
logger.info(`[${cacheStatus.toUpperCase()}] ${url}, format:${format}`)
Expand Down
8 changes: 6 additions & 2 deletions src/server/routes/image.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ router.get('/', async (req, res) => {
const { accept } = headers
const acceptFormats =
accept
?.split(',')
?.replace('jpg', 'jpeg')
.toLowerCase()
.split(',')
.map((e) => e.split(';'))
.flat()
.filter((e) => e.startsWith('image/'))
Expand All @@ -100,6 +102,8 @@ router.get('/', async (req, res) => {
},
)
const contentType = imageHeaders['content-type']
?.replace('jpg', 'jpeg')
.toLowerCase()
if (!contentType || !supportedFormats.includes(contentType)) {
return ['Unsupported format']
}
Expand All @@ -124,7 +128,7 @@ router.get('/', async (req, res) => {
'Content-Type': targetFormat,
'Cache-Control': 'public, max-age=31536000, must-revalidate',
'x-image-cache': cacheStatus.toUpperCase(),
age: `${age}`,
'x-image-age': `${age}`,
})
logger.info(
`[${cacheStatus.toUpperCase()}] ${params.url}, W:${
Expand Down
8 changes: 8 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2491,6 +2491,13 @@ __metadata:
languageName: node
linkType: hard

"helmet@npm:^7.1.0":
version: 7.1.0
resolution: "helmet@npm:7.1.0"
checksum: 8c3370d07487be11ac918577c68952e05d779a1a2c037023c1ba763034c381a025899bc52f8acfab5209304a1dc618a3764dbfd26386a0d1173befe4fb932e84
languageName: node
linkType: hard

"http-cache-semantics@npm:3.8.1":
version: 3.8.1
resolution: "http-cache-semantics@npm:3.8.1"
Expand Down Expand Up @@ -2612,6 +2619,7 @@ __metadata:
express: "npm:^4.18.2"
fluent-ffmpeg: "npm:^2.1.2"
fp-ts: "npm:^2.13.1"
helmet: "npm:^7.1.0"
io-ts: "npm:^2.2.20"
io-ts-types: "npm:^0.5.19"
ioredis: "npm:^5.2.5"
Expand Down

0 comments on commit 4cfebf4

Please sign in to comment.