javascript – How to turn nodeJS scraper results into a CSV file?

I’m using the nodeJS scraper below that scrapes the google play store. However, I’d like the results to show up in a CSV file. Currently it just runs in console:

https://github.com/facundoolano/google-play-scraper

Secondly, I would like to somehow combine the “search” and “app detail” functions so that I could search a term and return the App title, developer name, app URL, and developer email.

Search function:

var gplay = require('google-play-scraper');

gplay.search({
    term: "panda",
    num: 2
  }).then(console.log, console.log);

App Details Function:

var gplay = require('google-play-scraper');

gplay.app({appId: 'com.google.android.apps.translate'})
  .then(console.log, console.log);

oauth – What are the best practices to create a safe and performant user registration and validation with Nodejs and Postgres?

I’ve been asked to write an app with registration and login systems. In essence, I’ve already wrote the first version of their app using PHP, some javascript/jquery and storing data in MySQL. It worked for a time but now they are growing and expanding so they want something more performant and in realtime with push notifications. You know, the whole nine.

I’m always up to a great challenge especially if I need to learn new technologies. So I have leveled up my game and Im now learning to use Nodejs, Postgres and socket.io. So far I’m understanding the basics fairly well. Ran a few tests and it’s top notch.

The only thing that has been plaguing me for the past week is security and registration. I’ve been doing extensive research on OAuth2 and PKCE Flow. I’m trying to figure out the best practices without compromising UX.

I’d be happy to read more on the subject or if there are any API available. I’m thinking perhaps it’s not safe to handle registration and login by myself. The methodology used with PHP and MYSQL is very backward in my opinion and I’m looking for something more modern working with Nodejs and Postgres. Most login and registration systems, for example Google, send temporary numbers that expires within 30 mins and they can recognize your device and send alerts if you login from a device they dont recognize asking you if it’s you who just logged in. That’s the level I’m trying to reach. Any suggestion?

With PHP and MySQL the current registration flow is as follow :
enter image description here

node.js – What kind of hardware/infrastructure would I ideally need for this project idea?

I want to offer users a cloud-based version of a piece of software I have written in C#, which requires computational power and a fair amount of time (depending on how much data they are processing).

So, as a standalone software, performance really entirely depends on the user’s own hardware.

I came up with an alternate version to this software, where users will be able to login, upload their data, and then everything that needs to be processed will be done in the back-end, so the user can safely log out, and come back later.

I intend on writing this project in Node, using React as a front-end. I also intend to use a queueing library such as Bull or bee-queue which will have a hosted Redis server elsewhere.

However, if this becomes more popular, then it requires more hardware (CPU and RAM).

Let’s say a user uploads their data to be processed, but there aren’t enough resources available, what’s a viable way I could off-load this to say, another server?

I’ve never worked on anything that required some kind of ‘cluster’ in the back-end, so I really don’t know what kind of infrastructure I’d be looking for, and whether or not somewhere like AWS has that available.

node.js – Meu req.body retorna sempre vazio {}

Estou tentando pegar dados de um formulário, porém o meu req.body retorna sempre vazio

    import express from "express";
import * as httpStatus from 'http-status';
import bodyParser, { json } from "body-parser";
import cors from 'cors';
import mail from "./services/mail";


class App {
    
    public app: express.Application;

    enableCors(){
        const options: cors.CorsOptions = {
            methods: "GET,OPTIONS,PUT,POST,DELETE",
            origin: "*"
        };

        this.app.use(cors(options));
    }

    constructor() {
        this.app = express();
        this.enableCors();
        this.app.use(bodyParser.urlencoded({extended: true}));
        this.routes();
    }

    routes() {
        this.app.route("/contato").get((req, res) => {
            res.send({ 'result': 'version 0.0.2' })
        });
        
        this.app.post("/contato", (req, res) => {
            const message = Object.assign({}, req.body);
            let nome = req.body;
            console.log(nome);     
            
            mail.to = '';
            mail.subject = message.subject;
            mail.message = message.message;
            let result = mail.sendMail();

            res.status(200).json({ 'result': result })
        });


    }
}

export default new App();

