小编Dee*_*arg的帖子

用于Node js中的配置的JS vs JSON

我应该用什么配置?

像KrakenJS这样的模块通过JSON和博客https://blog.risingstack.com/node-js-best-practices-part-2/高度支持配置,说JS应该优于JSON.

你能告诉我他们的不同之处以及管理它们的最佳方法是什么?

javascript node.js

11
推荐指数
1
解决办法
1787
查看次数

如何使用正则表达式提取json字段?

初学者RegExp问题.我在文本文件中有JSON行,每个都有稍微不同的Fields,但如果有的话,我想为每行提取3个字段,忽略其他所有字段.我如何使用正则表达式(在编辑板或其他任何地方)执行此操作?

例:

"url":"http://www.netcharles.com/orwell/essays.htm",
"domain":"netcharles.com",
"title":"Orwell Essays & Journalism Section - Charles' George Orwell Links",
"tags":["orwell","writing","literature","journalism","essays","politics","essay","reference","language","toread"],
"index":2931,
"time_created":1345419323,
"num_saves":24
Run Code Online (Sandbox Code Playgroud)

我想提取URL,TITLE,TAGS,

regex text json replace editpad

6
推荐指数
3
解决办法
6万
查看次数

将 Passport.authenticate 包装在函数内不起作用

我正在尝试使用 Google OAuth2Strategy 对用户进行身份验证。我有以下路线

**server.get('/user/google', passport.authenticate('google', {scope: ['openid email profile']});
server.get('/user/google/callback', authenticate.authenticateGoogleCallback);** 
Run Code Online (Sandbox Code Playgroud)

这完全没问题。但是当我像我对回调所做的那样包装第一个身份验证时,它只是挂起。这是一个错误还是我做错了什么?

这就是我正在尝试的。

**server.get('/user/google', authenticate.authenticateGoogle); // NOT WORKING
server.get('/user/google', function(req,res,next){ // NOT WORKING
     passport.authenticate('google', {scope: ['openid email profile']});
});**
Run Code Online (Sandbox Code Playgroud)

node.js passport.js

2
推荐指数
1
解决办法
1967
查看次数

标签 统计

node.js ×2

editpad ×1

javascript ×1

json ×1

passport.js ×1

regex ×1

replace ×1

text ×1