节点+ plesk + ssl:如何使它们一起运行?

我的客户的网站运行由PLESK生成的ssl。 我以前用SSL运行node.js感谢: var ssl = { key: fs.readFileSync('/etc/letsencrypt/live/mysite.com/privkey.pem'), cert: fs.readFileSync('/etc/letsencrypt/live/mysite/cert.pem') }; 但是我不知道PLESK在哪里创build这两个文件。 我试着用: > /etc/ssl/certs/ssl-cert-snakeoil.pem > /etc/ssl/private/ssl-cert-snakeoil.key 没有成功。 有关如何使用Plesk生成的SSL运行nodej的想法?

ES6dynamic导入和实例化类

我想弄清楚如何执行在ES6一个服务器端(与巴贝尔node.js)类的dynamic导入。 我想要有一些类似于Javareflection的function。 这个想法是导入一个特定的文件夹中的所有类,并dynamic地实例化它们。 所以举例来说,我可以在一个文件夹中声明多个类,如下所示: export default class MyClass { constructor(somevar) { this._somevar = somevar } //… //some more instance level functions here } 然后在我的应用程序的代码中的其他地方,我可以有一个函数,找出特定文件夹中的所有类,并试图instanciate他们: //somewhere else in my app instanciationFunction(){ //find all the classes in a specific folder var classFiles = glob.sync(p + '/path_to_classes/**/*.js', { nodir: true }); _.each(classFiles, async function (file) { console.log(file); var […]

用NodeJS的UUID查询Cassandra

感谢您花时间看我的问题。 我和我的团队刚刚开始涉足NodeJS,这是我们第一次遇到一个问题,至今我们还找不到解决scheme。 简而言之,我们有一个Controller,需要用一个UUID主键来查询Cassandra。 控制器: 'use strict'; const express = require('express'); const models = require('../dbConnection'); const router = express.Router(); var UUID = require('uuid-js'); // Store / create checklist definition. router.post('/', function(req, res) { }); // Show checklist definition. router.get('/:id', function(req, res) { let checklistId = req.params.id; console.log(checklistId); models.instance.ChecklistDefinition.findOne({id: checklistId}, function(err, checklist) { if (err) { console.log(err); […]

aws + serverless + webpack =>在prod中找不到xxx模块

我想创build一个包,使用无服务器和webpack在AWS上进行部署。 在serverless.yml我想声明所有的资源(主要是DynamoDb表)和函数。 我想要使​​用外部的node.js库。 该文件夹结构是: |- serverless.yml |- webpack.config.js |- package.json |- src \ – file1.js | – file2.js 从serverless.yml中提取 functions: function1: handler: src/file1.f1 function2: handler: src/file2.f2 从webpack.congfig.js中提取 module.exports = { entry: { file1: './src/file1.js', file2: './src/file2.js', }, target: 'node', output: { libraryTarget: 'commonjs', path: path.join(__dirname, '.webpack'), filename: '[name].js', }, module: { loaders: [ { test: […]

Bot框架 – 在NodeJS中处理用户发送的图像

我找不到任何方式来处理用户发送到我的机器人的图像。 有什么办法可以获得图像? 我发现这是类似的,但对于C#,我在node.js工作。

angular度为2的节点,当你在url栏中input路由时,会得到404错误

当使用angular度为2的节点时,有奇怪的事情发生,我想修复。 基本上,如果我要在URL中input路由,例如浏览器url栏中的localhost:3000/about 。 我不能得到/家。 但是,当点击导航栏,我有相同的链接/左右。 它工作得很好。 我知道这是一个节点的问题,因为最初,我使用开发服务器这个错误没有发生与angular2。 angular2路线 const routes: Routes = [ { path: '', redirectTo: 'home', pathMatch: 'full' }, { path: 'home', component: HomeComponent}, { path: 'private', component: PrivateComponent}, { path: 'title', component: TitleComponent}, { path: 'shop', component: WelcomeComponent }, { path: 'about', component: AboutComponent }, { path: 'login', component: LoginComponent}, { path: […]

@ types / node和VS代码:因为注释格式化,IntelliSense不起作用

我使用的Visual Studio代码和@ types /节点(7.0.8),但似乎有些function等有一个错误的格式化的代码注释,因此Visual Studio代码和Visual Studio 2017不会显示任何在IntelliSense中的quickinfos。 例 import * as fs from 'fs'; fs.unlink 当我inputfs.unlink VS Code显示函数签名,但不是定义的注释 ./node_modules/@types/node/index.d.ts 在线2400 /* * Asynchronous unlink – deletes the file specified in {path} * * @param path * @param callback No arguments other than a possible exception are given to the completion callback. */ export function unlink(path: […]

在asynchronous函数中访问对象

我是node.js的初学者 所以,我用这个来 var toFix = { 'renault': 'Renault', 'renault ': 'Renault', 'RENAULT ': 'Renault', 'RENAULT': 'Renault', }; async.forEachOfSeries(toFix, function(to, from, cb){ Car.update({make:from }, {$set: {make: to}}, {multi: true},cb) }, done); 它为我的桌上汽车工作。 但是当我想在另一个表中使用相同的代码,汽车是表中的一个对象时,它不起作用,例如: async.forEachOfSeries(toFix, function(to, from, cb){ Ticket.update({car.make:from }, {$set: {car.make: to}}, {multi: true},cb) }, done); 它不能接受car.make。 所以我应该如何访问我的对象? 谢谢

我既不能过滤也不能过滤通过LogStash保存到ElasticSearch的文档

我想这个问题可能与我的logstash.conf有关,但我不知道该怎么做。 我发现很好的教程解释如何使用ElasticSearch,但在我的情况下,所有的数据将通过LogStash来自NodeJs。 我search关于启用fieldData,但我不知道如何在我的logstash.conf中做到这一点。 我应该创build一个索引模板? 如果这样怎么样? 上下文是我想每次用户访问我们的应用程序时logging,然后根据每个月的访问数量logging他/她。 logstash.conf input { tcp { port => 5000 type => cpfTipo } } filter { json { source => "message" } } output { elasticsearch { hosts => ["localhost:9200"] index => "mycostumer_indice" document_type => "cpfTipo"} } 暂定过滤: 1) curl -XGET http://127.0.0.1:9200/mycostumer_indice/cpfTipo/_search -d '{ "query": { "filtered": { "query": { […]

如何解决“TypeError:callback.apply不是一个函数”?

我正在做一个大学项目,我已经阅读了关于我的问题的每一个post,但我还没有find解决办法。 也许你可以帮我。 代码如下: viewerObj.update({_id: currentIDViewerVar} , {minutesWatched: 5},{upsert:true} , function (err,result) { if (err) throw err; console.log("Viewer " + userNameVar + " gespeichert"); console.log("minsWatched" +minsWatched); }); 我得到以下错误。 我看不出我做错了什么。 events.js:160 throw er; // Unhandled 'error' event ^ TypeError: callback.apply is not a function at C:\Users\picco\Desktop\TwitchWatcher_v19\TwitchWatcher\node_modules\mongoose\lib\model.js:3388:16 at Query.callback (C:\Users\picco\Desktop\TwitchWatcher_v19\TwitchWatcher\node_modules\mongoose\lib\query.js:2185:9) at C:\Users\picco\Desktop\TwitchWatcher_v19\TwitchWatcher\node_modules\mongoose\node_modules\kareem\index.js:259:21 at C:\Users\picco\Desktop\TwitchWatcher_v19\TwitchWatcher\node_modules\mongoose\node_modules\kareem\index.js:127:16 at _combinedTickCallback (internal/process/next_tick.js:67:7) at […]