No react tenho o seguinte código:

   export default function Contato() {

  const (nome, setNome) = useState('');
  const (sobrenome, setSobrenome) = useState('');
  const (contato, setContato) = useState('');
  const (cidadeEstado, setCidadeEstado) = useState('');
  const (email, setEmail) = useState('');
  const (assunto, setAssunto) = useState('');
  const (mensagem, setMensagem) = useState('');

  async function tratarFomulario(event: FormEvent) {
    event.preventDefault();

    const data = new FormData();

    data.append('nome', nome);
    data.append('sobrenome', sobrenome);
    data.append('contato', contato);
    data.append('cidadeEstado', cidadeEstado);
    data.append('email', email);
    data.append('assunto', assunto);
    data.append('mensagem', mensagem);

    await api.post('contato', data)

    alert('email enviado');

    console.log(
      nome,
      sobrenome,
      contato,
      cidadeEstado,
      email,
      assunto,
      mensagem
      );
  }

  return (
    <div className="global">
      <div className="container-global">
        <form className="mt-5" onSubmit={tratarFomulario}>
          <div className="container mb-5">
            <div className="row row-align">
              <h2 className="h-contato">ENTRE EM CONTATO</h2>
            </div>
          </div>
          <div className="container mt-2">
            <div className="col row justify-content-center">
              <div id="endereco" className="col-6">
                <div className="row row-align">
                  <p>
                    Rod Rs 453, Rota do Sol, Km 90,5 <br />
                    B. São Roque - Garibaldi (RS)
                  </p>
                </div>

                <div className="row mt-4 row-align">
                  <p className="mr-2"><FontAwesomeIcon icon={faWhatsappSquare} size="2x" /></p>
                  <p>(054) 99953-0114</p>
                </div>

                <div className="row mt-4 row-align">
                  <p>lafabbricamoveis@yahoo.com</p>
                </div>

                <div className="row row-align mb-5">
                        <div className="mr-3">
                            <FontAwesomeIcon icon={faFacebookSquare} className="icon"/>
                        </div>
                        <div className="mr-3">
                            <FontAwesomeIcon icon={faInstagramSquare} className="icon"/>
                        </div>
                        <div>
                            <FontAwesomeIcon icon={faWhatsappSquare} className="icon"/>
                        </div>
                    </div>

              </div>

              <div id="contato" className="col-6 row reverse">
                <div className="form-row">
                  <div className="form-group col-md-6 col-align-center">
                    <label htmlFor="inputNome"></label>
                    <input type="text" className="form-button" name="nome" id="inputNome" placeholder="Nome" onChange={event => setNome(event.target.value)}/>
                  </div>
                  <div className="form-group col-md-6 col-align-center">
                    <label htmlFor="inputSobrenome"></label>
                    <input type="text" className="form-button" id="inputSobrenome" placeholder="Sobrenome" onChange={event => setSobrenome(event.target.value)}/>
                  </div>
                </div>

node.js – Managing external-source depending workflows and rollback

I am looking for an elegant way to manage workflows and rollback when needed but the system is depending on various external services most steps of these workflows are triggering by external sources (like webhooks).

An example scenario for a subscription system:

1) User sends a subscription request
2) The subscription created on the database with `status=pending`
3) Subscription request sent to Stripe 
4) (Stripe does some black magic -like credit card verification-)
5) Stripe informs the results of subscription (succeeded or failed) to our app via an HTTP request (God knows when, maybe in 10 seconds, maybe in 10 hours)
6) Update the subscription on the database `status=active` or `status=failed`
7) doSomeOtherImportantStuffWithSubscription()

Now, in this flow, if any of these steps fails for some reason (an exception thrown, database connection error, Stripe card verification error etc.) I want to rollback all the previous steps. But handling all this flow with a bunch of if-else statements is probably the worst idea, and I wonder if there is an elegant and standardized way to achieve this rollback mechanism.

I’m looking for a framework-agnostic solution but if it’s important this is our tech stack:

MoleculerJS (with TypeScript)

Stripe API

MySQL 5.7.26

UPDATE

An example of what I’m trying to achieve:

