小编Cha*_*add的帖子

NodeJS 示例 - Firebase Cloud Functions - 实例化 Admin SDK Directory 服务对象

目标

使用googleapis与火力地堡云功能,能在这个摹套房域中所有用户的列表。

如何实例化 Admin SDK Directory 服务对象。我没有看到 NodeJS 示例,也不清楚如何使用googleapis.

语境

此代码从 Firebase Cloud Functions 运行,并且似乎可以通过身份验证。现在,如何//TODO在以下代码中设置服务对象:

// Firebase Admin SDK
const functions = require('firebase-functions')
const admin = require('firebase-admin')
admin.initializeApp(functions.config().firebase)

// Google APIs
const googleapis = require('googleapis')
const drive = googleapis.drive('v3')
const gsuiteAdmin = googleapis.admin('directory_v1')

// Service Account Key - JSON
let privatekey = require("./privatekey.json")

let jwtClient = new googleapis.auth.JWT(
    privatekey.client_email,
    null,
    privatekey.private_key,
    ['https://www.googleapis.com/auth/drive',
        'https://www.googleapis.com/auth/admin.directory.user'])

// Firebase Cloud Functions - REST
exports.authorize = …
Run Code Online (Sandbox Code Playgroud)

node.js jwt service-accounts google-admin-sdk google-cloud-functions

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

Docker 映像中的 Bitbucket 管道缺少 NPM 模块

问题

Dockerfile我的或有什么问题bitbucket-pipelines.yml吗?为什么 bitbucket pipeline 环境中缺少模块?

错误

当我尝试npm run build使用 Bitbucket Pipelines 通过 webpack 处理我的 Vue2 项目时,我收到有关缺少模块的错误。

来自日志

npm run build
> people-is@1.0.0 build /opt/atlassian/pipelines/agent/build
> node build/build.js
module.js:549
    throw err;
    ^
Error: Cannot find module 'cli-spinners'
Run Code Online (Sandbox Code Playgroud)

文件

这是配置文件。

Dockerfile -构建 cportwine/people-is

FROM node:8.10.0

RUN npm install
RUN npm install -g firebase-tools

CMD [ "npm", "run", "build" ]
Run Code Online (Sandbox Code Playgroud)

bitbucket-pipelines.yml

image:
  name: cportwine/people-is
pipelines:
  default:
    - step:
        script:
          - npm run build
Run Code Online (Sandbox Code Playgroud)

包.json

{
  "name": "people-is", …
Run Code Online (Sandbox Code Playgroud)

node.js npm docker package.json bitbucket-pipelines

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

在localhost上运行vue-cli欢迎页面的Docker容器:无法访问此站点

我希望看到chrome中的vue-cli欢迎页面,从我Mac上的Docker Container运行.我正在努力为此设置正确的配置.我错过了什么?这是我尝试过的.

脚步

安装

  1. 适用于Mac的Docker - 17.12.0-ce
  2. npm 5.6.0
  3. vue-cli 2.9.3

命令行

  1. $ vue init webpack docvue
  2. $ cd docvue
  3. $ npm install

运行上面的命令后,我现在准备好使用webpack构建vue示例项目.

$ ls
README.md       config          node_modules        package.json        static
build           index.html      package-lock.json   src
Run Code Online (Sandbox Code Playgroud)

/docvue/我可以npm run dev,我看到:

> docvue@1.0.0 dev /Users/dchaddportwine/Startup/docvue
> webpack-dev-server --inline --progress --config build/webpack.dev.conf.js

 95% emitting                                                                        

 DONE  Compiled successfully in 4695ms                                                                              12:17:04 PM

 Your application is running here: http://localhost:8080
Run Code Online (Sandbox Code Playgroud)

在Chrome中,http://localhost:8080/#/我看到了Vue Welcome页面.

构建Docker镜像

现在是时候使用这个Dockerfile构建Docker镜像了:

# base image
FROM node:8.10.0-alpine …
Run Code Online (Sandbox Code Playgroud)

node.js docker webpack vuejs2 vue-cli

3
推荐指数
1
解决办法
3305
查看次数

Firebase - 部署您的站点 - 删除云功能

如何在不删除云功能的情况下部署Firebase网站.

  1. 也许,在一个部署中包含站点和云功能?那是什么样的?
  2. 也许,在不删除云功能的情况下部署网站?我找不到firebase deploy --only site或类似的

上下文

我有一个使用云功能的Firebase项目.代码位于两个文件夹中:

-site-code
-cloud_function-code
Run Code Online (Sandbox Code Playgroud)

当我想部署项目时,我使用firebase CLI工具,分两步:

步骤1

-site-code我跑:

firebase deploy
Run Code Online (Sandbox Code Playgroud)

第2步

然后从cloud_functions-code我运行:

firebase deploy --only functions
Run Code Online (Sandbox Code Playgroud)

问题

当我运行firebase deploy -site-code我的火力地堡云功能都被删除了,所以我必须跟进firebase deploy --only functions -cloud_functions-code.

我没有找到--only仅部署站点代码的指令-site-code

firebase firebase-hosting google-cloud-functions

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

对Slack API使用Firebase onRequest()或Express app.use()

目标

使用@slack/interactive-messagefirebase-functions来监听和响应Slack消息和对话框.

我不确定如何使用@slack/interactive-messagefirebase 的监听器.

1)我是否使用Firebase functions.https.onRequest(),并以某种方式req从Slack 传递到 slackInteractions.action()

要么

2)我使用的app.use("/app", slackInteractions.expressMiddleware());如果是这样,你在哪里slackInteractions.action()小号

要么

3)还有别的吗?

// Express
import express = require("express");
const app = express();
const cors = require("cors")({
  origin: "*"
});
app.use("*", cors);

// Firebase Functions SDK
import functions = require("firebase-functions");

const slackbotConfig = functions.config().slackbot;
const { createMessageAdapter } = require("@slack/interactive-messages");
const slackInteractions = createMessageAdapter(slackbotConfig.signing_secret);

app.use("/app", slackInteractions.expressMiddleware());

// Express route
app.post("/go", (req, …
Run Code Online (Sandbox Code Playgroud)

middleware express firebase slack-api google-cloud-functions

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