Skip to content

Commit ded2174

Browse files
committed
lint: lib/utils.ts
- install @types/mime-types - add typing annotate
1 parent 6f7c5cc commit ded2174

File tree

3 files changed

+16
-5
lines changed

3 files changed

+16
-5
lines changed

lib/utils.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,30 @@
1+
import {NextFunction, Request, Response} from "express";
12
import * as fs from "fs";
23
import * as path from "path";
34

45
import mime from "mime-types";
56
import bodyParser from "body-parser";
67

7-
export function isSQLite(sequelize) {
8+
export function isSQLite(sequelize): boolean {
89
return sequelize.options.dialect === 'sqlite'
910
}
1011

11-
export function getImageMimeType(imagePath) {
12+
export function getImageMimeType(imagePath: string): string | boolean {
1213
return mime.lookup(path.extname(imagePath))
1314
}
1415

15-
export function isRevealTheme(theme) {
16+
export function isRevealTheme(theme: string): string | undefined {
1617
if (fs.existsSync(path.join(__dirname, '..', 'public', 'build', 'reveal.js', 'css', 'theme', theme + '.css'))) {
1718
return theme
1819
}
1920
return undefined
2021
}
2122

22-
export function wrap(innerHandler) {
23-
return (req, res, next) => innerHandler(req, res).catch(err => next(err))
23+
export function wrap<T>(innerHandler: (req?: Request, res?: Response, next?: NextFunction) => Promise<T>) {
24+
return (req: Request, res: Response, next: NextFunction): void => {
25+
innerHandler(req, res)
26+
.catch(err => next(err));
27+
}
2428
}
2529

2630
// create application/x-www-form-urlencoded parser

package-lock.json

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@
115115
"@types/express-flash": "0.0.2",
116116
"@types/express-session": "^1.17.3",
117117
"@types/lodash": "^4.14.170",
118+
"@types/mime-types": "^2.1.0",
118119
"@types/minio": "^7.0.7",
119120
"@types/node": "~12.20.15",
120121
"@types/passport-google-oauth20": "^2.0.8",

0 commit comments

Comments
 (0)