Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Jun 02 2020 06:16
    @ljharb banned @frank-dspeed
  • Apr 27 2018 01:23
    @MylesBorins banned @fjeddy
  • Feb 24 2016 08:26
    @rvagg banned @jonathanenbe
Jordan Harband
@ljharb
authoring ES modules is fine, but then you can use babel to transpile.
flyingCodeMonkeys
@flyingCodeMonkeys
Hi guys is anyone familiar with cheerio? i am trying to get the titles of webpages not sure how to select it though
Micule
@Micule
Hello everybody
Meir Shamay
@may215

Hi, I create a npm package that contains several utils for my project, one of the util is a patch to another npm package. Now, I don't know how to export and import the patch in order to use inside one of my projects. This is the example of the patch. file name: patch.ts inside my custom_npm_package

declare module 'node/module/to/patch' {
  interface Manager {
    saveOne<Entity>(entities: Entity, options?: SaveOptions): Promise<Entity>
  }
}

Manager.prototype.saveOne = function <Entity>(
  entity: Entity,
  options?: SaveOptions,
): Promise<Entity> {
  console.log('do things')

  return this.save(entity, options)
}

When this patch is inside the project I want to use it, it's working, I can call to saveOne method.

Kasir Barati
@kasir-barati

is there anyone who was deploy a node.js web application on heroku successfully?

I tried multiple times (with heroku CLI and connect to GitHub), I also removed the buildpack and add it again but no difference. Heroku seems could not deploy it successfully. would you like to help me?

This is the GitHub Repo: https://github.com/nodejsdeveloperskh/passport-lookup
and this is the Heroku log:

timestamp app[api]: Build started by user X
timestamp app[api]: Release v3 created by user X
timestamp app[api]: Deploy ecba21a1 by user X
timestamp app[api]: Scaled to web@1:Free by user X
timestamp app[api]: Build succeeded
timestamp heroku[web.1]: Starting process with command `npm start`
timestamp app[web.1]: 
timestamp app[web.1]: > passport-axios@1.0.0 start
timestamp app[web.1]: > node index.js
timestamp app[web.1]: 
timestamp heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
timestamp heroku[web.1]: Stopping process with SIGKILL
timestamp heroku[web.1]: Process exited with status 137
timestamp heroku[web.1]: State changed from starting to crashed
timestamp heroku[web.1]: State changed from crashed to starting
timestamp heroku[web.1]: Starting process with command `npm start`
timestamp app[web.1]: 
timestamp app[web.1]: > passport-axios@1.0.0 start
timestamp app[web.1]: > node index.js
timestamp app[web.1]: 
timestamp heroku[router]: at=error code=H20 desc="App boot timeout" method=GET path="/" host=passport-llokup.herokuapp.com request_id=da8ab014-3902-4d67-9004-c744059279c2 fwd="116.203.217.173" dyno= connect= service= status=503 bytes= protocol=https

But no response in the browser. whereas it sends me the correct response in the localhost

Lorenzo Sandini
@lsandini
Hello all, this might sound like a strange question, but here it is. Is it possible to trigger the server-side execution of a js script, by sending a HTTP POST request for example from a website or from another node app on a different server ?
Lorenzo Sandini
@lsandini
I'd like to pass a date (in the past or future) to my server using an express "app.post" route, on which a script executes a sequence of async functions resulting in a json file. That json file is served through an app.get route on the same server.
I guess I should write my functions as middleware, but since it is a complex sequence of events, calling functions from Typescript files, I am just too dumb to do it by myself...
Lorenzo Sandini
@lsandini
Executing the script manually with node -r esm myscript.js works fine.
Jordan Harband
@ljharb
yes, of course that's possible
why would it need to be middleware
everything on a node server is JS, so it's all functions
Lorenzo Sandini
@lsandini

Well I understand I can call a function like

var foo = function() {
  // do something
};

app.post('/', function(req, res) {
  console.log(req.body);
  res.send(200);

  foo();
});

... but can I call a whole script ?

