diff --git a/lib/controller.js b/lib/controller.js index 5544fad..f12b372 100644 --- a/lib/controller.js +++ b/lib/controller.js @@ -10,7 +10,7 @@ const smarty = new libs.Smarty() const jwt = require('./module/jwt') -class Controller { +export default class Controller { constructor({ ctx, req, res }) { this.ctx = ctx this.name = req.app @@ -75,5 +75,3 @@ class Controller { this.response.append('X-debug', msg + '') } } - -module.exports = Controller diff --git a/lib/middleware/cookie.js b/lib/middleware/cookie.js index b2339c2..34a8cda 100644 --- a/lib/middleware/cookie.js +++ b/lib/middleware/cookie.js @@ -5,9 +5,9 @@ * @version $Id$ */ -const Cookie = require('http.cookie') +import Cookie from 'http.cookie' -module.exports = function(req, res, next) { +export default function(req, res, next) { var cookie = new Cookie(req.origin.req, req.origin.res) var domain = this.get('domain') this.__INSTANCE__.cookie = function(key, val, opt) { diff --git a/lib/middleware/credentials.js b/lib/middleware/credentials.js index 06eb369..6bf578c 100644 --- a/lib/middleware/credentials.js +++ b/lib/middleware/credentials.js @@ -6,7 +6,7 @@ 'use strict' -module.exports = function(req, res, next) { +export default function(req, res, next) { var supportCredentials = this.get('supportCredentials') var credentialsRule = this.get('credentialsRule') var credentialsMaxAge = this.get('credentialsMaxAge') diff --git a/lib/middleware/router.js b/lib/middleware/router.js index e09e083..1ead7ae 100644 --- a/lib/middleware/router.js +++ b/lib/middleware/router.js @@ -6,7 +6,7 @@ */ 'use strict' -module.exports = function(req, res, next) { +export default function(req, res, next) { if (!this.__MODULES__[req.app]) { if (!this.__MODULES__.__error__) { res.error(`The app [${req.app}] not found`, 404) diff --git a/lib/middleware/session.js b/lib/middleware/session.js index e25467b..22d6fdf 100644 --- a/lib/middleware/session.js +++ b/lib/middleware/session.js @@ -4,10 +4,10 @@ * @date 2018-07-26 15:50:25 * @version $Id$ */ -const redisStore = require('../module/redis-store') -const nativeStore = require('../module/native-store') +import redisStore from '../module/redis-store' +import nativeStore from '../module/native-store' -module.exports = function(req, res, next) { +export default function(req, res, next) { var opt = this.get('session') var jwt = this.get('jwt') var cookie = this.ins('cookie') diff --git a/lib/module/jwt.js b/lib/module/jwt.js index 64bc0c5..e5a8793 100644 --- a/lib/module/jwt.js +++ b/lib/module/jwt.js @@ -15,7 +15,7 @@ const sha256 = (str, secret) => { .replace(/=/g, '') } -const sign = function(token) { +export const sign = function(token) { // "{"typ":"JWT","alg":"HS256"}" // 这里固定使用sha256 var header = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9' @@ -31,7 +31,7 @@ const sign = function(token) { return `${header}.${payload}.${auth}` } -const verify = function() { +export const verify = function() { var jwt = this.request.header('authorization') || '' var secret = this.ctx.get('jwt') var auth, token, payload @@ -56,8 +56,3 @@ const verify = function() { } return false } - -module.exports = { - verify, - sign -} diff --git a/lib/module/log.js b/lib/module/log.js index baa92f0..98d5267 100644 --- a/lib/module/log.js +++ b/lib/module/log.js @@ -6,7 +6,7 @@ */ 'use strict' -class Log { +export default class Log { constructor(file = 'run_time.log', dir) { if (!dir) { throw new Error(`agument dir must be a string, but ${typeof dir} given.`) @@ -44,5 +44,3 @@ class Log { ) } } - -module.exports = Log diff --git a/lib/module/native-store.js b/lib/module/native-store.js index 09bd956..0a59f73 100644 --- a/lib/module/native-store.js +++ b/lib/module/native-store.js @@ -15,7 +15,7 @@ function hideProperty(host, name, value) { }) } -class Session { +export default class Session { constructor(store, opt, uuid) { this.opt = opt this.uuid = uuid @@ -79,5 +79,3 @@ class Session { this.store[this.ssid] = {} } } - -module.exports = Session diff --git a/lib/module/redis-store.js b/lib/module/redis-store.js index 1578697..d9cd12c 100644 --- a/lib/module/redis-store.js +++ b/lib/module/redis-store.js @@ -6,7 +6,7 @@ */ 'use strict' -class Session { +export default class Session { constructor(store, opt, uuid) { this.store = store this.opt = opt @@ -79,5 +79,3 @@ class Session { this.store.del(this.ssid) } } - -module.exports = Session diff --git a/lib/module/sendmail.js b/lib/module/sendmail.js index 818cda3..b851e3c 100644 --- a/lib/module/sendmail.js +++ b/lib/module/sendmail.js @@ -7,7 +7,7 @@ 'use strict' const mailx = require('mailx') -class Sendmail { +export default class Sendmail { constructor({ host, port, mail, passwd } = {}) { if (!host || !port || !mail || !passwd) { throw new Error('smtp options [host, port, mail, passwd] is required.') @@ -44,5 +44,3 @@ class Sendmail { return defer.promise } } - -module.exports = Sendmail diff --git a/lib/reg-init.js b/lib/reg-init.js index 38419e1..d29b017 100644 --- a/lib/reg-init.js +++ b/lib/reg-init.js @@ -7,7 +7,7 @@ 'use strict' -const init = { +export default { db: {}, session: { type: 'native', // native 或 redis @@ -48,5 +48,3 @@ const init = { qq: /^\d{5,12}$/ } } - -module.exports = init diff --git a/package.json b/package.json index 665f40d..ae54601 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "main": "index.js", "dependencies": { "crypto.js": "^1.3.1", - "es.shim": "^1.1.2", + "@bytedo/es.shim": "^1.0.0", "iofs": "^1.3.2", "mysqli": "^3.0.11", "http.request": "^1.1.0", @@ -20,11 +20,11 @@ "devDependencies": {}, "repository": { "type": "git", - "url": "https://github.com/yutent/five.git" + "url": "https://github.com/bytedo/gmf.core.git" }, "keywords": ["five, fivejs, node-five, five.js, nodejs, mvc, koa, express"], "engines": { - "node": ">=8.0.0" + "node": ">=10.0.0" }, "license": "MIT" }