--
This commit is contained in:
parent
3cd5d356cb
commit
25f973e2b3
37 changed files with 812 additions and 470 deletions
20
backend/src/app/controllers/img/getImageHandler.ts
Normal file
20
backend/src/app/controllers/img/getImageHandler.ts
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
import { Request, Response } from 'express'
|
||||
import Images from '../../db/img.schema'
|
||||
|
||||
export default async (req: Request, res: Response) => {
|
||||
try {
|
||||
const img = await Images.findById(req.params.slug)
|
||||
|
||||
if (img) {
|
||||
res.contentType(img.img.contentType)
|
||||
res.send(img.img.data)
|
||||
} else {
|
||||
res.status(404).end()
|
||||
}
|
||||
} catch (ex) {
|
||||
console.error(ex)
|
||||
return res.status(500).send({
|
||||
error: ex
|
||||
})
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue