Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// 云函数入口文件
const cloud = require('wx-server-sdk')
cloud.init()
const db = cloud.database({
env: process.env.DATABASE_ENV_ID
})
const _ = db.command
// 云函数入口函数
exports.main = async (event, context) => {
// 这里获取到的 openId、 appId 和 unionId 是可信的,注意 unionId 仅在满足 unionId 获取条件时返回
let { OPENID, APPID, UNIONID } = cloud.getWXContext()
console.log(event.userDetailInfo)
try{
res = await db.collection('shared_score_results').add({
const cloud = require('wx-server-sdk')
var rp = require('request-promise');
cloud.init()
const db = cloud.database()
const _ = db.command
exports.main = async (event, context) => {
const {OPENID} = cloud.getWXContext()
const {type, openid} = event;
console.log('trigger:', event, context)
// 方糖推送
await pubcontent()
if (type == 'all' && OPENID != 'ooqTr4hMz05xwBHOU8VgokLyyoU0') {
console.log("非法的全局推送 openid: ", OPENID)
return
}
var publist = []
var content = await pubSimpleContent()
var trending = await trendingContent()
// 云函数入口文件
const cloud = require('wx-server-sdk')
cloud.init()
const db = cloud.database()
// 云函数入口函数
exports.main = async (event, context) => {
await db.collection('group').doc(event.groupId).update({
data: {
deleted: true
}
})
}
// 云函数入口文件
const cloud = require('wx-server-sdk')
cloud.init()
const db = cloud.database()
// 云函数入口函数
exports.main = async (event, context) => {
await db.collection('bill').doc(event.billId).update({
data: {
deleted: true
},
success() {
}
})
}
exports.main = async(event, context) => {
let {
OPENID,
APPID,
UNIONID
} = cloud.getWXContext()
const db = cloud.database()
return new Promise(async(resolve, reject) => {
try {
// 获取数据
let {
data
} = await db.collection('user').where({
openid: event.openid || OPENID
}).get()
if(data.length == 0) throw {code: 7402, data: [], info: '用户不存在!'}
resolve({
code: 0,
data,
info: '操作成功!'
})
} catch (error) {
console.log(error)
* @author: eysonyou
* @create: 2019-05-16
*/
// 云函数入口文件
const cloud = require('wx-server-sdk')
cloud.init({
// 1.release - 正式
// 2.test - 测试
// env: 'test'
env: 'release'
});
// 初始化数据库连接
const db = cloud.database();
const _ = db.command;
// 云函数入口函数
exports.main = async(event, context) => {
// 获取微信上下文
const wxContext = cloud.getWXContext();
// 参数
let params = {
// 标题
title: event.title,
// 内容
content: event.content,
// 图片
fileID: event.fileID,
// 场景
// 云函数入口文件
const cloud = require('wx-server-sdk')
cloud.init()
const db = cloud.database()
const _ = db.command
// 云函数入口函数
exports.main = async (event, context) => {
const wxContext = cloud.getWXContext()
var d = new Date()
d.setDate(d.getDate() - 3);
db.collection('history').where({
requesttime: _.lt(d.toISOString()),
}).remove()
await db.collection('gcache').where({
time: _.lt(d.toISOString()),
}).remove()
var d7 = new Date()
// 云函数入口文件
const cloud = require('wx-server-sdk')
cloud.init()
const octokit = require('@octokit/rest')()
const db = cloud.database()
const _ = db.command
db.collection("admin").where({website: "github", type: "token"}).get().then(res => {
octokit.authenticate({
type: 'oauth',
token: res[0].value
})
})
const per_page = 30;
const page = 1;
function dateFtt(fmt, date) { //author: meizz
var o = {
"M+": date.getMonth() + 1, //月份
"d+": date.getDate(), //日
"h+": date.getHours(), //小时
"H+": date.getHours(), //小时
exports.main = async(event, context) => {
let {
OPENID,
APPID,
UNIONID
} = cloud.getWXContext()
const db = cloud.database()
return new Promise(async(resolve, reject) => {
try {
if(!event.formId) throw {code: 7406, data: [], info: 'formId不能为空!'}
let page = event.page || '',
touser = OPENID,
formId = event.formId,
name = event.name,
amount = event.amount,
payAmount = event.payAmount,
templateId = 'xxxxxxx', // 模板id
date = getTime(new Date().getTime() + 28800 * 1000) // 因服务器是格林时间 所以要加8小时
// 发送模板消息
const result = await cloud.openapi.templateMessage.send({
touser,
page,
data: {
exports.main = async(event, context) => {
const db = cloud.database()
return new Promise(async (resolve, reject) => {
try {
if(!event.scene) throw {code: 7400, data: [], info: '场景信息不能为空!'}
// 一维码信息
let scene = event.scene,
page = event.page,
width = event.width || 430,
auto_color = event.auto_color || false,
line_color = event.line_color || {"r":0,"g":0,"b":0},
is_hyaline = event.is_hyaline || false
// 请求微信获取图像
let {
buffer,
errcode,
contentType
} = await cloud.openapi.wxacode.getUnlimited({