node.js – Postgres Pagination – DESC returns correct results but not ASC

This query works for DESC, but for ASC (for the most recent record) I do not get the latest version made in last. In fact, although I get the same overall results, the latest ones made in is not displayed at all (when it should be displayed last).

Any ideas why?

const queryAsc = (params) => {
Return pool
.query (`
WITH query1 AS (SELECT * FROM entries)
WO earth_box (ll_to_earth ($ 1, $ 2), $ 3)
@> ll_to_earth (Listings.lat, Listings.lng)
AND fruits> = 4 $
AND active = TRUE
ORDER from created_at ASC
LIMIT 100 OFFSET $ 5 :: smallint)

SELECT query1. *, Favorites.user_id is not null as is_favorite
from query1
left outer join favorites
on query1.id = favorites.listing_id
and favorites.user_id = $ 6`,

params
);
};

NOTE: Keyset pagination may be recommended in some cases. However, this is not required for the use case and the size of my app.

nginx – How do I configure Node.js ExpressJs for HTTPS?

I'm trying a Nginx, NodeJs, express route that works properly on a server instance (Digital Ocean).

So far this is the situation:

What is currently working:
http://api.xxxxxx.com - go to https and give "Welcome to nginx!" Page.
https://api.xxxxxx.com - gives "Welcome to nginx!" page
http://api.xxxxxx.com:3000/xxx/xxxxxxxxx/xx/xxx/xxx.xxx - returns the file byte array.

What does not work:
https://api.xxxxxx.com:3000/xxx/xxxxxxxxx/xx/xxx/xxx.xxx - error. "This site does not provide a secure connection"

What I want to work:
https://api.xxxxxx.com/xxx/xxxxxxxxx/xx/xxx/xxx.xxx

I tried https for bin / www:

