更新依赖
parent
3d7963e6f5
commit
b772d40fd8
41
index.js
41
index.js
|
@ -6,31 +6,30 @@
|
|||
*/
|
||||
|
||||
import 'es.shim' // 加载拓展方法
|
||||
import init from './lib/reg-init'
|
||||
import init from './lib/reg-init.js'
|
||||
|
||||
import http from 'http'
|
||||
import path from 'path'
|
||||
import Request from 'http.request'
|
||||
import Response from 'http.response'
|
||||
import Request from '../request/index.js'
|
||||
import Response from '../response/index.js'
|
||||
|
||||
import Smarty from 'smartyx' //模板引擎
|
||||
import Log from './lib/module/log' //基础日志记录工具
|
||||
import Email from './lib/module/sendmail' //加载email发送类
|
||||
// import Smarty from 'smartyx' //模板引擎
|
||||
import Log from './module/log.js' //基础日志记录工具
|
||||
import Email from './module/sendmail.js' //加载email发送类
|
||||
import Mysql from 'mysqli' //加载mysql操作类
|
||||
import Ioredis from 'ioredis'
|
||||
|
||||
import sec from 'crypto.js'
|
||||
import path from 'path'
|
||||
import url from 'url'
|
||||
import fs from 'iofs'
|
||||
import child from 'child_process'
|
||||
|
||||
import Controller from './lib/controller'
|
||||
import Controller from './lib/controller.js'
|
||||
|
||||
import routerWare from './lib/middleware/router'
|
||||
import cookieWare from './lib/middleware/cookie'
|
||||
import sessionWare from './lib/middleware/session'
|
||||
import credentialsWare from './lib/middleware/credentials'
|
||||
import routerWare from './middleware/router.js'
|
||||
import cookieWare from './middleware/cookie.js'
|
||||
import sessionWare from './middleware/session.js'
|
||||
import credentialsWare from './middleware/credentials.js'
|
||||
|
||||
var log = console.log
|
||||
|
||||
|
@ -49,22 +48,6 @@ export default class Five {
|
|||
hideProperty(this, '__MODULES__', { __error__: null })
|
||||
hideProperty(this, '__MIDDLEWARE__', [])
|
||||
hideProperty(this, '__INSTANCE__', {})
|
||||
|
||||
global.libs = {
|
||||
Smarty, //模板引擎
|
||||
Log, //基础日志记录工具
|
||||
Email, //加载email发送类
|
||||
Mysql, //加载mysql操作类
|
||||
Ioredis
|
||||
}
|
||||
global.Util = {
|
||||
sec,
|
||||
path,
|
||||
url,
|
||||
fs,
|
||||
child
|
||||
}
|
||||
global.Controller = Controller
|
||||
}
|
||||
|
||||
__init__() {
|
||||
|
@ -147,7 +130,7 @@ export default class Five {
|
|||
}
|
||||
// 预加载应用
|
||||
preload(dir) {
|
||||
var list = Util.fs.ls(dir)
|
||||
var list = fs.ls(dir)
|
||||
|
||||
if (list) {
|
||||
list.forEach(file => {
|
||||
|
|
|
@ -5,10 +5,11 @@
|
|||
*
|
||||
*/
|
||||
|
||||
'use strict'
|
||||
import Smarty from 'smartyx' //模板引擎
|
||||
|
||||
const smarty = new libs.Smarty()
|
||||
const jwt = require('./module/jwt')
|
||||
import { sign, verify } from '../module/jwt.js'
|
||||
|
||||
const smarty = new Smarty()
|
||||
|
||||
export default class Controller {
|
||||
constructor({ ctx, req, res }) {
|
||||
|
@ -18,8 +19,8 @@ export default class Controller {
|
|||
this.response = res
|
||||
|
||||
this.jwt = {
|
||||
sign: jwt.sign.bind(this),
|
||||
result: jwt.verify.call(this)
|
||||
sign: sign.bind(this),
|
||||
result: verify.call(this)
|
||||
}
|
||||
|
||||
smarty.config('path', this.ctx.get('VIEWS'))
|
||||
|
|
|
@ -1,53 +0,0 @@
|
|||
/**
|
||||
* 路由
|
||||
* @authors yutent (yutent@doui.cc)
|
||||
* @date 2015-10-01 19:11:19
|
||||
*
|
||||
*/
|
||||
'use strict'
|
||||
|
||||
export default function(req, res, next) {
|
||||
if (!this.__MODULES__[req.app]) {
|
||||
if (!this.__MODULES__.__error__) {
|
||||
res.error(`The app [${req.app}] not found`, 404)
|
||||
} else {
|
||||
res.error(
|
||||
this.get('debug')
|
||||
? this.__MODULES__.__error__.stack
|
||||
: this.__MODULES__.__error__,
|
||||
500
|
||||
)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
if (req.path.length < 1) {
|
||||
req.path.push('index')
|
||||
}
|
||||
|
||||
var app = new this.__MODULES__[req.app]({ ctx: this, req, res })
|
||||
|
||||
if (this.get('routeMode') === 1) {
|
||||
var act = req.path.shift()
|
||||
|
||||
if (app[act + 'Action']) {
|
||||
app[act + 'Action'].apply(app, req.path).catch(err => {
|
||||
res.error(this.get('debug') ? err.stack || err : err, 500)
|
||||
})
|
||||
} else {
|
||||
res.error(`Action[${act}] not found`, 404)
|
||||
}
|
||||
} else {
|
||||
if (app.indexAction) {
|
||||
app.indexAction.apply(app, req.path).catch(err => {
|
||||
res.error(this.get('debug') ? err.stack || err : err, 500)
|
||||
})
|
||||
} else {
|
||||
res.error(`Default Action not found`, 404)
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
res.error(this.get('debug') ? err.stack || err : err, 500)
|
||||
}
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
/**
|
||||
* 路由
|
||||
* @authors yutent (yutent@doui.cc)
|
||||
* @date 2015-10-01 19:11:19
|
||||
*
|
||||
*/
|
||||
'use strict'
|
||||
|
||||
export default function(req, res, next) {
|
||||
if (!this.__MODULES__[req.app]) {
|
||||
if (!this.__MODULES__.__error__) {
|
||||
res.error(`The app [${req.app}] not found`, 404)
|
||||
} else {
|
||||
res.error(
|
||||
this.get('debug')
|
||||
? this.__MODULES__.__error__.stack
|
||||
: this.__MODULES__.__error__,
|
||||
500
|
||||
)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
if (req.path.length < 1) {
|
||||
req.path.push('index')
|
||||
}
|
||||
|
||||
this.__MODULES__[req.app].then(Mod => {
|
||||
var app = new Mod({ ctx: this, req, res })
|
||||
|
||||
if (this.get('routeMode') === 1) {
|
||||
var act = req.path.shift()
|
||||
|
||||
if (app[act + 'Action']) {
|
||||
app[act + 'Action'].apply(app, req.path).catch(err => {
|
||||
res.error(this.get('debug') ? err.stack || err : err, 500)
|
||||
})
|
||||
} else {
|
||||
res.error(`Action[${act}] not found`, 404)
|
||||
}
|
||||
} else {
|
||||
if (app.indexAction) {
|
||||
app.indexAction.apply(app, req.path).catch(err => {
|
||||
res.error(this.get('debug') ? err.stack || err : err, 500)
|
||||
})
|
||||
} else {
|
||||
res.error(`Default Action not found`, 404)
|
||||
}
|
||||
}
|
||||
})
|
||||
} catch (err) {
|
||||
res.error(this.get('debug') ? err.stack || err : err, 500)
|
||||
}
|
||||
}
|
|
@ -4,8 +4,8 @@
|
|||
* @date 2018-07-26 15:50:25
|
||||
* @version $Id$
|
||||
*/
|
||||
import redisStore from '../module/redis-store'
|
||||
import nativeStore from '../module/native-store'
|
||||
import redisStore from '../module/redis-store.js'
|
||||
import nativeStore from '../module/native-store.js'
|
||||
|
||||
export default function(req, res, next) {
|
||||
var opt = this.get('session')
|
|
@ -6,7 +6,8 @@
|
|||
*/
|
||||
'use strict'
|
||||
|
||||
const mailx = require('mailx')
|
||||
import mailx from 'mailx'
|
||||
|
||||
export default class Sendmail {
|
||||
constructor({ host, port, mail, passwd } = {}) {
|
||||
if (!host || !port || !mail || !passwd) {
|
11
package.json
11
package.json
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"name": "node-five",
|
||||
"name": "@gm5/core",
|
||||
"version": "3.2.6",
|
||||
"type": "module",
|
||||
"description": "Five.js, 一个轻量级的nodejs mvc框架 旨在简单易用, 5分钟即可上手",
|
||||
|
@ -10,12 +10,11 @@
|
|||
"@bytedo/es.shim": "^1.0.0",
|
||||
"iofs": "^1.3.2",
|
||||
"mysqli": "^3.0.11",
|
||||
"http.request": "^1.1.0",
|
||||
"http.response": "^1.0.2",
|
||||
"http.cookie": "^1.0.2",
|
||||
"@gm5/request": "^1.0.0",
|
||||
"@gm5/response": "^1.0.0",
|
||||
"@gm5/cookie": "^1.0.0",
|
||||
"smartyx": "^1.3.1",
|
||||
"ioredis": "^3.2.2",
|
||||
"mailx": "^0.0.11"
|
||||
"ioredis": "^3.2.2"
|
||||
},
|
||||
"devDependencies": {},
|
||||
"repository": {
|
||||
|
|
Loading…
Reference in New Issue