Upgrade server dependencies
This commit is contained in:
parent
20f9f0f708
commit
56aaa2ccdd
26
package.json
26
package.json
|
@ -30,26 +30,24 @@
|
||||||
"cors": "^2.8.5",
|
"cors": "^2.8.5",
|
||||||
"express": "^4.16.4",
|
"express": "^4.16.4",
|
||||||
"express-validator": "^6.1.1",
|
"express-validator": "^6.1.1",
|
||||||
"fs-extra": "^9.0.1",
|
"fs-extra": "^10.0.0",
|
||||||
"js-yaml": "^3.12.1",
|
"js-yaml": "^4.1.0",
|
||||||
"lodash": "^4.17.15",
|
"lodash": "^4.17.15",
|
||||||
"mkdirp": "^1.0.4",
|
"mkdirp": "^1.0.4",
|
||||||
"morgan": "^1.9.1",
|
"morgan": "^1.9.1",
|
||||||
"multer": "^1.4.1",
|
"multer": "^1.4.1",
|
||||||
"pg": "^8.2.1",
|
"pg": "^8.2.1",
|
||||||
"pino": "^6.3.0",
|
"pino": "^6.3.0",
|
||||||
"pino-pretty": "^4.0.0",
|
"pino-pretty": "^5.1.0",
|
||||||
"reflect-metadata": "^0.1.13",
|
"reflect-metadata": "^0.1.13",
|
||||||
"request": "^2.88.0",
|
"request": "^2.88.0",
|
||||||
"retry": "^0.12.0",
|
"retry": "^0.13.1",
|
||||||
"sequelize": "5.21.11",
|
|
||||||
"sequelize-typescript": "^1.0.0-beta.3",
|
|
||||||
"source-map-support": "^0.5.10"
|
"source-map-support": "^0.5.10"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/async": "^3.0.0",
|
"@types/async": "^3.0.0",
|
||||||
"@types/body-parser": "^1.16.3",
|
"@types/body-parser": "^1.16.3",
|
||||||
"@types/config": "^0.0.36",
|
"@types/config": "^0.0.38",
|
||||||
"@types/express": "^4.16.1",
|
"@types/express": "^4.16.1",
|
||||||
"@types/fluent-ffmpeg": "^2.1.14",
|
"@types/fluent-ffmpeg": "^2.1.14",
|
||||||
"@types/fs-extra": "^9.0.1",
|
"@types/fs-extra": "^9.0.1",
|
||||||
|
@ -57,19 +55,19 @@
|
||||||
"@types/mkdirp": "^1.0.0",
|
"@types/mkdirp": "^1.0.0",
|
||||||
"@types/morgan": "^1.7.32",
|
"@types/morgan": "^1.7.32",
|
||||||
"@types/multer": "^1.3.3",
|
"@types/multer": "^1.3.3",
|
||||||
"@types/node": "^14.0.5",
|
"@types/node": "^15.12.4",
|
||||||
"@types/pino": "^6.0.1",
|
"@types/pino": "^6.0.1",
|
||||||
"@types/request": "^2.48.1",
|
"@types/request": "^2.48.1",
|
||||||
"@types/sequelize": "^4.27.35",
|
"@types/sequelize": "^4.27.35",
|
||||||
"@types/validator": "^13.0.0",
|
"@types/validator": "^13.0.0",
|
||||||
"@typescript-eslint/eslint-plugin": "^3.0.2",
|
"@typescript-eslint/eslint-plugin": "^4.28.0",
|
||||||
"@typescript-eslint/parser": "^3.0.2",
|
"@typescript-eslint/parser": "^4.28.0",
|
||||||
"eslint": "^7.1.0",
|
"eslint": "^7.1.0",
|
||||||
"eslint-config-standard-with-typescript": "^18.0.2",
|
"eslint-config-standard-with-typescript": "^20.0.0",
|
||||||
"eslint-plugin-import": "^2.20.1",
|
"eslint-plugin-import": "^2.20.1",
|
||||||
"eslint-plugin-node": "^11.0.0",
|
"eslint-plugin-node": "^11.0.0",
|
||||||
"eslint-plugin-promise": "^4.2.1",
|
"eslint-plugin-promise": "^5.1.0",
|
||||||
"eslint-plugin-standard": "^4.0.1",
|
"eslint-plugin-standard": "^5.0.0",
|
||||||
"typescript": "^3.7.5"
|
"typescript": "^4.3.4"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,11 +5,11 @@ function badRequest (req: express.Request, res: express.Response) {
|
||||||
return res.type('json').status(400).end()
|
return res.type('json').status(400).end()
|
||||||
}
|
}
|
||||||
|
|
||||||
interface FormattableToJSON {
|
interface FormattableToJSON <T> {
|
||||||
toFormattedJSON ()
|
toFormattedJSON: () => T
|
||||||
}
|
}
|
||||||
|
|
||||||
function getFormattedObjects<U, T extends FormattableToJSON> (objects: T[], objectsTotal: number) {
|
function getFormattedObjects<U, T extends FormattableToJSON<U>> (objects: T[], objectsTotal: number) {
|
||||||
const formattedObjects: U[] = []
|
const formattedObjects: U[] = []
|
||||||
|
|
||||||
objects.forEach(object => {
|
objects.forEach(object => {
|
||||||
|
|
|
@ -38,6 +38,7 @@ export abstract class AbstractIndexer <T extends IndexableDoc, DB> {
|
||||||
|
|
||||||
scheduleIndexation (host: string, identifier: string) {
|
scheduleIndexation (host: string, identifier: string) {
|
||||||
this.indexQueue.push({ identifier, host })
|
this.indexQueue.push({ identifier, host })
|
||||||
|
.catch(err => logger.error({ err: inspect(err) }, 'Cannot schedule indexation of %s for %s', identifier, host))
|
||||||
}
|
}
|
||||||
|
|
||||||
refreshIndex () {
|
refreshIndex () {
|
||||||
|
|
|
@ -2,16 +2,15 @@ import { eachSeries } from 'async'
|
||||||
import { NextFunction, Request, RequestHandler, Response } from 'express'
|
import { NextFunction, Request, RequestHandler, Response } from 'express'
|
||||||
import { ValidationChain } from 'express-validator'
|
import { ValidationChain } from 'express-validator'
|
||||||
|
|
||||||
// Syntactic sugar to avoid try/catch in express controllers
|
export type ExpressPromiseHandler = (req: Request<any>, res: Response, next: NextFunction) => Promise<any>
|
||||||
// Thanks: https://medium.com/@Abazhenov/using-async-await-in-express-with-node-8-b8af872c0016
|
|
||||||
|
|
||||||
export type RequestPromiseHandler = ValidationChain | ((req: Request, res: Response, next: NextFunction) => Promise<any>)
|
export type RequestPromiseHandler = ValidationChain | ExpressPromiseHandler
|
||||||
|
|
||||||
function asyncMiddleware (fun: RequestPromiseHandler | RequestPromiseHandler[]) {
|
function asyncMiddleware (fun: RequestPromiseHandler | RequestPromiseHandler[]) {
|
||||||
return (req: Request, res: Response, next: NextFunction) => {
|
return (req: Request, res: Response, next: NextFunction) => {
|
||||||
if (Array.isArray(fun) === true) {
|
if (Array.isArray(fun) === true) {
|
||||||
return eachSeries(fun as RequestHandler[], (f, cb) => {
|
return eachSeries(fun as RequestHandler[], (f, cb) => {
|
||||||
Promise.resolve(f(req, res, cb))
|
Promise.resolve(f(req, res, err => cb(err)))
|
||||||
.catch(err => next(err))
|
.catch(err => next(err))
|
||||||
}, next)
|
}, next)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import "express";
|
import "express"
|
||||||
|
|
||||||
declare module "express" {
|
declare module "express" {
|
||||||
export interface Request {
|
export interface Request {
|
||||||
|
|
Loading…
Reference in New Issue