我目前正在阅读Adam Freeman撰写的"Pro AngularJS".通过这些示例,他让读者使用Angular(当然)和Deployd服务器资源创建了一个体育商店应用程序.Deployd资源设置为返回要填充到模型中的JSON数据.我正在使用NodeJS来运行我的服务器.它目前在端口5000(http://localhost:5000/sportsstore/app.html
)上设置.Deployd资源在端口5500(http://localhost:5500/products
)上运行.点击Deployd时,响应如下:
[
{ "name": "Kayak", "description": "A boat for one person", "category": "Watersports", "price": 275, "id": "a1c999fc248b2959" },
{ "name": "Lifejacket", "description": "Protective and fashionable", "category": "Watersports", "price": 48.95, "id": "61303717cfad182e" },
{ "name": "Soccer Ball", "description": "FIFA-approved size and weight", "category": "Soccer", "price": 19.5, "id": "0fb5f67bdcbd992f" },
{ "name": "Corner Flags", "description": "Give your playing field a professional touch", "category": "Soccer", "price": 34.95, "id": "24385d315dd388b4" },
{ "name": "Stadium", "description": "Flat-packed 35,000-seat stadium", …
Run Code Online (Sandbox Code Playgroud) 我是 Angular 和 Deployd 的新手,想知道如何一起使用它们。
我发现 Deployd 网站中的示例很好,但它只消耗其余 API 数据,我想了解如何将 Deployd 作为 AngularJS 中的服务。例如,通过部署中可用的收集事件,使所有客户端 API 保持最新的收集最新数据。
我想出了下面的示例,我们可以看到我正在使用 $resource 来使用其余 api,但在控制器“MyCtrl”内,我正在调用 dpd,我想用它来利用功能,例如http://docs.deployd.com/docs/collections/notifying-clients.md
我真的很想看到一些例子,或者对此有任何建议!
感谢您的浏览:)
angular.module('questions', ['ngResource'])
.factory('Deployd', function(dpd){
return dpd;
})
.factory('EntriesService', function($resource){
return $resource('/entries', {});
})
.controller('MainCtrl', ['$scope', 'EntriesService', function($scope, EntriesService) {
$scope.title = "Q&A Module";
$scope.entries = [];
EntriesService.query(function(response){
$scope.entries = response;
});
$scope.addMessage = function() {
$scope.entries.push({
author: "myAuthor",
message: $scope.message
});
EntriesService.save({
author: "myAuthor",
message: $scope.message
});
};
dpd.comments.get(function(comments, error) {
comments.forEach(function(comment) {
console.log(comment);
});
}); …
Run Code Online (Sandbox Code Playgroud) 首先让我说我真的很喜欢Deployd.我想在生产中使用它,但我想要合并OAuth和社交登录,所以我安装了dpd-passport模块.除了两个小(大)问题外,它的效果很好:
/users
如果他们知道用户的socialAccount和socialAccountId,则向端点发出POST请求.我的问题是:IA如何防止#1发生,或者B)禁用用户创建的标准方法而不阻止OAuth用户创建?
有没有人成功使用过Deployd
并dpd-passport
在生产中?如果是的话,我想跟你说话......
提前致谢!
我正在使用Deployd构建一个项目来帮助我的API,并使用dpd-passport进行身份验证.
我似乎已经对所有内容进行了身份验证,后面分发了会话密钥并通过Google进行了用户身份验证,但是我遇到了问题redirectURL
,并且翻译了我返回的回调页面.
我已经挖掘了dpd-passport/index.js
文件,我相信这是相关的信息:
var sendResponse = function(ctx, err, config) {
var sessionData = ctx.session.data;
var returnUrl = (ctx.req.cookies && ctx.req.cookies.get('_passportReturnUrl')) || null;
if(returnUrl) {
var redirectURL = url.parse(returnUrl, true);
// only append if not disabled
if(!config.disableReturnParams) {
// delete search so that query is used
delete redirectURL.search;
// make sure query is inited
redirectURL.query = redirectURL.query || {};
if(err) {
redirectURL.query.success = false;
redirectURL.query.error = err;
} else {
// append user + session id to …
Run Code Online (Sandbox Code Playgroud) 我有一个Deployd应用程序,我试图部署到Heroku.我已成功部署该应用程序,并能够通过它的url命中它.我现在正试图访问仪表板.为了访问仪表板,它需要我从服务器生成密钥.我知道有两种方法可以做到这一点.
这里描述的第一种方法在本地生成密钥并将其推送到heroku.我觉得这种方法在将密钥发布到VCS的意义上是不安全的.
第二种方法是使用Procfile和list dpd keygen
和dpd showkey
.但由于某种原因,这种方法对我不起作用.我看到命令在heroku日志中执行但它没有打印出键,我无法通过执行看到它heroku run dpd showkey
.
我想弄清楚为什么列出我的procfile中的命令不起作用.请在下面找到我的文件:
web: node app.js
cmd: dpd keygen
cmd: dpd showkey
Run Code Online (Sandbox Code Playgroud)
我的日志文件如下:
2015-08-30T19:18:25.012474+00:00 heroku[api]: Starting process with command `dpd showkey` by [email]
2015-08-30T19:18:28.196008+00:00 heroku[run.5122]: Starting process with command `dpd showkey`
2015-08-30T19:18:28.168161+00:00 heroku[run.5122]: Awaiting client
2015-08-30T19:18:28.501367+00:00 heroku[run.5122]: State changed from starting to up
2015-08-30T19:18:31.023033+00:00 heroku[run.5122]: State changed from up to complete
2015-08-30T19:18:31.012416+00:00 heroku[run.5122]: Process exited with status 0
2015-08-30T19:19:36.935285+00:00 …
Run Code Online (Sandbox Code Playgroud) 不知道我在这里缺少什么.
我需要的输出data
入this.contact
.现在,我正在使用一个静态类变量,但它似乎很脏,必须这样做.
export class contactEdit {
static t; // static class var
constructor() {
this.id = null;
this.contact = null;
contactEdit.t = this;
}
activate(id) {
this.id = id;
let contact = this.contact; // scoped version of class var
return dpd.contacts.get(id).then(function(data) {
console.log(data);
contactEdit.t.contact = data; // this works
contact = data; // this doesn't
});
}
}
Run Code Online (Sandbox Code Playgroud)
通常我会var contact
在activate()
函数内部创建一个(它在Chrome控制台中工作),但这似乎不适用于ES6.
Chrome控制台:
var c = null;
undefined
c;
null
dpd.contacts.get('a415fdc8f5a7184d').then(function(data) {
c = …
Run Code Online (Sandbox Code Playgroud) 我认为标题几乎都说明了......对于Deployd来说是全新的,所以任何关于如何最好地解决这个问题的指针都会受到赞赏.
我有一些npm包的各种权限和路径问题,这次是deployd的dpd二进制文件.然而,它似乎仍然与我偶尔收到的任何其他熟悉的令人沮丧的npm路径问题有关.考虑到我经常使用-g而不是在安装npm包时,它似乎非常熟悉npm的用法.
到目前为止,为了解决这个问题,我尝试了多次从用户和全局重新安装deployd和mongodb,我甚至重新安装了npm.我在运行dpd时获得一致的包错误.我发现很多相关的,但没有一个有效.这是今天运行dpd时的问题.任何宏伟的建议?
当从linux运行时,以下$ dpd启动deployd v0.8.4 ...无法启动MongoDB(确保'mongod'在$ PATH中或使用dpd --modod选项.参考:http://docs.deployd. com/docs/basics/cli.html)再见
$ sudo dpd
starting deployd v0.8.4...
Failed to start MongoDB (Make sure 'mongod' are in your $PATH or use dpd --mongod option. Ref: http://docs.deployd.com/docs/basics/cli.html)
bye
$ dpd --mongod ./.dpd/pids
starting deployd v0.8.4...
child_process.js:1162
throw errnoException(err, 'spawn');
^
Error: spawn EACCES
at exports._errnoException (util.js:746:11)
at ChildProcess.spawn (child_process.js:1162:11)
at exports.spawn (child_process.js:995:9)
at Object.exports.restart (/usr/bin/node_modules/bin/lib/node_modules/deployd/lib/util/mongod.js:38:14)
at start (/usr/bin/node_modules/bin/lib/node_modules/deployd/bin/dpd:149:16)
at Object.<anonymous> (/usr/bin/node_modules/bin/lib/node_modules/deployd/bin/dpd:280:31)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load …
Run Code Online (Sandbox Code Playgroud) 我们在后端 nodejs 应用程序中运行了把手,用于对发送的各种消息进行模板化。
Error: You must pass a string or Handlebars AST to Handlebars.compile. You passed <html>
<head>
... extremely long markup
at Object.compile (/Users/guscrawford/rollick-management-console/deployd/node_modules/handlebars/dist/cjs/handlebars/compiler/compiler.js:501:11)
at HandlebarsEnvironment.hb.compile (/Users/guscrawford/rollick-management-console/deployd/node_modules/handlebars/dist/cjs/handlebars.js:39:40)
at Object.invokePartialWrapper [as invokePartial] (/Users/guscrawford/rollick-management-console/deployd/node_modules/handlebars/dist/cjs/handlebars/runtime.js:71:44)
... additional stack trace through to dpd, bluebird etc.
Run Code Online (Sandbox Code Playgroud)
继续尝试建立一个废品项目:
yarn add handlebars handlebars-helper-ternary handlebars-helpers handlebars.numeral
然后在 nodejs 中运行这个脚本:
const handlebars = require('handlebars'),
numeralHelper = require('handlebars.numeral'),
ternaryHelper = require('handlebars-helper-ternary'),
helpers = require('handlebars-helpers')({
handlebars: handlebars
});
console.log(`Testing...`);
const base = `
<html>
<body style="font-family:'Segoe …
Run Code Online (Sandbox Code Playgroud) deployd ×10
javascript ×5
node.js ×4
angularjs ×3
passport.js ×2
aurelia ×1
cors ×1
ecmascript-6 ×1
express ×1
heroku ×1
mongodb ×1
npm ×1
oauth ×1
procfile ×1
promise ×1