var https = required (& # 39; https & # 39;);
httpServer.listen (443);
httpServer.on (& # 39; error & # 39 ;, onError);
httpServer.on (& # 39; list & # 39; onListening);

However, this caused the WWW process to be halted incorrectly.

I'm obviously missing something. I refer to a series of tutorials and documents that bring me close, but not directly to what I need. And I'm new to all of these components, but I'm working with:

  • Ubuntu 16.04.5 LTS
  • ExpressJs 4.16
  • NodeJs 10.15.0
  • nginx 1, 10, 3

What additional steps do I have to take to
https://api.xxxxxx.com/xxx/xxxxxxxxx/xx/xxx/xxx.xxx Please for work

node.js – The post does not send data in the mySql table

I am new to programming and have tried to create a post that allows me to send data from an ancount form to a table (mysql database). The console.log (on the node node console displays an error) and I can not understand why the post is not working.

I get the error message saying that handshake can not be queued even though a handshake has already been queued. I googled, but I did not find a way to get the post started or fix it.

I appreciate any help.

const express = require (& # 39; express & # 39;);
const mysql = required (& # 39; mysql & # 39;);

// connect
const db = mysql.createConnection ({
host: & # 39; localhost & # 39 ;,
User: & # 39; root & # 39 ;,
Password: & # 39 ;,
Database: & # 39; nodemysql & # 39;
});

// Connect
db.connect ((err) => {
if (err) {
Throwing mistakes;
}
console.log (& # 39; MySql Connected ... & # 39;);
});

const app = express ();


app.get (& # 39; / & # 39 ;, function (req, res) {// nome da minha URL req (é ve que / / / / response response response response response)
res.sendFile (path.join (__ dirname + & # 39; / public / index.html & # 39;));
})

app.get (& # 39; / log_in & # 39 ;, function (req, res) {// Nome da Minha URL
res.sendFile (path.join (__ dirname + & # 39; / public / signin.html & # 39;));
})

app.get (& # 39; / register & # 39 ;, function (req, res) {// Nome da Minha URL
res.sendFile (path.join (__ dirname + # / public / register.html & # 39;));
})

// create DB
app.get (& # 39; / createdb & # 39 ;, (req, res) => {
let sql = & # 39; CREATE DATABASE IF NOT EXISTS nodemysql & # 39;
db.query (sql, (err, result)) => {
if (err) throw errors;
console.log (result);
res.send (& # 39; database created ... & # 39;);
});
});

// create table
app.get (& # 39; / createusertable & # 39 ;, (req, res) => {
let sql = # CREATE TABLE user (id int AUTO_INCREMENT, name VARCHAR (50), last name VARCHAR (50), email VARCHAR (100), password VARCHAR (100), telephone VARCHAR (50), country VARCHAR (100), VAT number VARCHAR (9), address VARCHAR (150), PRIMARY KEY (id)) & # 39 ;;
db.query (sql, (err, result)) => {
if (err) throw errors;
console.log (result);
res.send (& # 39; created table created ... & # 39;);
});
});

db.connect (function (err) {
if (err) return console.log (err);
console.log (& # 39; conectou! & # 39;);
createTable (connection);
})

app.listen (& # 39; 3000 & # 39 ;, () => {
console.log (& # 39; server started at port 3000 & # 39;);
});


app.use (express.static (& # 39; public & # 39;))
const bodyParser = required ("body parser");

app.use (bodyParser.urlencoded ({
extended: true
}));

app.use (bodyParser.json ());


app.post (& # 39; / register & # 39 ;, function (req, res) {
console.log (req.body.user.name);
let post = {name: req.body.user.name, last name: req.body.user.lastName,
Email: req.body.user.email, Password: req.body.user.password, Phone: req.body.user.phone,
country: req.body.user.country, VAT No .: req.body.user.nif, address: req.body.user.address};

let sql = & # 39; INSERT INTO user SET? & # 39 ;;
Let query = db.query (sql, post, (err, result)) => {
if (err) throw errors;
res.redirect (303, & # 39; / & # 39;);

});
});

openssl – problem with the configuration of ssl and nodejs

Intent to create an installation and a program that contains Bitcoinjs-lib and bug fixes in a number of bugs and troubleshoot a configuration file for configuring SSL.

michel @ michel-H81M-DS2: ~ / programacion / bitcoinjs examples $ npm i bitcoinjs-libnode: /lib/x86_64-linux-gnu/libssl.so.1.0.0: No version information available (required by node)
node: /lib/x86_64-linux-gnu/libssl.so.1.0.0: No version information available (required for node)
node: /lib/x86_64-linux-gnu/libssl.so.1.0.0: No version information available (required for node)
node: /lib/x86_64-linux-gnu/libcrypto.so.1.0.0: No version information available (required for node)
node: /lib/x86_64-linux-gnu/libcrypto.so.1.0.0: No version information available (required for node)

> tiny-secp256k1@1.0.1 install / home / michel / programacion / bitcoinjs examples / node_modules / tiny-secp256k1
> Node-gyp reconstruction

node: /lib/x86_64-linux-gnu/libssl.so.1.0.0: No version information available (required for node)
node: /lib/x86_64-linux-gnu/libssl.so.1.0.0: No version information available (required for node)
node: /lib/x86_64-linux-gnu/libssl.so.1.0.0: No version information available (required for node)
node: /lib/x86_64-linux-gnu/libcrypto.so.1.0.0: No version information available (required for node)
node: /lib/x86_64-linux-gnu/libcrypto.so.1.0.0: No version information available (required for node)
node: /lib/x86_64-linux-gnu/libssl.so.1.0.0: No version information available (required for node)
node: /lib/x86_64-linux-gnu/libssl.so.1.0.0: No version information available (required for node)
node: /lib/x86_64-linux-gnu/libssl.so.1.0.0: No version information available (required for node)
node: /lib/x86_64-linux-gnu/libcrypto.so.1.0.0: No version information available (required for node)
node: /lib/x86_64-linux-gnu/libcrypto.so.1.0.0: No version information available (required for node)
gyp: call to & # 39; node -e "Required (& nb; nano & # 39;)" & # 39; has returned exit status 0 while in binding.gyp. when trying to load binding.gyp
gyp ERR! Configure error
gyp ERR! Stacking error: `gyp` failed with exit code: 1
gyp ERR! Stack on ChildProcess.onCpExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:345:16)
gyp ERR! Stack at emitTwo (events.js: 126: 13)
gyp ERR! Stack at ChildProcess.emit (events.js: 214: 7)
gyp ERR! Stack at Process.ChildProcess._handle.onexit (internal / child_process.js: 198: 12)
gyp ERR! System Linux 4.15.0-43-generic
gyp ERR! "/ Usr / bin / node" command "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "Rebuild"
gyp ERR! cwd / home / michel / programsacion / bitcoinjs examples / node modules / tiny-secp256k1
gyp ERR! Node -v v8.10.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not OK
npm WARN bitcoinjs-examples@1.0.0 No description
npm WARN bitcoinjs-examples@1.0.0 No repository field.

npm ERR! Code ELIFECYCLE
npm ERR! Erno 1
npm ERR! tiny-secp256k1@1.0.1 install: `node-gyp rebuild`
npm ERR! Termination status 1
npm ERR!
npm ERR! Error during installation script tiny-secp256k1@1.0.1.
npm ERR! This is probably not a problem with npm. There is probably additional logging issue above.

npm ERR! A complete log of this run can be found in:
npm ERR! /home/michel/.npm/_logs/2019-01-16T12_58_03_653Z-debug.log

Alguna idea of ​​the Puedo-Seguir ?, he is given by different providers in the price, without trying to connect with the other

node.js – How can I properly close a stream in nodejs?

While playing around with streams and buffers, I came across a problem:

I have written the following stupid program:

const net = required (& # 39; net & # 39;);
const stream = required (& # 39; stream & # 39;);

Class MyReadable extends stream.Readable {
Constructor (options) {
great (options);

}

_read (size) {
let value = Math.floor (Math.random () * 10);
this.push (value> 8? null: value.toString ())
}
}

const server = net.createServer ((client) => {
const readStream = new MyReadable ()

readStream.pipe (client)
client.pipe (process.stdout)
readStream.on (& # 39; end & # 39 ;, () => {
console.log (& # 39; done & # 39;)
client.destroy ()
readStream.destroy ()
})
})

server.listen (7000)

And I get these warnings:

(Node: 1919) MaxListenersExceededWarning: Possible memory leak detected on EventEmitter. Added 11 error listeners. Use emitter.setMaxListeners () to increase the limit
(Node: 1919) MaxListenersExceededWarning: Possible memory leak detected on EventEmitter. Added 11 unpipe listeners. Use emitter.setMaxListeners () to increase the limit
(Node: 1919) MaxListenersExceededWarning: Possible memory leak detected on EventEmitter. Added 11 drain listeners. Use emitter.setMaxListeners () to increase the limit
(Node: 1919) MaxListenersExceededWarning: Possible memory leak detected on EventEmitter. 11 added near handset. Use emitter.setMaxListeners () to increase the limit
(Node: 1919) MaxListenersExceededWarning: Possible memory leak detected on EventEmitter. 11 listeners added. Use emitter.setMaxListeners () to increase the limit

I think I may not close any objects that I create, or I create that read stream at the wrong place. But those are just guesses, and I have added readStream.destroy () and that did not seem to help.

I miss something big here, but I do not know what. Where and how should I close the stream? Am I doing it bad at all?

node.js – Expected handle error in Firebase command

I have Node.Js installed to use the Firebase tools in my console. For a project I gave the command npm install -g firebase tools I was successful until then. However, if you enter the command firebase login me, a syntax error is thrown. I do not understand why this error occurs because the syntax of the file is sent directly from the server. The picture looks like this: Insert here the description of the picture

Multiple queries via router in Nodejs

I'm doing this to try to send multiple queries from a single get, but I do not know why I get that. I do not know if what I propose is possible.

router.get (& # 39; / profile & # 39 ;, isLoggedIn, async (req, res) => {
const admins = await pool.query (Select * from users where admin = 1 & # 39;);
const left = await pool.query (* choose * from the order of links to create_at desc & # 39;);
res.render (& # 39; left / profile & # 39 ;, {left}, {admins});

});

If I'm using a single query, that's if I only send admins or only links if everything happens.

express-handlebars / lib / utils.js: 26
Callback (zero, value);

TypeError: Callback is not a function

node.js – Allows the use of "mysql com nodejs"

Levantei com docker container MySQL

docker run --name mysql-docker -e MYSQL_ROOT_PASSWORD = Password -d -p 3306: 3306 MySQL

Porém and others Tentar Conectar about knots

Node index.js

Ocorre o seguinte erro

                {Error: Connect ECONNREFUSED 127.0.0.1:3306
at Object._errnoException (util.js: 992: 11)
at _exceptionWithHostPort (util.js: 1014: 20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js: 1186: 14)
--------------------
at Protocol._enqueue (DIRETORIO DO PROJETO  node_modules  mysql  lib  protocol  Protocol.js: 144: 48)
at Protocol.handshake (DIRETORIO DO PROJETO  node_modules  mysql  lib  protocol  Protocol.js: 51: 23)
Connection.connect (DIRETORIO DO PROJETO  node_modules  mysql  lib  Connection.js: 118: 18)
at object. (DIRETORIO DO PROJETO  api  index.js: 13: 12)
at Module._compile (module.js: 652: 30)
at Object.Module._extensions..js (module.js: 663: 10)
at Module.load (module.js: 565: 32)
at tryModuleLoad (module.js: 505: 12)
at Function.Module._load (module.js: 497: 3)
at Function.Module.runMain (module.js: 693: 10)
code: & # 39; ECONNREFUSED & # 39 ;,
errno: "ECONNREFUSED",
syscall: & # 39; connect & # 39 ;,
Address: & # 39; 127.0.0.1 & # 39 ;,
Harbor: 3306,
fatal: true}

arquivo index.js

const mysql = required (& # 39; mysql & # 39;);
const connection = mysql.createConnection ({
host: & # 39; 127.0.0.1 & # 39 ;,
Harbor: 3306,
User: & # 39; root & # 39 ;,
Password: & # 39; Password & # 39 ;,
});

Node.js app to track the dynamic IP address of the Dell Edge Box?

I have Dell Edge box, which is stored in a different location, the edge box has 4G SIM card Internet access with dynamic IP address, which changes frequently I will not be able to get the updated IP address of the To know the edge box. How can I track the IP address with a microservice using node.js?
Thakns in advance.
Seham.