Skip to content
Permalink
Browse files

Minor Changes

  • Loading branch information...
Florian Wendelborn
Florian Wendelborn committed Apr 17, 2017
1 parent 16a0820 commit 01100964853329154f2e3bc63b496ddd2eda76b4
Showing with 2 additions and 15 deletions.
  1. +1 −8 source/api/session.js
  2. +1 −7 source/utilities/modules.js
@@ -1,28 +1,22 @@
// region import

import crypto from 'crypto'
import jwt from 'jsonwebtoken'

// internal

import {provide} from '../utilities/modules'

// endregion

// region crypto

const key = 'secret'
const hashPassword = async ({password, salt}) => new Promise((resolve, reject) =>
const hashPassword = ({password, salt}) => new Promise((resolve, reject) =>
crypto.pbkdf2(password, salt, 64000, 512, 'sha512', (error, hash) => error
? reject(error)
: resolve(hash.toString('base64'))
)
)

// endregion

// region export

export const verify = async (token) =>
jwt.verify(token, key, {
algorithms: ['HS256']
@@ -41,5 +35,4 @@ export const create = async ({name, password}) => {

throw 'wrong password'
}

// endregion
@@ -11,8 +11,7 @@ import api from '../api'

// endregion

// region routes

// region modules
const modules = fs
.readdirSync(`${__dirname}/../../modules`)
.map(name => path.join(`${__dirname}/../../modules`, name))
@@ -21,11 +20,9 @@ const modules = fs
.isDirectory()
)
.map(name => require(`${name}/build/info.js`).default({api}))

// endregion

// region provide & subscribe

export const provide = {}
export const subscribes = {
user: []
@@ -45,11 +42,9 @@ modules.forEach(module => {
provide.user = module.provide.user
}
})

// endregion

// region serve

export default () => modules
.map(({name, routes}) => routes
.map(([method, path, dependencies, handler]) => {
@@ -69,5 +64,4 @@ export default () => modules
})
)
.reduce((a, b) => [...a, ...b], [])

// endregion

0 comments on commit 0110096

Please sign in to comment.
You can’t perform that action at this time.