jsdoc和vscode:logging作为parameter passing给另一个函数的函数

我试图在JavaScript中logginginput参数的函数,但我不能解决如何在jsdoc中做到这一点。 我查看了jsdoc文档,它build议使用@callback注释是必需的,但Visual Studio代码(vscode)不会像截图一样突出显示它。 location参数的intellisense显示它是typesany而不是typeslocator (带有返回Location的id参数的函数)。 显示调用函数的函数的示例代码作为parameter passing: class Location { constructor(position, count) { this.position = position; this.count = count; } } const items = { 'USB Cable': new Location('Desk Drawer', 123), Keyboard: new Location('Desk Surface', 1), }; /** * A locater. * @param {string} id * @returns {Location} */ const locaterA = id => items[id]; […]

当`session`对象不可用时,在Bot框架中读/写bot用户数据

我想将一个简单的键值对存储在由微软的Bot Framework提供的bot用户数据存储器中。 通常很容易: session.userData.key = value; 但是,当session对象不可用时,我想在处理所有传入消息的事件处理程序中执行此操作: bot.on('incoming', incoming => { // Check whether user asked to switch on debug mode. if (incoming.text === 'debug on') { console.log('Enabling debug mode.'); // TODO FIXME – we need to save the result to bot memory. } }); 有没有其他的方式来保存从主app.js文件或从事件处理程序机器人内存?

我无法find与MySQL代码的错误

我是新手。 我无法从前端插入数据到MySQL数据库。 我在插入时遇到问题。 我的index.js代码 我将表单详细信息存储在一个variables中,并试图将其插入到数据库中 router.post('/signup',function(req,res,next) { var item = req.body; connection.connect(function(err){ var sql = "INSERT INTO details VALUES ? "; connection.query(sql,[item]); }); res.render('data' ,{items:item}); }); 错误信息 /home/gayathri/jsonhbs/node_modules/mysql/lib/protocol/Parser.js:80 throw err; // Rethrow non-MySQL errors ^ Error: ER_PARSE_ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version […]

节点请求如何处理会话

我使用node.JS和请求模块。 我的问题是,我需要对每个请求进行身份validation,因为会话在.then((response) => {})块之外被销毁。 如何将创build的会话保存在一个类中供以后使用? 我尝试了一切都没有成功。 这是一个不工作的代码片段 login() { const getLoginUrl = 'https://www.demourl.com/' const postLoginUrl = 'https://www.demourl.com/account/login/' rp({ url: getLoginUrl, jar: this.cookieJar, method: 'GET' }) .then((body) => { var csrftoken = this.cookieJar.getCookies(getLoginUrl)[1].toString().split('=')[1].split(';')[0]; var args = { url: postLoginUrl, json: true, method: 'POST', data: { username: this.username, password: this.password }, headers: { 'method': 'POST', 'path': '/account/login/', […]

如何在IBMi / AS400上安装MeteorJS

我想知道是否有可能安装MeteorJS AS400(IBMi),因为它能够运行Node.js,MongoDB,… 我通过“curl”快速testing了安装,但是我有一个消息说这个平台不受支持。 有人会通过NPM软件包进行testing吗? 在那里我有一个疑问:是JS中的所有meteor代码,还是有一个二进制层,使它不可能?

如何在模块Aimport模块B的地方开发两个angular模块

当在angularjs中开发两个本地项目(其中一个导入另一个)时,我只需要在模块B的文件夹中运行“npm link”,然后在主模块文件夹中运行“npm link module-B”,并且每当我更改模块BI会直接在我的浏览器服务模块A中看到它 但是angular度(4)似乎并不那么容易。 我使用ng-packagr来生成dist文件夹。 我在dist文件夹下运行npm链接。 我在主模块的文件夹中运行npm link module-B。 然后运行ng serve –preserve-symlinks。 到目前为止,它可以理解模块B的组件。但是,如果我尝试改变模块B中的东西,重新运行ng-packagr,我的主模块的“ng服务”不能编译,我必须停止并启动ng服务。 我认为,ng-packagr首先删除dist文件夹,这会触发在ng服务器中重build失败,并且不会注意到删除dist文件夹后新创build的文件。 我们是否需要使用ng-packagr或者是否有其他方式来进行多项目本地开发。 更新 : 如果我们在ng-packagr.js中注释掉这个部分,只要文件被改变并运行ngpackagr就不会删除文件夹和浏览器更新: return Promise.all([ /*rimraf_1.rimraf(p.dest),*/ rimraf_1.rimraf(p.workingDirectory) ]); 但是运行ng-packagr需要一些时间,具体取决于库的大小。 由于它构build了整个事情,而不仅仅是文件的变化。

mongoose – MissingSchema错误的人口

我有两个mongoose模型: 1-事件模型: eventSchema = new mongoose.Schema({ name: { type: String, required: true, }, location: { type: { type: String, default: 'Point', required: true }, coordinates: { type: [Number], required: true }, }, sport: { type: mongoose.Schema.Types.ObjectId, ref: 'Sport', required: true, }, startDate: { type: Date, required: true, }, description: { type: String, required: true, }, […]

从应用程序更新vcap env

有没有办法在比较更新vcap env port服务的代码从我的应用程序,可以说我想改变port为12345 eg { "VCAP_SERVICES": { "mongodb": [ { "credentials": { "dbname": "ztmvvvmtrz", "hostname": "13.15.241.29", "password": "abzArl7AsssseKpi", "port": "22241", 而尝试cf set-env其更新user provided env ,并不能够帮助… java / node.js上的一些例子将伟大

如何在Cloud Functions Firestore中处理读写操作

我有点困惑如何重构我的代码读取和写入没有嵌套的承诺。 在写入对象时,如果该对象有一个标志设置,我想用新的计数来更新它的“相关”对象。 我有两个问题。 1)嵌套承诺从读取然后写入。 2)我应该回来什么 exports.updateRelationshipCounts = functions.firestore .document('masterProduct/{nfCode}').onWrite((event) => { //on writing of record: var newProduct = event.data.data(); if (newProduct.isGlutenFreeYN === 'Y') { console.log('Gluten Free'); //Update GF count in the Brand Object: var db = admin.firestore(); var docRef = db.collection("masterBrand").doc(newProduct.brandNFCode); var doc = docRef.get() .then(doc => { doc.glutenFreeCount = doc.glutenFreeCount + 1 docRef.set(newProduct.brand) .then(function […]

如何捕获http.get上的错误

我有一些看起来像这样的http.get代码 http.get(url, function (response) { var data = ''; response.on('data', function (x) { data += x; }); response.on('end', function () { var json = JSON.parse(data); console.log(json); }); }); 如果提供了无效的URL / API端点,如何处理此错误?