我是 WebSocket (webRTC) 的新手。我创建了一个视频聊天应用程序。它在本地主机上工作。
服务器
app.listen(process.env.PORT || 8081, function () {
console.log("Example app listening at 8081" )
});
app.get('/', function(req, res){
res.sendfile('index.html');
});
//require our websocket library
var WebSocketServer = require('ws').Server;
//creating a websocket server at port 9090
var wss = new WebSocketServer({server: app});
//all connected to the server users
var users = {};
Run Code Online (Sandbox Code Playgroud)
客户
//connecting to our signaling server
var HOST = location.origin.replace(/^http/, 'ws');
var conn = new WebSocket(HOST);
conn.onopen = function () {
console.log("Connected to the signaling server"); …Run Code Online (Sandbox Code Playgroud) 我的文档有包含多个对象的数组,我需要找到相关的值并推送到同一个数组中。
大车
{
"_id" : ObjectId("5b2b72119fbb60750e0061b9"),
"cartId" : "1529573905701",
"supplierId" : ObjectId("5b221d1b63eda2902418434d"),
"user_id" : "5b20c54651e68057b3cbe745",
"createdAt" : ISODate("2018-06-21T09:38:25.680Z"),
"services" : [
{
"date" : "21-06-2018",
"timeSlot_id" : ObjectId("5b29e08cb116c31f5b1f56c6"),
"time" : "03:30 PM - 04:30 PM",
"serviceId" : ObjectId("5b24aff4abf2494701bc1c15"),
"cost" : 250,
"_id" : ObjectId("5b2b72119fbb60750e0061ba")
},
{
"_id" : ObjectId("5b2b72329fbb60750e0061bb"),
"cost" : 250,
"serviceId" : ObjectId("5b24aff4abf2494701bc1c15"),
"time" : "03:30 PM - 04:30 PM",
"timeSlot_id" : ObjectId("5b29e08cb116c31f5b1f56c6"),
"date" : "21-06-2018"
}
],
"__v" : 0
}
Run Code Online (Sandbox Code Playgroud)
服务
{
"_id" : ObjectId("5b24aff4abf2494701bc1c15"),
"isActivated" …Run Code Online (Sandbox Code Playgroud) 我用来@aws-sdk/client-kms加密数据。我得到了 base64 字符串作为响应。现在我得到了Uint8Array。
const encryptedBlob = await kms.encrypt({
KeyId: kmsKey,
Plaintext: Buffer.from(JSON.stringify('data to encrypt')),
});
Run Code Online (Sandbox Code Playgroud)
加密的明文。当您使用 HTTP API 或 AWS CLI 时,该值是 Base64 编码的。否则,它不是 Base64 编码的。AWS文档中提到
有没有办法在nodeJs中获取base64作为响应。
我在 github 上托管了一个 npm 包。在本地机器上工作时工作正常。但它不会在 docker 构建过程中安装。
Dockerfile
FROM node:14-alpine as base
EXPOSE 8080
ARG LIB_GITHUB_TOKEN
ENV NODE_ENV=production \
LIB_GITHUB_TOKEN="${LIB_GITHUB_TOKEN}"
WORKDIR /home/node/app
RUN chown -R node:node /home/node/app
COPY --chown=node:node package.json package-lock*.json tsconfig.json .npmrc ./
RUN npm install --only=development
RUN ls -a **every pkgs installed except gihub pvt pkg**
RUN cd node_modules/ && ls
RUN npm run build
Run Code Online (Sandbox Code Playgroud)
.npmrc 文件
registry=https://registry.npmjs.org/
@github_user:registry=https://npm.pkg.github.com/
//npm.pkg.github.com/:_authToken=${LIB_GITHUB_TOKEN}
Run Code Online (Sandbox Code Playgroud)
除了我的 GitHub 私有包之外,所有包都已安装。
与 docker-compose 一样可以正常工作。
如果我添加npm ci --only=production到 dockerfile. 它给 -
npm ERR! code E401 …Run Code Online (Sandbox Code Playgroud) Nest无法解析AuthService(?)的依赖项。请验证[0]参数在当前上下文中是否可用。
请找到我的项目资料库
Error: Nest can't resolve dependencies of the AuthService (?). Please verify whether [0] argument is available in the current context.
at Injector.lookupComponentInExports (/home/arpit/Documents/aquaapp/node_modules/@nestjs/core/injector/injector.js:129:19)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:182:7)
at Function.Module.runMain (internal/modules/cjs/loader.js:697:11)
at Object.<anonymous> (/home/arpit/Documents/aquaapp/node_modules/ts-node/src/_bin.ts:177:12)
at Module._compile (internal/modules/cjs/loader.js:654:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:665:10)
at Module.load (internal/modules/cjs/loader.js:566:32)
at tryModuleLoad (internal/modules/cjs/loader.js:506:12)
at Function.Module._load (internal/modules/cjs/loader.js:498:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:695:10)
at startup (internal/bootstrap/node.js:201:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:516:3)
1: node::Abort() [/usr/bin/node]
2: 0x8d04d9 [/usr/bin/node]
3: v8::internal::FunctionCallbackArguments::Call(void (*)(v8::FunctionCallbackInfo<v8::Value> const&)) [/usr/bin/node]
4: 0xb17d2c [/usr/bin/node]
5: v8::internal::Builtin_HandleApiCall(int, v8::internal::Object**, v8::internal::Isolate*) [/usr/bin/node] …Run Code Online (Sandbox Code Playgroud) node.js ×3
amazon-kms ×1
aws-sdk-js ×1
docker ×1
heroku ×1
jwt ×1
mongodb ×1
mongoose ×1
nestjs ×1
typescript ×1
websocket ×1