小编The*_*mer的帖子

为什么我的解决方案如此缓慢?如何提高查询的性能?

目前我能够优化性能,但它仍然有点慢:/

最新编辑:

我目前的解决方案(最快的atm(但仍然很慢)并保持秩序):

服务器

router.post('/images', function(req, res, next) {
    var image = bucket.file(req.body.image);
    image.download(function(err, contents) {
        if (err) {
            console.log(err);
        } else {
            var resultImage = base64_encode(contents);
            var index = req.body.index;
            var returnObject = {
                image: resultImage,
                index: index
            }
            res.send(returnObject);
        }
    });
});
Run Code Online (Sandbox Code Playgroud)

客户端查询

$scope.getDataset = function() {

                fb.orderByChild('id').startAt(_start).limitToFirst(_n).once("value", function(dataSnapshot) {

                    dataSnapshot.forEach(function(childDataSnapshot) {
                        _start = childDataSnapshot.child("id").val() + 1;

                        var post = childDataSnapshot.val();
                        var image = post.image;

                        var imageObject = {
                            image: image,
                            index: position
                        };
                        position++;
                        $.ajax({
                            type: "POST", …
Run Code Online (Sandbox Code Playgroud)

javascript node.js google-cloud-storage firebase google-cloud-platform

11
推荐指数
1
解决办法
795
查看次数

如何使用Firebase实施Steam Auth?

我发现的只有这个老答案:

https://groups.google.com/forum/#!topic/firebase-talk/rApG8QQd6t4

SOer的同事是否知道任何信息,或者Firebase工程师能否提供更详细的答案?

我目前正在尝试使用此库对Steam用户进行身份验证:

https://github.com/liamcurry/passport-steam

然后使用Firebase自定义令牌在Firebase身份验证系统中获取用户.

我不知道这是不是正确的方法.无论如何,我被卡住了.


编辑:

这是我目前的代码:

app.js

var passport = require('passport');
var SteamStrategy = require('passport-steam').Strategy;

app.use(passport.initialize());

passport.serializeUser(function(user, done) {
  done(null, user);
});

passport.deserializeUser(function(obj, done) {
  done(null, obj);
});

passport.use(new SteamStrategy({
    returnURL: 'http://localhost:8080/users/steam/return',
    realm: 'http://localhost:8080/',
    apiKey: steamKey.steam,
    stateless:true
  },
  function(identifier, profile, done) {

    profile.identifier = identifier;
    return done(null, profile);
  }
));
Run Code Online (Sandbox Code Playgroud)

users.js

    router.get('/steam', passport.authenticate('steam', { failureRedirect: 'login' }), function(req, res, next) {

});

router.get('/steam/return', 
  function(req, res, next) {
      req.url = req.originalUrl;
      next();
  }, 
  passport.authenticate('steam', { failureRedirect: 'users/login' }), …
Run Code Online (Sandbox Code Playgroud)

javascript node.js firebase steam firebase-authentication

11
推荐指数
1
解决办法
1232
查看次数

错误的ERR!版本无效:"1"

题:

在我的本地机器上执行"节点应用程序"时,一切正常.

但是,当我将项目部署到Google App Engine时,实例被终止,我在日志中发现以下错误:

npm ERR! Invalid version: "1"
Run Code Online (Sandbox Code Playgroud)

我在看:

npm:为什么版本"0.1"无效?

错误的ERR!版本无效:y

如何解决npm"错误:版本无效:"0.1"BUG?

我需要纠正的错误是什么?

部署过程始于 gcloud app deploy --version=deploy

总是以:

ERROR: (gcloud.app.deploy) Error Response: [4] Timed out waiting for the app infrastructure to become healthy.
Run Code Online (Sandbox Code Playgroud)

这是我的package.json


码:

的package.json

{
  "name": "Name",
  "version": "1.0.0",
  "description": "Desc",
  "main": "app.js",
  "engines": {
    "node": "6.9.4",
    "npm": "4.2.0"
  },
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "node app.js",
    "minify": "html-minifier --input-dir ./viewsCopy --output-dir ./views-minified --collapse-whitespace --html5 --minify-js true"
  }, …
Run Code Online (Sandbox Code Playgroud)

javascript node.js npm google-cloud-platform package.json

11
推荐指数
3
解决办法
2297
查看次数

Next.js 在开发模式下加载页面非常慢(30 秒以上),这可能是什么原因造成的?

问题:

本质上遇到以下问题(但使用不同的文件):https ://github.com/vercel/next.js/discussions/17977

已经尝试了那里建议的一切。

这是开发模式下页面加载的样子:

在此输入图像描述

有人对如何优化这个有任何建议吗?


代码:

next.config.js:

const withPlugins = require('next-compose-plugins');
const webpack = require("webpack")
const withBundleAnalyzer = require('@next/bundle-analyzer')({
    enabled: process.env.ANALYZE === 'true',
})
const withTM = require('next-transpile-modules')(['swr']);

nextConfig = {
    images: {
        domains: ['storage.googleapis.com'],
    },
    webpack: config => {
        config.resolve.extensions = [ '.mjs', '.js', '.jsx', '.json' ];
        config.plugins.push(
            new webpack.ProgressPlugin((percentage, message, ...args) => {
                // e.g. Output each progress message directly to the console:
                console.info(percentage, message, ...args);
            })
        );
        return config
    }
}

module.exports = withPlugins([
    withBundleAnalyzer, …
Run Code Online (Sandbox Code Playgroud)

javascript node.js webpack next.js

8
推荐指数
1
解决办法
8597
查看次数

是否可以通过Firebase Admin SDK从我的Node.js服务器发送验证电子邮件?

有没有办法从我的服务器发送电子邮件验证电子邮件?

这是在客户端上完成的方式:

authData.sendEmailVerification().then(function() {
Run Code Online (Sandbox Code Playgroud)

有没有办法在服务器上做到这一点?

node.js firebase firebase-authentication firebase-admin

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

There is always a gap on my Audio Loop in Safari

SITUATION:

It works fine on Chrome. But there is a small gap every time the "Waterfall 1" sound loops, only on Safari.

Website: http://mymindflow.com


WHAT I TRIED SO FAR:

1) With the HTML 5 audio element:

audio.addEventListener('timeupdate', function(){
                    var buffer = 0.44;
                    if(this.currentTime > this.duration - buffer){
                        this.currentTime = 0
                        this.play()
                    }}, false);
Run Code Online (Sandbox Code Playgroud)

2) Gapless.js https://github.com/regosen/Gapless-5

3) Howler.js https://github.com/goldfire/howler.js

4) Web Audio API alone: How to seamlessly loop sound with web audio api


QUESTION:

How can I get rid of …

html javascript safari audio howler.js

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

为什么我的使用 Next.js (React) 构建的 Shopify 应用加载速度如此之慢?

我遵循了本教程:https://shopify.dev/tutorials/build-a-shopify-app-with-node-and-react

从一开始,我的应用程序加载速度非常慢,包括更改选项卡时,包括通过 ngrok 加载并在本地主机上运行或部署在应用程序引擎上时。

可能是什么原因造成的?

PS:我是 React、Next.js 和 Shopify 应用程序开发的新手,所以答案可能非常基本。

PPS:基于红色,构建输出似乎表明“所有人共享的首次加载 JS”太大。我不知道如何调查这个问题并减少所述块的大小,尽管仅仅 214KB 无法解释如此缓慢的加载时间,不是吗?


建造

在此输入图像描述


React 开发工具分析器

在此输入图像描述

在此输入图像描述


@next/bundle-analyzer 输出:

已解析

在此输入图像描述

在此输入图像描述

压缩

在此输入图像描述

在此输入图像描述


包.json

 {
      "name": "ShopifyApp1",
      "version": "1.0.0",
      "description": "",
      "main": "index.js",
      "scripts": {
        "test": "echo \"Error: no test specified\" && exit 1",
        "dev": "node server.js NODE_ENV=dev",
        "build": "next build",
        "deploy": "next build && gcloud app deploy --version=deploy",
        "start": "NODE_ENV=production node server.js",
        "analyze": "cross-env ANALYZE=true npm run build"
      },
      "keywords": [],
      "author": "",
      "license": "ISC",
      "dependencies": {
        "@google-cloud/storage": "^5.2.0",
        "@next/bundle-analyzer": …
Run Code Online (Sandbox Code Playgroud)

javascript node.js shopify reactjs next.js

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

如何在 Next.js 中为 Material-ui 正确配置 babel?

文件:

https://material-ui.com/guides/minimizing-bundle-size/#development-environment

“在项目的根目录中创建一个 .babelrc.js 文件:

const plugins = [
  [
    'babel-plugin-transform-imports',
    {
      '@material-ui/core': {
        // Use "transform: '@material-ui/core/${member}'," if your bundler does not support ES modules
        'transform': '@material-ui/core/esm/${member}',
        'preventFullImport': true
      },
      '@material-ui/icons': {
        // Use "transform: '@material-ui/icons/${member}'," if your bundler does not support ES modules
        'transform': '@material-ui/icons/esm/${member}',
        'preventFullImport': true
      }
    }
  ]
];

module.exports = {plugins};"
Run Code Online (Sandbox Code Playgroud)

https://nextjs.org/docs/advanced-features/customizing-babel-config

“要添加具有自定义配置的预设/插件,请在 next/babel 预设上执行此操作,如下所示:

{
  "presets": [
    [
      "next/babel",
      {
        "preset-env": {},
        "transform-runtime": {},
        "styled-jsx": {},
        "class-properties": {}
      }
    ]
  ],
  "plugins": []
}" …
Run Code Online (Sandbox Code Playgroud)

javascript node.js babeljs material-ui next.js

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

如何在 Node.js 中进行 Cragislist 电子邮件转发(接收电子邮件到自动生成的电子邮件地址并转发)?

我发现的只是这个使用 Rails 的问题:Email Forwarding like Craigslist - Rails

我用 google 搜索了很长时间,但找不到任何使用 Node.js 的东西。

我知道这不是通常接受的问题,但此时我确实没有其他办法。

您能给我指出一个我可以使用的资源或一些教程吗?或者也许您知道自己该怎么做?

编辑:我最终使用了 Sendgrid。

javascript email node.js craigslist

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

如何向 GLTF 模型添加光泽度/镜面反射纹理?

问题:

我有一个模型的镜面/光泽度纹理图像,该图像尚未被 GLTF 模型使用。

如何使用/添加纹理到我的模型中,使其在应有的位置具有反光/光泽?

我不知道要在 .gltf 文件中更改什么才能使用纹理。

编辑:添加了更多 GLTF 行以更好地了解情况。


GLTF JSON:

"images": [
    {
        "name": "...",
        "uri": "..."
    },
    {
        "name": "...",
        "uri": "..."
    },
    {
        "name": "...",
        "uri": "..."
    },
    {
        "name": "...",
        "uri": "..."
    },
    {
        "name": "...",
        "uri": "..."
    }
],
"samplers": [
    {}
],
"textures": [
    {
        "name": "T_N",
        "sampler": 0,
        "source": 0
    },
    {
        "name": "Map #9",
        "sampler": 0,
        "source": 1
    },
    {
        "name": "T_D",
        "sampler": 0,
        "source": 2
    },
    {
        "name": …
Run Code Online (Sandbox Code Playgroud)

javascript json textures three.js gltf

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