Adding autobind decorator to server
This commit is contained in:
@@ -7,6 +7,7 @@
|
|||||||
}]
|
}]
|
||||||
],
|
],
|
||||||
"plugins": [
|
"plugins": [
|
||||||
|
"transform-decorators-legacy",
|
||||||
"transform-class-properties",
|
"transform-class-properties",
|
||||||
"transform-object-rest-spread"
|
"transform-object-rest-spread"
|
||||||
]
|
]
|
||||||
|
|||||||
17
server/package-lock.json
generated
17
server/package-lock.json
generated
@@ -566,6 +566,12 @@
|
|||||||
"integrity": "sha1-1+sjt5oxf4VDlixQW4J8fWysJ94=",
|
"integrity": "sha1-1+sjt5oxf4VDlixQW4J8fWysJ94=",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"babel-plugin-syntax-decorators": {
|
||||||
|
"version": "6.13.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/babel-plugin-syntax-decorators/-/babel-plugin-syntax-decorators-6.13.0.tgz",
|
||||||
|
"integrity": "sha1-MSVjtNvePMgGzuPkFszurd0RrAs=",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
"babel-plugin-syntax-exponentiation-operator": {
|
"babel-plugin-syntax-exponentiation-operator": {
|
||||||
"version": "6.13.0",
|
"version": "6.13.0",
|
||||||
"resolved": "https://registry.npmjs.org/babel-plugin-syntax-exponentiation-operator/-/babel-plugin-syntax-exponentiation-operator-6.13.0.tgz",
|
"resolved": "https://registry.npmjs.org/babel-plugin-syntax-exponentiation-operator/-/babel-plugin-syntax-exponentiation-operator-6.13.0.tgz",
|
||||||
@@ -607,6 +613,17 @@
|
|||||||
"babel-template": "6.26.0"
|
"babel-template": "6.26.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"babel-plugin-transform-decorators-legacy": {
|
||||||
|
"version": "1.3.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/babel-plugin-transform-decorators-legacy/-/babel-plugin-transform-decorators-legacy-1.3.4.tgz",
|
||||||
|
"integrity": "sha1-dBtY9sW86eYCfgiC2cmU8E82aSU=",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"babel-plugin-syntax-decorators": "6.13.0",
|
||||||
|
"babel-runtime": "6.26.0",
|
||||||
|
"babel-template": "6.26.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"babel-plugin-transform-es2015-arrow-functions": {
|
"babel-plugin-transform-es2015-arrow-functions": {
|
||||||
"version": "6.22.0",
|
"version": "6.22.0",
|
||||||
"resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-arrow-functions/-/babel-plugin-transform-es2015-arrow-functions-6.22.0.tgz",
|
"resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-arrow-functions/-/babel-plugin-transform-es2015-arrow-functions-6.22.0.tgz",
|
||||||
|
|||||||
@@ -54,17 +54,18 @@
|
|||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"babel-cli": "^6.24.1",
|
"babel-cli": "^6.24.1",
|
||||||
"babel-plugin-transform-class-properties": "^6.24.1",
|
"babel-plugin-transform-class-properties": "^6.24.1",
|
||||||
|
"babel-plugin-transform-decorators-legacy": "^1.3.4",
|
||||||
"babel-plugin-transform-object-rest-spread": "^6.23.0",
|
"babel-plugin-transform-object-rest-spread": "^6.23.0",
|
||||||
"babel-preset-env": "^1.5.2",
|
"babel-preset-env": "^1.5.2",
|
||||||
"jest": "^21.1.0",
|
"jest": "^21.1.0",
|
||||||
"monzilla": "^1.1.0"
|
"monzilla": "^1.1.0"
|
||||||
},
|
},
|
||||||
"private": true,
|
"private": true,
|
||||||
"keywords": {
|
"keywords": [
|
||||||
"0": "rest",
|
"rest",
|
||||||
"1": "api",
|
"api",
|
||||||
"2": "deighton"
|
"deighton"
|
||||||
},
|
],
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "git+ssh://git@github.com/KingstonSoftware/deighton-ar.git"
|
"url": "git+ssh://git@github.com/KingstonSoftware/deighton-ar.git"
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
import childProcess from 'child_process'
|
import childProcess from 'child_process'
|
||||||
import path from 'path'
|
import path from 'path'
|
||||||
import timers from 'timers'
|
import timers from 'timers'
|
||||||
import autoBind from 'auto-bind2'
|
import autobind from 'autobind-decorator'
|
||||||
|
|
||||||
|
@autobind
|
||||||
export class ServerTool {
|
export class ServerTool {
|
||||||
constructor(toolName, log) {
|
constructor(toolName, log) {
|
||||||
autoBind(this)
|
|
||||||
this.toolName = toolName
|
this.toolName = toolName
|
||||||
this.log = log
|
this.log = log
|
||||||
this.actors = [
|
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 amqp from 'amqplib'
|
||||||
import uuidv4 from 'uuid/v4'
|
import uuidv4 from 'uuid/v4'
|
||||||
import autoBind from 'auto-bind2'
|
import autobind from 'autobind-decorator'
|
||||||
|
|
||||||
|
@autobind
|
||||||
export class MQ {
|
export class MQ {
|
||||||
constructor(container) {
|
constructor(container) {
|
||||||
autoBind(this)
|
|
||||||
this.container = container
|
this.container = container
|
||||||
this.log = container.log
|
this.log = container.log
|
||||||
this.replyQueueName = `reply-${uuidv4()}`
|
this.replyQueueName = `reply-${uuidv4()}`
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
import IOServer from 'socket.io'
|
import IOServer from 'socket.io'
|
||||||
import autoBind from 'auto-bind2'
|
import autobind from 'autobind-decorator'
|
||||||
|
|
||||||
|
@autobind
|
||||||
export class WS {
|
export class WS {
|
||||||
constructor(container) {
|
constructor(container) {
|
||||||
this.log = container.log
|
this.log = container.log
|
||||||
this.io = new IOServer(container.server, { path: '/socketio' })
|
this.io = new IOServer(container.server, { path: '/socketio' })
|
||||||
this.socketMap = {}
|
this.socketMap = {}
|
||||||
this.db = container.db
|
this.db = container.db
|
||||||
autoBind(this)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
listen() {
|
listen() {
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import createError from 'http-errors'
|
|||||||
import path from 'path'
|
import path from 'path'
|
||||||
import util from 'util'
|
import util from 'util'
|
||||||
import config from 'config'
|
import config from 'config'
|
||||||
import autoBind from 'auto-bind2'
|
import autobind from 'autobind-decorator'
|
||||||
|
|
||||||
function pipeToGridFS(readable, gfsWriteable) {
|
function pipeToGridFS(readable, gfsWriteable) {
|
||||||
const promise = new Promise((resolve, reject) => {
|
const promise = new Promise((resolve, reject) => {
|
||||||
@@ -23,6 +23,7 @@ function pipeToGridFS(readable, gfsWriteable) {
|
|||||||
return promise
|
return promise
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@autobind
|
||||||
export class AssetRoutes {
|
export class AssetRoutes {
|
||||||
static rangeRegex = /^byte (\d+)/
|
static rangeRegex = /^byte (\d+)/
|
||||||
|
|
||||||
@@ -32,7 +33,6 @@ export class AssetRoutes {
|
|||||||
this.db = container.db
|
this.db = container.db
|
||||||
this.rs = container.rs
|
this.rs = container.rs
|
||||||
this.uploadTimeout = config.get('api.uploadTimout')
|
this.uploadTimeout = config.get('api.uploadTimout')
|
||||||
autoBind(this)
|
|
||||||
app.route('/assets/:_id')
|
app.route('/assets/:_id')
|
||||||
.get(passport.authenticate('bearer', { session: false }), this.getAsset)
|
.get(passport.authenticate('bearer', { session: false }), this.getAsset)
|
||||||
.delete(passport.authenticate('bearer', { session: false }), this.deleteAsset)
|
.delete(passport.authenticate('bearer', { session: false }), this.deleteAsset)
|
||||||
|
|||||||
@@ -6,9 +6,10 @@ import crypto from 'crypto'
|
|||||||
import urlSafeBase64 from 'urlsafe-base64'
|
import urlSafeBase64 from 'urlsafe-base64'
|
||||||
import util from 'util'
|
import util from 'util'
|
||||||
import * as loginToken from './loginToken'
|
import * as loginToken from './loginToken'
|
||||||
import autoBind from 'auto-bind2'
|
import autobind from 'autobind-decorator'
|
||||||
import url from 'url'
|
import url from 'url'
|
||||||
|
|
||||||
|
@autobind
|
||||||
export class AuthRoutes {
|
export class AuthRoutes {
|
||||||
constructor(container) {
|
constructor(container) {
|
||||||
const app = container.app
|
const app = container.app
|
||||||
@@ -20,7 +21,6 @@ export class AuthRoutes {
|
|||||||
this.sendEmailDelayInSeconds = config.get('email.sendEmailDelayInSeconds')
|
this.sendEmailDelayInSeconds = config.get('email.sendEmailDelayInSeconds')
|
||||||
this.supportEmail = config.get('email.supportEmail')
|
this.supportEmail = config.get('email.supportEmail')
|
||||||
this.sendEmail = config.get('email.sendEmail')
|
this.sendEmail = config.get('email.sendEmail')
|
||||||
autoBind(this)
|
|
||||||
app.route('/auth/login')
|
app.route('/auth/login')
|
||||||
// Used to login. Email must be confirmed.
|
// Used to login. Email must be confirmed.
|
||||||
.post(this.login)
|
.post(this.login)
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
import passport from 'passport'
|
import passport from 'passport'
|
||||||
import createError from 'http-errors'
|
import createError from 'http-errors'
|
||||||
import { makeFingerprint } from '../makeFingerprint'
|
import { makeFingerprint } from '../makeFingerprint'
|
||||||
import autoBind from 'auto-bind2'
|
import autobind from 'autobind-decorator'
|
||||||
|
|
||||||
|
@autobind
|
||||||
export class ProjectRoutes {
|
export class ProjectRoutes {
|
||||||
constructor(container) {
|
constructor(container) {
|
||||||
const app = container.app
|
const app = container.app
|
||||||
@@ -11,7 +12,6 @@ export class ProjectRoutes {
|
|||||||
this.db = container.db
|
this.db = container.db
|
||||||
this.mq = container.mq
|
this.mq = container.mq
|
||||||
this.ws = container.ws
|
this.ws = container.ws
|
||||||
autoBind(this)
|
|
||||||
|
|
||||||
app.route('/projects')
|
app.route('/projects')
|
||||||
.get(passport.authenticate('bearer', { session: false }), this.listProjects)
|
.get(passport.authenticate('bearer', { session: false }), this.listProjects)
|
||||||
|
|||||||
@@ -4,9 +4,10 @@ import crypto from 'crypto'
|
|||||||
import urlSafeBase64 from 'urlsafe-base64'
|
import urlSafeBase64 from 'urlsafe-base64'
|
||||||
import url from 'url'
|
import url from 'url'
|
||||||
import util from 'util'
|
import util from 'util'
|
||||||
import autoBind from 'auto-bind2'
|
import autobind from 'autobind-decorator'
|
||||||
import config from 'config'
|
import config from 'config'
|
||||||
|
|
||||||
|
@autobind
|
||||||
export class UserRoutes {
|
export class UserRoutes {
|
||||||
constructor(container) {
|
constructor(container) {
|
||||||
const app = container.app
|
const app = container.app
|
||||||
@@ -17,7 +18,6 @@ export class UserRoutes {
|
|||||||
this.ws = container.ws
|
this.ws = container.ws
|
||||||
this.maxEmailTokenAgeInHours = config.get('email.maxEmailTokenAgeInHours')
|
this.maxEmailTokenAgeInHours = config.get('email.maxEmailTokenAgeInHours')
|
||||||
this.sendEmail = config.get('email.sendEmail')
|
this.sendEmail = config.get('email.sendEmail')
|
||||||
autoBind(this)
|
|
||||||
app.route('/users')
|
app.route('/users')
|
||||||
.get(passport.authenticate('bearer', { session: false }), this.listUsers)
|
.get(passport.authenticate('bearer', { session: false }), this.listUsers)
|
||||||
// Add a new user, send email confirmation email
|
// Add a new user, send email confirmation email
|
||||||
|
|||||||
@@ -7,12 +7,11 @@ import readlineSync from 'readline-sync'
|
|||||||
import crypto from 'crypto'
|
import crypto from 'crypto'
|
||||||
import urlSafeBase64 from 'urlsafe-base64'
|
import urlSafeBase64 from 'urlsafe-base64'
|
||||||
import util from 'util'
|
import util from 'util'
|
||||||
|
import autobind from 'autobind-decorator'
|
||||||
|
|
||||||
import autoBind from 'auto-bind2'
|
@autobind
|
||||||
|
|
||||||
class AddUserTool {
|
class AddUserTool {
|
||||||
constructor(toolName, log) {
|
constructor(toolName, log) {
|
||||||
autoBind(this)
|
|
||||||
this.toolName = toolName
|
this.toolName = toolName
|
||||||
this.log = log
|
this.log = log
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,11 +4,11 @@ import JSON5 from 'json5'
|
|||||||
import fs from 'fs'
|
import fs from 'fs'
|
||||||
import uuidv4 from 'uuid/v4'
|
import uuidv4 from 'uuid/v4'
|
||||||
import chalk from 'chalk'
|
import chalk from 'chalk'
|
||||||
import autoBind from 'auto-bind2'
|
import autobind from 'autobind-decorator'
|
||||||
|
|
||||||
|
@autobind
|
||||||
class SendMessageTool {
|
class SendMessageTool {
|
||||||
constructor(toolName, log) {
|
constructor(toolName, log) {
|
||||||
autoBind(this)
|
|
||||||
this.toolName = toolName
|
this.toolName = toolName
|
||||||
this.log = log
|
this.log = log
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,18 +2,17 @@ import mongoose from 'mongoose'
|
|||||||
import mongodb from 'mongodb'
|
import mongodb from 'mongodb'
|
||||||
import Grid from 'gridfs-stream'
|
import Grid from 'gridfs-stream'
|
||||||
import merge from 'mongoose-merge-plugin'
|
import merge from 'mongoose-merge-plugin'
|
||||||
import autoBind from 'auto-bind2'
|
import autobind from 'autobind-decorator'
|
||||||
import * as Schemas from './schemas'
|
import * as Schemas from './schemas'
|
||||||
import util from 'util'
|
import util from 'util'
|
||||||
|
|
||||||
Grid.mongo = mongoose.mongo
|
Grid.mongo = mongoose.mongo
|
||||||
|
|
||||||
|
@autobind
|
||||||
export class DB {
|
export class DB {
|
||||||
constructor() {
|
constructor() {
|
||||||
mongoose.Promise = Promise
|
mongoose.Promise = Promise
|
||||||
mongoose.plugin(merge)
|
mongoose.plugin(merge)
|
||||||
|
|
||||||
autoBind(this)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
connect(mongoUri, isProduction) {
|
connect(mongoUri, isProduction) {
|
||||||
|
|||||||
@@ -8,8 +8,9 @@ import appRoot from 'app-root-path'
|
|||||||
import JSON5 from 'json5'
|
import JSON5 from 'json5'
|
||||||
import aws from 'aws-sdk'
|
import aws from 'aws-sdk'
|
||||||
import config from 'config'
|
import config from 'config'
|
||||||
import autoBind from 'auto-bind2'
|
import autobind from 'autobind-decorator'
|
||||||
|
|
||||||
|
@autobind
|
||||||
export class EmailHandlers {
|
export class EmailHandlers {
|
||||||
constructor(container) {
|
constructor(container) {
|
||||||
this.log = container.log
|
this.log = container.log
|
||||||
@@ -35,8 +36,6 @@ export class EmailHandlers {
|
|||||||
html: def.html ? handlebars.compile(fs.readFileSync(def.html).toString()) : null
|
html: def.html ? handlebars.compile(fs.readFileSync(def.html).toString()) : null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
autoBind(this)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sendEmail(options) {
|
sendEmail(options) {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import Canvas from 'canvas'
|
|||||||
import fs from 'fs'
|
import fs from 'fs'
|
||||||
import util from 'util'
|
import util from 'util'
|
||||||
import createError from 'http-errors'
|
import createError from 'http-errors'
|
||||||
import autoBind from 'auto-bind2'
|
import autobind from 'autobind-decorator'
|
||||||
import stream from 'stream'
|
import stream from 'stream'
|
||||||
|
|
||||||
function streamToBuffer(readable) {
|
function streamToBuffer(readable) {
|
||||||
@@ -132,11 +132,11 @@ function normalizeOrientation(image, orientation) {
|
|||||||
return loadImage(canvas.toBuffer())
|
return loadImage(canvas.toBuffer())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@autobind
|
||||||
export class ImageHandlers {
|
export class ImageHandlers {
|
||||||
constructor(container) {
|
constructor(container) {
|
||||||
this.db = container.db
|
this.db = container.db
|
||||||
this.log = container.log
|
this.log = container.log
|
||||||
autoBind(this)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
scaleImage(options) {
|
scaleImage(options) {
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
import amqp from 'amqplib'
|
import amqp from 'amqplib'
|
||||||
import autoBind from 'auto-bind2'
|
import autobind from 'autobind-decorator'
|
||||||
import createError from 'http-errors'
|
import createError from 'http-errors'
|
||||||
|
|
||||||
|
@autobind
|
||||||
export class MS {
|
export class MS {
|
||||||
constructor(exchangeName, options, log) {
|
constructor(exchangeName, options, log) {
|
||||||
this.exchangeName = exchangeName
|
this.exchangeName = exchangeName
|
||||||
this.options = options || {}
|
this.options = options || {}
|
||||||
this.isProduction = (process.env.NODE_ENV === 'production')
|
this.isProduction = (process.env.NODE_ENV === 'production')
|
||||||
this.log = log
|
this.log = log
|
||||||
autoBind(this)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async connect(amqpUri) {
|
async connect(amqpUri) {
|
||||||
|
|||||||
Reference in New Issue
Block a user