Jordan Harband
@ljharb
what is a "script"
everything in node is a file, which is a module
so anything you require is running code
Lorenzo Sandini
@lsandini
Sorry, very new to this. On my server, I started a project in which the npm package "astronomy-bundle" is installed as a module. Then I wrote a "myapp.js" file importing functions from this bundle, and creating the json file that I need. That's where I am stuck. How can I "require" this myapp.js file/module, to be executed as such ? I Understand I can export its various functions using "module.exports", but can I execute the whole file in one step ?
Jordan Harband
@ljharb
node myapp?
Lorenzo Sandini
@lsandini
I appreciate your help, but isn't node myapp a bash command ? How can I trigger it in an express route ? That's where I am baffled...
Jordan Harband
@ljharb
@lsandini yes, it is. inside a node program, you'd require('./myapp') assuming it module.exports = whatever you want to pull in
Lorenzo Sandini
@lsandini
Aah yes I think I got it now. I modified my myapp.js adding the module.exports = ... and also corrected my "require" stuff in app.js. Now the functions I add in my app.post route are called when a POST request is sent to the server :)
Not still there yet, but progressing. I put the work in progress here https://github.com/lsandini/astro but more corrections are needed
"myapp.js" is called "all-mod.js" in my repo
Lakshman
@lakshmankashyap
How can handle big image upload and fetch project with node js optimisation.
Jordan Harband
@ljharb
@lakshmankashyap: i would have answered on irc, but you didn't auth with nickserv.
Lakshman
@lakshmankashyap
let me know how can auth
i start a project so I have no idea that what we use to handle heavy files in nodejs
Jordan Harband
@ljharb
find an npm package
but you can't just dive into any tech, including node - you have to learn it first
Lakshman
@lakshmankashyap
i have 7 year exprience
in nodejs
let me know what package and structure use
Jordan Harband
@ljharb
… i'm not sure how 7 years of experience would translate to those questions being reasonable. someone with a year or two of experience should know how to answer them (search npm for solutions)
Lakshman
@lakshmankashyap
thanks for remind
Lakshman
@lakshmankashyap
If I using pm2 on server so is that need workpool implementation on sever for handle high performance api task?
Htc Saj
@htcsaj123_gitlab
Hello.How to scrape specific word from different posts on subreddit using puppeteer
Lorenzo Sandini
@lsandini
I see questions and answers here, but very uncommonly the finished product, where the solution has been implemented. So here is my "I did this" entry. And thank you again Jordan for your helpfuls hints : https://astro6.herokuapp.com/
I wrote a little API to which you can POST a date, and it will return the heliocentric coordinates of planets, using the excellent "astronomy-bundle" npm package
The HTML interface is not what it's all about, I plan to send POST requests from another node app and retrieve the sama data in JSON format, like this https://github.com/lsandini/astro/blob/main/ask-api.js
mile-mijatovic
@mile-mijatovic
Hello
I am trying to reuse
const queryParam = (error, result) => {
  if (error) throw error;
  res.status(200).json(result);
};
1 reply
in customerController.js, like this
exports.get_all_customers = (req, res) => {
  const FETCH_CUSTOMERS = "SELECT * FROM Customers";
  db.query(FETCH_CUSTOMERS, queryParam);
};

exports.get_customer = (req, res) => {
  const GET_CUSTOMER_BY_ID = `SELECT * FROM Customers WHERE id = ${req.params.id}`;
  db.query(GET_CUSTOMER_BY_ID, queryParam);
};
4 replies
but I get an error - ReferenceError: res is not defined
I tried to rename resinto result
but then - TypeError: result.status is not a function
lintdeveloper
@lintdeveloper
Hi everyone, I deployed an express app with aws cognito for authentication but when I tried accessing it after deployment on ecs it doesnt work. What might be the issue
1 reply
RafaRed
@RafaRed
What are the best practices to wait for a blockchain number of confirmations and execute an operation in firebase via api? I'm working on a web3 application with a node.js server, I imagine doing this on the client side would be very bad as it would be waiting with the browser locked, but at the same time it seems costly on the server side, for how long it will be waiting for confirmations from several customers. I thought the node.js server would stack the requests in a queue [(hash,blockNumber), (hash,blockNumber)...] and until the queue is clear check for every update in the block, if it can be executed. would there be any better way?
2 replies
jerryphilips
@jerryphilips:matrix.org
[m]
No sense in blocking approved stuff with non-approved stuff blocking the way