Google apis for NodeJS - node.js

Am trying to build a server on NodeJS, I want to create a n api the simply takes two points and uses a google api and creates a route, I got lost in web, any recommendation for tutorials is appreciated

What you need here is a Direction API or Direction Service, it can calculate directions (using a variety of methods of transportation) by using the DirectionsService object. This object communicates with the Google Maps API Directions Service which receives direction requests and returns an efficient path. You may either handle these directions results yourself or use the DirectionsRenderer object to render these results.
The Directions service can return multi-part directions using a series of waypoints. Directions are displayed as a polyline drawing the route on a map.
Here are the sample jsfiddle for it.
http://jsfiddle.net/gHK7s/2/ and http://jsfiddle.net/user2314737/u9no8te4/
Now, to connect it with the Node.js that you want, you can check these SO questions on how to do that.
Using Node.js to connect to a REST API
Cannot connect to Google Directions API with Node.js server
For more information, check this Node.js Client for Google Maps Services

Related

How can I get Events from Hikvision camera to my Typescript project and is there any documentation on the camera's internal API?

I have a project where I need to get events from the Hikvision camera that I've connected on my network, to my Typescript project's code.
The events in question are face detection and alarm triggered by recognized face.
The events then would go through webhook in the code and call corresponding functions to send the information to my front-end application.
I know there is an internal API (actually ISAPI) built into the camera, and I know that there are at least 2 endpoints called:
/ISAPI/Intelligent/
and
/ISAPI/Event/
There surely are lots of different endpoints under there.
However, I can't find any documentation for this API / ISAPI even from Hikvision's product support website.
There 3 PDF-manuals on the product support page and none of them mention API or endpoints.
Are there any documentation of these API endpoints for Hikvision cameras?
This question does not solve my case (I already know how to authenticate)
Ok, turns out you can setup a webhook on your Express server app and point the camera's http-listening towards the app's webhook endpoint.
The http-listening is done from the camera's internal software that lives at the camera's IP-address.

Rest API that calls a SOAP service

I'm a student who's newbie to the world of APIs and I'm working on an assignment where I have to create a NodeJs rest API that would call a SOAP service, transfer the XML response into a JSON object and return it to my angular project that calls this API.
I have looked around and found very little information about this, so is there a good place for me to start (Tutorial, courses, etc..) ?
looking forward to receiving answers because my passing grade is on the line :( </3
You need to break up this problem into multiple steps.
How do we make a rest-api in nodejs?
See a link like: https://www.codementor.io/#olatundegaruba/nodejs-restful-apis-in-10-minutes-q0sgsfhbd
OR How to best create a RESTful API in Node.js
How do we call a soap service from nodejs?
See e.g. SOAP Request using nodejs
How do we call our rest-api from angular?
https://angular.io/guide/http OR
Call Rest API From Angular Application
So break the problem up into steps, find the tutorials that help you implement that part, and put it all together.
Also use console.log and JSON.Stringify to debug your objects. E.g. see: https://levelup.gitconnected.com/5-ways-to-log-an-object-to-the-console-in-javascript-7b995c56af5a

External API Calls server or client side?

I'm currently working on an analytics webapp with a react frontend and node (express) backend.
Describing the functionality in a nutshell:
A user will be able to login on the website, search for a YouTube username and then the YouTube API is called, the data will be stored in a mysql db via my express API and also the data will be used to calucalte some statistics which afterwards are displayed in a dashboard.
Now I was wondering if I should:
Call the YouTube API from the frontend, i.e. inside my react code, do the calculations display them and and then store it in the DB via my express API.
Or, from the react app call an endpoint in my express API that will then call the YouTube API, store the data in the DB and then pass on the data to my react app.
Are there any best practices or up-/downsides to either approach?
When answering questions like these, it's important to remember that the client-side is different for each and every user that visits your website, their internet speed, their GPU & CPU power, etc., but the server is most commonly held in a stable container and much more powerful than a client.
The proper way would be the following:
1. Obtain a search query from a client
Meaning you should get the user's search query from an input, or any other form of control (text area, checkbox, etc.), this way client is doing the least business logic, as it should. The client should always focus more on UI / UX rather than business logic.
2. Send query to the server
Let the server use the query you've just obtained from client, call the youtube api from the server (either explicitly using Axios, or find a node.js youtube library), and do all the necessary calculation on the backend
3. Send processed data to the client
Let client receive the data in the form which is ready for use (iterations, mappings, etc.) - again separating concerns, server - business logic, client - UI / UX
Now to be fair, the example you have will most commonly be done all on the client-side, since it is not as computationally heavy as other enterprise examples, but this is a good rule to follow for big projects, and no one would really complain if you did it this way, since it would be the proper way.

Calling secured API from NodeJS Lambda

I have an API that is secured using OAuth (IdentityServer 4). I need to call this from an AWS Lambda function. I cant figure out how to do this in Node (noob to node). I can see an example of using oidc-client package but it seems to be designed for browser based clients. I just need the access token to call the api. Ive done this from a .Net console app, but Im lost in Node. Does anyone know of an example of doing this?
Thanks
#Jonesie have you tried example from AWS repository? Request you to take a look https://github.com/awslabs/serverless-application-model/tree/master/examples/apps/api-gateway-authorizer-nodejs

query mongodb using node and facebook token

I am using the Facebook SDK on a mobile app. After the login, I get a token (long string) from facebook. I want to use this to connect to a remove mongodb database and update or query the database there.
Am I correct in understanding that:
I need to run node.js on the remote server and then
make a connection from the app to the remote node.js, and then
have node.js query the mongodb
If yes, can someone please point me to a simple example that demonstrates this?
thanks!
What you require is API(mostly REST which understands JSON), much like the Facebook api your mobile app is already talking to. Your mobile app will also communicate with this API, which in turn connects to MongoDB and preforms desired operation.
Look here to get basic understanding of REST API
Look here for sample REST API implementation using nodejs.
I found a solution which is in line with what I need: http://www.quietless.com/kitchen/building-a-login-system-in-node-js-and-mongodb/

Resources