小编AFM*_*les的帖子

Firebase 应用初始化失败,凭证无效(firebase 函数初始化)

根据文档

如果您在 Cloud Function 中使用 Node.js Admin SDK,则可以通过 functions.config() 变量自动初始化 SDK:

admin.initializeApp(functions.config().firebase);
Run Code Online (Sandbox Code Playgroud)

但是当我尝试这段非常简单的代码时:

const functions = require('firebase-functions')
const admin = require('firebase-admin')

admin.initializeApp(functions.config().firebase)

exports.orhub = functions.https.onRequest((req, res) => {
    res.end()
})
Run Code Online (Sandbox Code Playgroud)

我收到以下错误:

error: FIREBASE WARNING: {"code":"app/invalid-credential","message":"Credential implementation provided to initializeApp() via the \"credential\" property failed to fetch a valid Google OAuth2 access token with the following error: \"Error fetching access token: invalid_grant (Bad Request)\". There are two likely causes: (1) your server time is not properly synced or (2) …
Run Code Online (Sandbox Code Playgroud)

node.js firebase

7
推荐指数
2
解决办法
8586
查看次数

无法定义标签长度 - ZPL(RW 220)

研究员,

我想做的事情应该很简单:从ZPL II编程指南中打印一个示例标签.但无论我写什么,标签总是印有40毫米长.

这是代码:

^XA
^LH0,30
^FO20,10^AD^FDVERSUL^FS
^XZ
Run Code Online (Sandbox Code Playgroud)

我尝试更改打印机属性中的标签设置,尝试添加^ LL命令,将单位设置为点.我正在使用Zebra Setup Utilities的控制台,我已经将语言更改为ZPL.没有改变.

你知道我做错了什么或者是否还有其他地方我应该更改标签的设置?

BTW:打印机在CPCL模式下工作正常,看起来它与ZPL的配置有关.

提前致谢.

printing label zpl

6
推荐指数
1
解决办法
9559
查看次数

用于客户端站点(浏览器)PDF生成的块和管道大量数据

我正在尝试从网络服务器(Node.js)下载HTML/JSON数据,并在客户端将其转换为PDF.我希望在用户的浏览器上进行处理,这样我的服务器就不会因为pdfs转换而过载.

如果数据不是那么大,那应该不是问题.报告(从服务器下载的数据)可以总计200,300MB,并且浏览器无法在内存中处理如此多的数据.因此,我(可能)需要以块的形式下载和保存数据,或者将其直接传送到PDF转换器.

但我无法理解它.如何切片和存储/管道下载的数据?我一直在四处寻找并发现了几个库,但我仍然没有得到如何使它们一起工作.有什么想法吗?

javascript pdf pipe download stream

6
推荐指数
1
解决办法
432
查看次数

使用标志启动时,Docker SIGTERM 未传送到 node.js/coffee 应用程序

我在我的应用程序中设置了监听器来捕捉 SIGTERM、SIGINT 和 SIGUSR2:

# kill
process.on 'SIGTERM', ->
    killExecutors 'SIGTERM'

# ctrl + c
process.on 'SIGINT', ->
    killExecutors 'SIGINT'

# nodemon signal
process.on 'SIGUSR2', ->
    killExecutors 'SIGUSR2'
Run Code Online (Sandbox Code Playgroud)

它按预期工作。当我在 docker 实例中运行它时:

FROM node:4.4.7

MAINTAINER Newborns <newborns@versul.com.br>

COPY . /src

EXPOSE 7733

WORKDIR /src
RUN npm install

CMD ["./node_modules/.bin/coffee", "feeder.coffee"]
Run Code Online (Sandbox Code Playgroud)

一切正常,也是。但是,当我向执行添加节点标志时

FROM node:4.4.7

MAINTAINER Newborns <newborns@versul.com.br>

COPY . /src

EXPOSE 7733

WORKDIR /src
RUN npm install

CMD ["./node_modules/.bin/coffee", "--nodejs", "--max_old_space_size=384", "feeder.coffee"]
Run Code Online (Sandbox Code Playgroud)

它停止捕捉信号。我试图将 de CMD exec 形式更改为

CMD ./node_modules/.bin/coffee --nodejs --max_old_space_size=384 feeder.coffee …
Run Code Online (Sandbox Code Playgroud)

javascript node.js coffeescript docker dockerfile

5
推荐指数
1
解决办法
1937
查看次数

Sinon-Stub模块功能,无需依赖注入即可对其进行测试

我有一个代理模块,它将功能调用转发给服务。我想测试在调用此代理模块中的函数时是否调用了服务函数。

这是代理模块:

const payService = require('../services/pay')
const walletService = require('../services/wallet')

const entity = {
    chargeCard: payService.payByCardToken,
    // ... some other fn
}

module.exports = entity
Run Code Online (Sandbox Code Playgroud)

基于此示例此响应,我尝试对所需的模块“ payService”进行存根:

const expect = require('expect.js')
const sinon = require('sinon') 
const entity = require('../entity')
const payService = require('../../services/pay')

describe('Payment entity,', () => {

    it('should proxy functions to each service', () => {

        const stub = sinon.stub(payService, 'payByCardToken')
        entity.chargeCard()
        expect(payService.payByCardToken.called).to.be.ok()

    })
})
Run Code Online (Sandbox Code Playgroud)

但是测试失败并显示:

  0 passing (19ms)
  1 failing

  1) Payment entity,
       should …
