用Koa实现一个较完整的登录注册功能需要用到哪些模块

JavaScript017

用Koa实现一个较完整的登录注册功能需要用到哪些模块,第1张

登录注册涉及哪些功能?

基础 mvc 生成页面

处理登录,注册表单

登录状态

用户数据存储

找回密码

对下来要用到的模块:

koajs/ejs · GitHub、alexmingoia/koa-router · GitHub 实现 mvc

koajs/bodyparser · GitHub 用来处理登录注册的 post 上来的 HTTP body 中的数据

expressjs/cookie-parser · GitHubkoajs/session · GitHub cookie 解析以及基于 cookie 的 session 管理,用来保存用户的登录状态,也可以使用 Chilledheart/koa-session-redis · GitHub 来把 session 保存在 redis 中,等等

Automattic/mongoose · GitHub 数据库,保存用户信息

andris9/Nodemailer · GitHub 发邮件

整个应用的文件划分可参考:gusnips/node-koa-mvc · GitHub

app.use(function *(next){

this.body = 'hello'

var ctx = this

yield function (cb) {

fs.createReadStream('./file.txt').on('data', function (s) {

ctx.body += s

}).on('end', function () {

cb()

})

}

this.body += 'world'

})

express

https://github.com/expressjs/express

http://www.yyyweb.com/ctools/demo.php?t=http%3A%2F%2Fexpressjs.com%2F&h=1000&c=&n=expressjs

koa

https://github.com/koajs/koa

http://www.yyyweb.com/ctools/demo.php?t=http%3A%2F%2Fkoajs.com%2F&h=20000&c=&n=koajs

egg(阿里开源的企业级 Node.js 框架,原型koa)

https://github.com/eggjs/egg

sails

https://github.com/balderdashy/sails/

http://www.yyyweb.com/ctools/demo.php?t=http%3A%2F%2Fsailsjs.org%2F%23!%2F&h=3500&c=&n=sailsjs

total

https://github.com/totaljs/framework

http://www.yyyweb.com/ctools/demo.php?t=https%3A%2F%2Fwww.totaljs.com%2F&h=2500&c=&n=totaljs