NestJS best way to call an API every day at 12 AM - nestjs

I need to call an API every day at 12 AM. How can I achieve this using NestJS. Any leads, please?

Have you read through the docs? Seems like this is exactly what you're looking for using a CRON expression.

Related

What Formula to use for this task?

So for a recent interview I was given a set of tasks to carry out on a workbook. I'm now going through the tasks that I couldn't understand or complete. I was wondering if anyone could help me through it or know a site maybe better suited for this sort of thing?
Question
Dataset
So here's the original formula:
=IF(E2="national","10",IF(E2="local","25",""))
And they want you to reprice local calls so they're 5p per minute with a price cap of 25.
Easiest way to do that is to nest another IF statement:
=IF(E2="national","10",IF(E2="local",IF(K2>5,"25",K2*5),""))
In the future, please write a question title that others will be able to easily search for when they have the same issue.

Node.js with Twit - AND Operator issue

I am having an issue getting the twit node.js bot to recognize multiple parameters when attempting to RT when it is both a listed user in the code, as well as containing a specified hashtag.
var stream = bot.stream('statuses/filter', {follow: approved_users, track: '#somehashtag'}
While this seems to work on an either/or basis how can this me modified so that it is an AND condition?
I've been looking through the documentation, and while I am assuming this should be a relatively simple fix I am not familiar enough with node.js to recognize immediately where the issue is.
Any help on this would be greatly appreciated!
Per the Twitter documentation, it is not possible to AND these filter types:
The track, follow, and locations fields should be considered to be
combined with an OR operator. track=foo&follow=1234 returns Tweets
matching "foo" OR created by user 1234.
The only way you'd be able to do something more complicated in real time would be to use the enterprise PowerTrack API, which is a commercial offering.

Node Red Global Process

Sorry if this is a newbie type Q but after much searching I cannot find the answer. I am trying to understand how to write a process (function?) that I can call from any flow in Node Red. Every time I search "global function" the (web / blog) results want to teach me how to write a simple function in a flow. I've got that in spades. I'm sure the answer is simple, just finding it doesn't appear to be. Closest I got is writing it in settings.js but no clear examples to give me confidence.
As one simple example, I use a timestamp that is in easy human readable form (12 hr am/pm) for logging. Currently I have to write a time stamp procedure (new Date) in each flow before writing it to the log file. I'd like a one-liner in each flow that calling a global function I write that every flow can access. TIA

Open Street Map: how retrieve amenity in Postman?

Since Google Places API became a hell I'm trying to move to Open Street Map. I'm learning how to call amenity with Postman.
For example using this URL I try to retrieve all the toilets in Auckland:
http://nominatim.openstreetmap.org/search?format=json&q=toilet Auckland
But as result I have just 10 pleace_id and I'm using search.
I think I'm doing things wrong.
How can I retrieve all toilets in Auckland?
Is there any example about how to use amenity=toilet, country=NZ, city=Auckland instead of the generic search?
My goal is to improve the precision of my requests.
I have a good and a bad news.
Good news: I finally found an example about how to query Overpass API and I could retrieve what I think are most of the cinemas in France:
http://overpass-api.de/api/interpreter?data=area[name=France];node(area)[amenity=cinema];out;
(I still don't get how to insert way and rel into the call)
Bad News: apparently there are no cinemas in Italy:
Tanks a million to #mmd which helped me dig deeper into Overpass API and REST calls.
EDIT: I found how to add node, way and rel:
http://overpass-api.de/api/interpreter?data=area[name="Heidelberg"]->.a;(node(area.a)[amenity=hospital];way(area.a)[amenity=hospital];rel(area.a)[amenity=hospital];);out;

Realtime: Node.js, MongoDB and Redis?

Okay, first of all I want to tell you that I am new to all this techniques mentioned in the title.
I want to make an new app. Think of it as a real time trading engine (like for stocks for example).
So, there are two things that really matter:
Speed / Performance: Everyone has to see trades in realtime
Security: Same trades can be made simultaneously but only one can be successful
I thought about an approach like this:
If a user wants to buy 10 peaces of stock X for $100 each he places an order which I store with Redis (speed) and push it to all clients with socket.io. Well, as soon as another user wants to sell 15 peaces for $100 the script should check if there is an open buy order. If so, it saves it as a successfull transaction in MongoDB (persistance) and closes the buy order of 10 peaces.
In this example 5 peaces are left. The script would display that with a calculation like this: 15 (sell at $100) minus 10 (buy at $100) equals 5 left. Every time someone want's to trade something this calculation would be made because I don't know how many stocks are left for trading else.
Edit: Or I could subtract 10 peaces of the 15 peaces in Redis so that I don't need to calculate every time. But if something would go wrong, I wouldn't know what the original data was. That's a problem.
Now the questions are:
Would you make it like this? Better ideas maybe?
What would happen if two users make the exact same order in the same time? Could it happen, that it gets stored two times in MongoDB as different successfull transactions? Of course you could run an audit over Redis and MongoDB and compare it. But that would be a horrible solution.
Hope you understand what I'm trying to ask. Thanks in advance!
First of all if you do not know anything from the stack you are using, it is not a good idea to tell I need high performance (high availability, good security and so on). Being absolutely new to all the tools you are using you should be happy if it will just work.
As for your question: first of all take a look how other people have done similar things. Here is an open source bitcoin trading engine which uses node.js which makes it an excellent example to study (it is complex, so take a deep breath). If you want to use mongo you need to know that it does not support transactions, so you need to take a look how to implement them by yourself there. These two examples are really good in explaining it.

Resources