Giter Club home page Giter Club logo

qs-unicloud-account's Introduction

qs-unicloud-account

qs-accountuniCloud开发者提供了简单、统一、可扩展的账户模块云函数类插件,支持阿里云、腾讯云。

qs-account作为云函数公用模块,封装了用户注册、登录、Token 校验、修改密码、设置头像等常见用户管理功能,以 API 方式调用,开发者将qs-account作为公用模块导入后,可在云函数中便捷调用。

对于qs-account还未封装的能力,欢迎大家在开源项目上提交 pr,共同完善这个开源项目。

打包

执行以下命令:

npm install
npm run lint
npm run build

使用方式

创建公用模块

  1. cloudfunctions目录下创建common目录
  2. common目录右键创建公用模块目录(本例中为qs-account),会自动创建入口index.js文件和package.json,不要修改此package.jsonname字段
  3. qs-account右键上传公用模块

引入公用模块

  1. 在要引入公用模块的云函数目录(本例中为account)执行npm init -y生成package.json文件
  2. account目录执行npm install ../common/qs-account引入qs-account模块
  3. 在云函数中调用,示例代码:
'use strict';

const qsAccount = require('qs-account')

exports.main = async (event, context) => {
	//event为客户端上传的参数
	console.log('event : ' + event)

	// 操作
	let action = event.action
	// 参数
	let params = event.params
	// 返回
	let res = {}

	switch (action) {
		case 'login-pwd':
			res = await qsAccount.loginByPwd(params);
			break;
		case 'login-sms':
			res = await qsAccount.loginBySms(params);
			break;
		case 'register-email':
			res = await qsAccount.registerByEmail(params);
			break;
		case 'register-mobile':
			res = await qsAccount.registerByMobile(params);
			break;
		default:
			res = {
				code: 403,
				msg: '非法访问'
			}
			break;
	}

	// 返回数据给客户端
	return res
};

qs-unicloud-account's People

Contributors

qingsongyoudao avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.