云函数路由
发布于 6 年前 作者 chaoyuan 690 次浏览 来自 问答

npm  tcb-router到云开发本地目录后,怎么将这个同步到云端???

跪求…或,云函数怎么写路由????

1 回复

// 云函数入口文件  

const cloud = require(‘wx-server-sdk’);

const TcbRouter = require(‘tcb-router’);

cloud.init()

const db = cloud.database();

const _ = db.command;

// 云函数入口函数

exports.main = async (event, context) => {

const app = new TcbRouter({ event });

/**

 * 登录

 */

app.router(‘login’, async (ctx, next) => {

await next();

}, async (ctx, next) => {

await next();

}, async (ctx) => {

const login = require(‘login/index.js’);

ctx.body = login.mian(event, context, db, _);

});

return app.serve();

}

安装相关依赖右键上传上去即可

回到顶部