Adding autobind decorator to server
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
import childProcess from 'child_process'
|
||||
import path from 'path'
|
||||
import timers from 'timers'
|
||||
import autoBind from 'auto-bind2'
|
||||
import autobind from 'autobind-decorator'
|
||||
|
||||
@autobind
|
||||
export class ServerTool {
|
||||
constructor(toolName, log) {
|
||||
autoBind(this)
|
||||
this.toolName = toolName
|
||||
this.log = log
|
||||
this.actors = [
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
{
|
||||
"presets": [
|
||||
[ "env", {
|
||||
"targets": {
|
||||
"node": 8
|
||||
}
|
||||
}]
|
||||
],
|
||||
"plugins": [
|
||||
"transform-class-properties",
|
||||
"transform-object-rest-spread"
|
||||
]
|
||||
}
|
||||
7
server/src/api/.gitignore
vendored
7
server/src/api/.gitignore
vendored
@@ -1,7 +0,0 @@
|
||||
.DS_STORE
|
||||
*.log
|
||||
node_modules
|
||||
dist
|
||||
coverage
|
||||
**/local*.json*
|
||||
.idea/
|
||||
@@ -1,10 +1,10 @@
|
||||
import amqp from 'amqplib'
|
||||
import uuidv4 from 'uuid/v4'
|
||||
import autoBind from 'auto-bind2'
|
||||
import autobind from 'autobind-decorator'
|
||||
|
||||
@autobind
|
||||
export class MQ {
|
||||
constructor(container) {
|
||||
autoBind(this)
|
||||
this.container = container
|
||||
this.log = container.log
|
||||
this.replyQueueName = `reply-${uuidv4()}`
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import IOServer from 'socket.io'
|
||||
import autoBind from 'auto-bind2'
|
||||
import autobind from 'autobind-decorator'
|
||||
|
||||
@autobind
|
||||
export class WS {
|
||||
constructor(container) {
|
||||
this.log = container.log
|
||||
this.io = new IOServer(container.server, { path: '/socketio' })
|
||||
this.socketMap = {}
|
||||
this.db = container.db
|
||||
autoBind(this)
|
||||
}
|
||||
|
||||
listen() {
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -6,9 +6,10 @@ import crypto from 'crypto'
|
||||
import urlSafeBase64 from 'urlsafe-base64'
|
||||
import util from 'util'
|
||||
import * as loginToken from './loginToken'
|
||||
import autoBind from 'auto-bind2'
|
||||
import autobind from 'autobind-decorator'
|
||||
import url from 'url'
|
||||
|
||||
@autobind
|
||||
export class AuthRoutes {
|
||||
constructor(container) {
|
||||
const app = container.app
|
||||
@@ -20,7 +21,6 @@ export class AuthRoutes {
|
||||
this.sendEmailDelayInSeconds = config.get('email.sendEmailDelayInSeconds')
|
||||
this.supportEmail = config.get('email.supportEmail')
|
||||
this.sendEmail = config.get('email.sendEmail')
|
||||
autoBind(this)
|
||||
app.route('/auth/login')
|
||||
// Used to login. Email must be confirmed.
|
||||
.post(this.login)
|
||||
@@ -194,7 +194,7 @@ export class AuthRoutes {
|
||||
if (this.sendEmail) {
|
||||
await this.mq.request('dar-email', 'sendEmail', msgs)
|
||||
}
|
||||
|
||||
|
||||
res.json({})
|
||||
} catch(err) {
|
||||
if (err instanceof createError.HttpError) {
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import passport from 'passport'
|
||||
import createError from 'http-errors'
|
||||
import { makeFingerprint } from '../makeFingerprint'
|
||||
import autoBind from 'auto-bind2'
|
||||
import autobind from 'autobind-decorator'
|
||||
|
||||
@autobind
|
||||
export class ProjectRoutes {
|
||||
constructor(container) {
|
||||
const app = container.app
|
||||
@@ -11,7 +12,6 @@ export class ProjectRoutes {
|
||||
this.db = container.db
|
||||
this.mq = container.mq
|
||||
this.ws = container.ws
|
||||
autoBind(this)
|
||||
|
||||
app.route('/projects')
|
||||
.get(passport.authenticate('bearer', { session: false }), this.listProjects)
|
||||
|
||||
@@ -4,9 +4,10 @@ import crypto from 'crypto'
|
||||
import urlSafeBase64 from 'urlsafe-base64'
|
||||
import url from 'url'
|
||||
import util from 'util'
|
||||
import autoBind from 'auto-bind2'
|
||||
import autobind from 'autobind-decorator'
|
||||
import config from 'config'
|
||||
|
||||
@autobind
|
||||
export class UserRoutes {
|
||||
constructor(container) {
|
||||
const app = container.app
|
||||
@@ -17,7 +18,6 @@ export class UserRoutes {
|
||||
this.ws = container.ws
|
||||
this.maxEmailTokenAgeInHours = config.get('email.maxEmailTokenAgeInHours')
|
||||
this.sendEmail = config.get('email.sendEmail')
|
||||
autoBind(this)
|
||||
app.route('/users')
|
||||
.get(passport.authenticate('bearer', { session: false }), this.listUsers)
|
||||
// Add a new user, send email confirmation email
|
||||
|
||||
@@ -7,12 +7,11 @@ import readlineSync from 'readline-sync'
|
||||
import crypto from 'crypto'
|
||||
import urlSafeBase64 from 'urlsafe-base64'
|
||||
import util from 'util'
|
||||
import autobind from 'autobind-decorator'
|
||||
|
||||
import autoBind from 'auto-bind2'
|
||||
|
||||
@autobind
|
||||
class AddUserTool {
|
||||
constructor(toolName, log) {
|
||||
autoBind(this)
|
||||
this.toolName = toolName
|
||||
this.log = log
|
||||
}
|
||||
|
||||
@@ -4,11 +4,11 @@ import JSON5 from 'json5'
|
||||
import fs from 'fs'
|
||||
import uuidv4 from 'uuid/v4'
|
||||
import chalk from 'chalk'
|
||||
import autoBind from 'auto-bind2'
|
||||
import autobind from 'autobind-decorator'
|
||||
|
||||
@autobind
|
||||
class SendMessageTool {
|
||||
constructor(toolName, log) {
|
||||
autoBind(this)
|
||||
this.toolName = toolName
|
||||
this.log = log
|
||||
}
|
||||
|
||||
@@ -2,18 +2,17 @@ import mongoose from 'mongoose'
|
||||
import mongodb from 'mongodb'
|
||||
import Grid from 'gridfs-stream'
|
||||
import merge from 'mongoose-merge-plugin'
|
||||
import autoBind from 'auto-bind2'
|
||||
import autobind from 'autobind-decorator'
|
||||
import * as Schemas from './schemas'
|
||||
import util from 'util'
|
||||
|
||||
Grid.mongo = mongoose.mongo
|
||||
|
||||
@autobind
|
||||
export class DB {
|
||||
constructor() {
|
||||
mongoose.Promise = Promise
|
||||
mongoose.plugin(merge)
|
||||
|
||||
autoBind(this)
|
||||
}
|
||||
|
||||
connect(mongoUri, isProduction) {
|
||||
|
||||
@@ -8,8 +8,9 @@ import appRoot from 'app-root-path'
|
||||
import JSON5 from 'json5'
|
||||
import aws from 'aws-sdk'
|
||||
import config from 'config'
|
||||
import autoBind from 'auto-bind2'
|
||||
import autobind from 'autobind-decorator'
|
||||
|
||||
@autobind
|
||||
export class EmailHandlers {
|
||||
constructor(container) {
|
||||
this.log = container.log
|
||||
@@ -35,8 +36,6 @@ export class EmailHandlers {
|
||||
html: def.html ? handlebars.compile(fs.readFileSync(def.html).toString()) : null
|
||||
}
|
||||
}
|
||||
|
||||
autoBind(this)
|
||||
}
|
||||
|
||||
sendEmail(options) {
|
||||
|
||||
@@ -2,7 +2,7 @@ import Canvas from 'canvas'
|
||||
import fs from 'fs'
|
||||
import util from 'util'
|
||||
import createError from 'http-errors'
|
||||
import autoBind from 'auto-bind2'
|
||||
import autobind from 'autobind-decorator'
|
||||
import stream from 'stream'
|
||||
|
||||
function streamToBuffer(readable) {
|
||||
@@ -132,11 +132,11 @@ function normalizeOrientation(image, orientation) {
|
||||
return loadImage(canvas.toBuffer())
|
||||
}
|
||||
|
||||
@autobind
|
||||
export class ImageHandlers {
|
||||
constructor(container) {
|
||||
this.db = container.db
|
||||
this.log = container.log
|
||||
autoBind(this)
|
||||
}
|
||||
|
||||
scaleImage(options) {
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
import amqp from 'amqplib'
|
||||
import autoBind from 'auto-bind2'
|
||||
import autobind from 'autobind-decorator'
|
||||
import createError from 'http-errors'
|
||||
|
||||
@autobind
|
||||
export class MS {
|
||||
constructor(exchangeName, options, log) {
|
||||
this.exchangeName = exchangeName
|
||||
this.options = options || {}
|
||||
this.isProduction = (process.env.NODE_ENV === 'production')
|
||||
this.log = log
|
||||
autoBind(this)
|
||||
}
|
||||
|
||||
async connect(amqpUri) {
|
||||
|
||||
Reference in New Issue
Block a user