Adding autobind decorator to server

This commit is contained in:
John Lyon-Smith
2018-03-26 11:37:18 -07:00
parent 80c37f8642
commit 49ca7f3bf1
18 changed files with 51 additions and 55 deletions

View File

@@ -5,7 +5,7 @@ import createError from 'http-errors'
import path from 'path'
import util from 'util'
import config from 'config'
import autoBind from 'auto-bind2'
import autobind from 'autobind-decorator'
function pipeToGridFS(readable, gfsWriteable) {
const promise = new Promise((resolve, reject) => {
@@ -23,6 +23,7 @@ function pipeToGridFS(readable, gfsWriteable) {
return promise
}
@autobind
export class AssetRoutes {
static rangeRegex = /^byte (\d+)/
@@ -32,7 +33,6 @@ export class AssetRoutes {
this.db = container.db
this.rs = container.rs
this.uploadTimeout = config.get('api.uploadTimout')
autoBind(this)
app.route('/assets/:_id')
.get(passport.authenticate('bearer', { session: false }), this.getAsset)
.delete(passport.authenticate('bearer', { session: false }), this.deleteAsset)