1) User sends a subscription request
2) The subscription created on the database with `status=pending`
3) Subscription request sent to Stripe 
4) (Stripe does some black magic -like credit card verification-)
5) Stripe informs the results of subscription (succeeded or failed) to our app via an HTTP request (God knows when, maybe in 10 seconds, maybe in 10 hours)
6) Update the subscription on the database **failed because of a connection error**
7) Cancel Subscription on Stripe (reverse of 5th step)
8) Delete subscription request from the database (reverse of 2nd step)

node.js – Como exibir uma lista de rooms com o Socket.IO?

Olá! Estou desenvolvendo uma aplicação web de um chat utilizando React, NodeJS, Express e Socket.IO e gostaria de exibir uma lista com todas as salas disponíveis para que o usuário possa transitar de uma sala para outra. Eu já fiz algumas pesquisas e descobri que uma forma de alcançar o meu objetivo é utilizando o io.sockets.adapter.rooms. Porém, ao que me parece tal comando só retorna os ID’s das salas. Como eu poderia utilizar o retorno de io.sockets.adapter.rooms para conseguir exibir as rooms aos usuários? Existe alguma outra forma? Muito obrigado.

blog – Is there a good open-source blogging system out there written in nodejs that comes with GUI?

I’ve been working with this company for a few years. When we first started, I wrote their website using PHP and their mobile app using Cordova. They needed a blogging system and so since we were using PHP as the language I hooked them with Serendipity. It’s old and it’s not that great but there was that one theme that looked modern enough to be usable. Serendipity is written in PHP and uses MySQL. What I like about it is that it offers a GUI backend for my client to be able to create and write posts on his own a bit like WordPress.

Thing is now we’re migrating to nodejs and postgres.

Here’s what I’m looking for :

  • Blog system with GUI for my client
  • Written in Nodejs
  • Open source
  • I’d like to be able to query every post my client writes from the blogging system and display/embedded them on the website. With Serendipity, it’s like a whole new website I have to link from their website.

I’ve done a bit of research and I came accross Poet which is written in node. But it doesn’t seem to offer any GUI for humans to be able to write, delete and create new posts?

Can anyone suggests anything? Thanks

nodejs – como enviar eventos a distintos sockets en particulares

estoy buscando enviar eventos a distintos sockets, tengo el backend echo con nodejs y typescript y el frontend con react, todo funciona bien, cuando el cliente se conecta al socket, automáticamente se hace un update mediante mongoose que actualiza el socketid de mi modelo de datos, esto lo hago para tener el id del socket de cada usuario en la base de datos, mi idea es que cuando un usuario haga una acción, se envíen ciertos datos a ciertos usuarios,

const EmitterNewLike = async (_id: String, usr: IUsuario) => {
  const socket = getSocket();
  const publicacion: IPublicaciones | null = await Publicaciones.findById(
    _id
  ).populate({ path: "usuario" });
  socket.to((id, id, id, id ))emit("NEW_LIKE", publicacion, usr);
};

estoy buscando hacer algo como lo que se ve aquí, enviar mediante un .to(), un array de los id que van a recibir ese evento, obviamente esto no funciona, pero estoy buscando hacer algo similar para enviar eventos a ciertos usuario

nodejs – Update masivo con node js y postgresql

Buenas noches tengo una funcion PUT que me realiza el UPDATE 1×1 donde le paso su “id”, pero desearia implementar otra Funcion Post que reciba una array de objetos en JSON y realice la actualizacion de una sola vez y me indique si todo proceso correctamente o si hubo un error.

mi Arreglo JSON seria

[{"id" : 1, "estado1" : "1", "estado2" : "1"},
{"id" : 2, "estado1" : "2", "estado2" : "3"},
{"id" : 3, "estado1" : "2", "estado2" : "3"},
{"id" : 4, "estado1" : "2", "estado2" : "2"},
{"id" : 5, "estado1" : "3", "estado2" : "1"},
{"id" : 6, "estado1" : "1", "estado2" : "1"}
]

donde “id” es el identificador de mi documento y “estado1” y “estado2” los campos que voy actualizar.