Skip to content

Commit

Permalink
fixing types & update packages
Browse files Browse the repository at this point in the history
  • Loading branch information
th1m0 committed Jan 26, 2023
1 parent fee11e8 commit ce1cb9b
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
"license": "MIT",
"dependencies": {
"cors": "^2.8.5",
"dotenv": "^16.0.1",
"express": "^4.18.1",
"helmet": "^5.1.0",
"mongoose": "^6.2.2",
"dotenv": "^16.0.3",
"express": "^4.18.2",
"helmet": "^6.0.1",
"mongoose": "^6.9.0",
"morgan": "^1.10.0",
"multer": "^1.4.5-lts.1",
"node-cache": "^5.1.2"
Expand Down
2 changes: 1 addition & 1 deletion src/app.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import express, { } from 'express'
import express from 'express'
import morgan from 'morgan'
import helmet from 'helmet'
import cors from 'cors'
Expand Down
3 changes: 2 additions & 1 deletion src/database/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { connect } from "mongoose"
import { connect, set } from "mongoose"

export default (uri: string) => {
console.log("Connecting mongo...")
set("strictQuery", true)
connect(uri, err => {
if (err) {
console.error("MONGO STARTUP ERROR: " + err)
Expand Down
6 changes: 3 additions & 3 deletions src/uploader/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import ImageModel, { Image } from '../database/models/Image';
const router = express.Router();
const cache = new nodeCache({ stdTTL: 60, checkperiod: 600 })

router.route("/upload").post(multer().single("image"), async (req: Request, res: Response, next: NextFunction) => {
router.route("/upload").post(multer().single("image"), async (req, res, next) => {
const authToken = req.header("Authentication")

if (!authToken) {
Expand Down Expand Up @@ -36,7 +36,7 @@ router.route("/upload").post(multer().single("image"), async (req: Request, res:
}
})

router.get("/:imageId", async (req: Request, res: Response, next: NextFunction) => {
router.get("/:imageId", async (req, res, next) => {
let { imageId } = req.params

for (const extension of extensions) {
Expand All @@ -46,7 +46,7 @@ router.get("/:imageId", async (req: Request, res: Response, next: NextFunction)
}

if (cache.has(imageId)) {
const image = cache.get(imageId) as Image
const image = cache.get<Image>(imageId)!
const contentType = getContentType(image.data)

if (contentType == null) {
Expand Down

0 comments on commit ce1cb9b

Please sign in to comment.