Run Code Online (Sandbox Code Playgroud)

javascript unit-testing stub node.js sinon

5
推荐指数
1
解决办法
6840
查看次数

执行$ .find时出错"undefined is a funcion"

伙计们,我再次来求助.我无法理解这一点 - 我需要的是更新表单中name属性的文本索引.我想向用户显示表格中的一行,并且当他/她点击加号时,会添加另一行.为了我的表单在服务器端工作,我需要重新索引name参数.这就是我试图这样做的方式:

function reindex () {
$("table").find("tr.faixa").each(function(index, value) {
value.find("input.faixa_min").attr("name", "data[" + index + "][BonusRecarga][faixa_min]"); // <- here's where I get the error
value.find("input.faixa_max").attr("name", "data[" + index + "][BonusRecarga][faixa_max]");
value.find("input.valor_bonus").attr("name", "data[" + index + "][BonusRecarga][valor_bonus]");
value.find("input.perc_bonus").attr("name", "data[" + index + "][BonusRecarga][perc_bonus]");
});      
}
Run Code Online (Sandbox Code Playgroud)

这是表单的一个片段:

<tr class="faixa">
<td>
<input name="data[0][BonusRecarga][faixa_min]" class="faixa_min" type="text" required="required"/>
 </td>                  
<td>
<input name="data[0][BonusRecarga][faixa_max]" class="faixa_max" type="text" required="required"/>
</td>
<td>
<input name="data[0][BonusRecarga][valor_bonus]" class="valor_bonus" type="text" required="required"/>
</td>
<td>
<input name="data[0][BonusRecarga][perc_bonus]" class="perc_bonus input-small" type="text" required="required"/>
</td>
<td>
<span class="help-inline"><i class="icon-plus" …
Run Code Online (Sandbox Code Playgroud)

javascript iteration jquery

0
推荐指数
1
解决办法
81
查看次数

无法查询类型查询的字段注册

开始摆弄 GraphQL,但我遇到了这个错误。不确定这是架构定义还是查询中的问题。

const express_graphql = require('express-graphql')
const { buildSchema } = require('graphql')
const users = require('../users/translator')

const schema = buildSchema(`
    type User {
        id: ID
        email: String
        role: String
    }
    type Query {
        user(id: ID!): User
        users: [User]
        token(email: String!, password: String!): String!
    }
    type Mutation {
        signup(email: String!, password: String!, role: String!): ID
    }`
)

const resolvers = {
    users: users.getAll,
    user: users.getById,
    token: users.login,
    signup: users.create,
}

module.exports = app => {
    // GraphQL route
    app.use('/graphql', express_graphql({
        schema, …
Run Code Online (Sandbox Code Playgroud)

node.js express graphql express-graphql

0
推荐指数
1
解决办法
7991
查看次数