小编Mus*_*eed的帖子

使用 Lerna 在 mono 存储库中 Docker 化多个 Node 应用程序

我的单一存储库和 Docker 项目设置遇到一些问题。

\n\n

我想使用 Lerna 进行单一存储库设置,并使用 Docker 进行项目构建。

\n\n

在我集成 Lerna 之前,一切都工作得很好,但现在我集成了 Lerna,我不知道我必须调用哪个部分/步骤,lerna bootstrap因为调用此命令后,我node_modules将自动构建,我不再需要npm install在每个中单独运行Dockerfile。我不明白的是这一切会是什么样子,我是否必须Dockerfile为根文件夹创建另一个?如果是,那么我的docker-compose.yml文件会是什么样子?一切都还不清楚。

\n\n

这就是我的项目树的样子:

\n\n

后端文件夹具有基本的 Nestjs 设置,客户端文件夹具有基本的 Gatsby 设置。

\n\n
\n.\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 backend\n\xe2\x94\x82   \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 Dockerfile\n\xe2\x94\x82   \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 nest-cli.json\n\xe2\x94\x82   \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 package.json\n\xe2\x94\x82   \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 README.md\n\xe2\x94\x82   \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 src\n\xe2\x94\x82   \xe2\x94\x82   \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 app.controller.spec.ts\n\xe2\x94\x82   \xe2\x94\x82   \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 app.controller.ts\n\xe2\x94\x82   \xe2\x94\x82   \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 app.module.ts\n\xe2\x94\x82   \xe2\x94\x82   \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 app.service.ts\n\xe2\x94\x82   \xe2\x94\x82   \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 main.ts\n\xe2\x94\x82   \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 test\n\xe2\x94\x82   \xe2\x94\x82   \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 app.e2e-spec.ts\n\xe2\x94\x82   \xe2\x94\x82   \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 jest-e2e.json\n\xe2\x94\x82   \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 tsconfig.build.json\n\xe2\x94\x82   \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 tsconfig.json\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 client\n\xe2\x94\x82   \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 Dockerfile\n\xe2\x94\x82   \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 …
Run Code Online (Sandbox Code Playgroud)

node.js npm docker reactjs lerna

7
推荐指数
1
解决办法
5485
查看次数

使用 createUploadLink 和 WebSocketLink 的 ApolloClient 配置

我希望能够从我需要使用的 React Native 应用程序上传文件,createUploadLink但我在配置它时遇到一些问题。

我当前的设置如下所示:

import SInfo from "react-native-sensitive-info";
import Config from "react-native-config";
import { InMemoryCache, ApolloClient } from "apollo-boost";
import { createHttpLink } from "apollo-link-http";
import { createUploadLink } from "apollo-upload-client";
import { WebSocketLink } from "apollo-link-ws";
import { setContext } from "apollo-link-context";
import { getMainDefinition } from "apollo-utilities";
import { split } from "apollo-link";

let token: any;

const getToken = async () => {
  if (token != null) {
    return token;
  }

  token = await SInfo.getItem("ACCESS_TOKEN", …
Run Code Online (Sandbox Code Playgroud)

typescript apollo graphql react-native apollo-client

5
推荐指数
0
解决办法
1078
查看次数

无法使用 play() 函数在 React Typescript 中播放音频 | 错误:属性“play”不存在

我用 Typescript 在 React js 中创建了一个简单的音频播放器,我尝试使用普通的 HTML5 函数来播放和暂停音频,但它不起作用。

当我这样做时,mytrack.play();我收到此错误:Property 'play' does not exist on type 'HTMLElement'.

这是我的代码:

import React, { Component } from "react";
import "./SimplePlayer.css";
import styled from "styled-components";

export interface SimplePlayerProps {}

var mytrack = document.getElementById("mytrack");
console.log(mytrack);
mytrack.play();

export class SimplePlayer extends Component<SimplePlayerProps> {
  constructor(props: SimplePlayerProps) {
    super(props);
    console.log(this.props);
    this.state = {};
  }

  render() {
    return (
      <div id="wrapper">
        <audio id="mytrack" controls>
          <source src="audio.mp3" />
        </audio>
        <nav>
          <div id="defaultBar">
            <div id="progressBar" />
          </div>
          <div id="buttons"> …
Run Code Online (Sandbox Code Playgroud)

javascript audio jsx typescript reactjs

4
推荐指数
1
解决办法
5609
查看次数

如何取消订阅(删除侦听器)React Native Expo 推送通知

我想为用户提供一个能够取消订阅通知的选项。我已经阅读了 Expo 文档,但我仍然不确定如何在我的代码中实现它。

这是我想要实现的:https ://docs.expo.io/versions/latest/sdk/notifications/#eventsubscription

Notifications.addListener(listener) EventSubscription 然后remove()(函数)——取消监听器对未来通知的订阅。通知

方法如下componentDidMount

  componentDidMount() {
registerForPushNotificationsAsync();

// Handle notifications that are received or selected while the app
// is open. If the app was closed and then opened by tapping the
// notification (rather than just tapping the app icon to open it),
// this function will fire on the next tick after the app starts
// with the notification data.
this._notificationSubscription = Notifications.addListener(this._handleNotification);
Run Code Online (Sandbox Code Playgroud)

}

一些帮助会非常好

最好的问候穆萨亚布

javascript listener push-notification react-native expo

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

无法使用样式组件将样式应用于 React Native 中的自定义组件?

styled-components在我的 React Native 应用程序中使用它来设计它。样式在其他组件上运行良好,但是当我尝试为自定义创建的组件设置样式时,不会应用任何样式。

在这种情况下,不应用填充。

这是我的代码示例之一:

import React, { Component } from "react";
import { View } from "react-native";
import styled from "styled-components/native";
import { BigTitle } from "./Titles";

class Home extends Component {
  render() {
    return (
      <View>
        <MainTitle title="Hello World!" />
      </View>
    );
  }
}
export default Home;

const MainTitle = styled(BigTitle)`
  padding-top: 45px;
  padding-bottom: 10px;
`;


Run Code Online (Sandbox Code Playgroud)

这是自定义创建的组件:


import React from "react";
import { Text } from "react-native";
import styled from "styled-components/native";

interface TitleProps {
  title: …
Run Code Online (Sandbox Code Playgroud)

css frontend reactjs react-native styled-components

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