Initialization in node.js || How to handle initial configuration in node.js - javascript

I recently transited from Java to JavaScript specifically MEAN Stack Development. I want to make API in node.js such that it initializes all configuration upon deployment like init method in Servlets.
If there is any other standardized way to accomplish this task kindly guide me.

You have to go with Loopback is a highly-extensible, open-source Node.js API framework.
Features
Quickly create dynamic end-to-end REST APIs.
Connect devices and browsers to data and services.
Use Android, iOS, and AngularJS SDKs to easily create client apps.
Add-on components for push, file management, 3rd-party login, and geolocation.
Use StrongLoop Arc to visually edit, deploy, and monitor LoopBack apps.
StrongLoop API Gateway acts an intermediary between API consumers (clients) and API providers to externalize, secure, and manage
APIs.
Runs on-premises or in the cloud
How to install - To install this, simply run the following given command.
$ npm install -g strongloop
Hope this will help to resolve your query !!

You could look at Swagger which provides many tools for configuring, representing and validating a RESTful API.
There is a swagger-node module which, after defining your JSON API schema, can automatically configure your API for you.

Related

The difference between AWS Amplify and amazon-cognito-identity-js?

I'm reviewing this demo of how to integrate Cognito with Angular, and it amazon-cognito-identity-js for the authorization service.
It seems that is what we should be using, but other tutorials install AWS Amplify as a whole:
npm i aws-amplify
Curious what the difference is and whether one is more current than the other?
amazon-cognito-identity-js used to be a separate package specifically for Cognito. Recently they've been bundling all their SDKs into Amplify to streamline the integration process.
For instance in our iOS app the Cognito SDK had a number of issues that were resolved by moving to Amplify.
As you can see in the link below, this package is now maintained in the Amplify umbrella.
https://github.com/aws-amplify/amplify-js/tree/master/packages/amazon-cognito-identity-js
It used to be standalone here:
https://github.com/amazon-archives/amazon-cognito-identity-js
I would recommend going forward with Amplify as that is the direction that AWS development is headed internally, and amazon-cognito-identity-js is maintained as part of Amplify anyway.
To add to the great answer by #DaveS. There are 3 official tools you can use to integrate Cognito in your app:
Amplify
Use it in client-side applications, where you'd use Amplify anyway - to leverage the premade auth UI components or to integrate with other services from the Amplify ecosystem: APIs, Analytics, Storage, etc.
Does not support secret-enabled Cognito app clients.
Cannot make authenticated (requiring AWS credentials) Cognito API calls (e.g. adminCreateUser) directly, but there's a workaround.
amazon-cognito-identity-js
It is a much smaller package and it comes as a part of Amplify (hosted in the Amplify monorepo).
It can still be used separately if you don't need any of the extra features provided by Amplify (save on the bundle size).
Does not support secret-enabled Cognito app clients.
Cannot make authenticated (requiring AWS credentials) Cognito API calls, e.g. adminCreateUser.
Can be used in the backend (unauthenticated Cognito APIs only).
AWS SDK
Low-level as it can get.
Provides access to all (authenticated and non-authenticated) Cognito APIs. For authenticated, make sure the code has access to AWS credentials.
Can work with secret-enabled Cognito client apps (you need to sign the requests with the secret).
Can be used in both client (for unauthenticated APIs only, otherwise you're exposing secrets) and server applications.
Code samples for all 3 can be found here: AWS Cognito: Amplify vs amazon-cognito-identity-js vs AWS SDK.

ReactJS Production Deployment

I currently have production web app (PHP+AngularJS) & Java/Spring backend. Basically it is a web app making lots and lots of REST Api calls to Java backend and rendering that data on web forms. I use Apache Web 2.0 to host the frontend and Tomcat for the backend
Planning to migrate to ReactJS, Java/Spring will still be the backend. I need some guidance on following
Best Web Server to use to deploy React (Build/Deploy controlled through CD/CI, Jenkins)
Any specific frameworks and/or components that needs to be added and installed to support this web app.
Best Testing framework to use for React which will work with the CI/CD pipeline.
Can all this be containerized (docker/kubernetes) ?
Thanks in advance
Any server that servers static files (express, apacha, nginx, etc) can handle a react app.
You'll need webpack to build the project (transpile/minify/optimise)
You'll need a test runner (i suggest jest from facebook) and a library to test/render you application on each unit test. Use react-testing-library (simple, dynamic and easy to use).
Totally!

How to deploy Node.js REST API to production mode

I've created a REST API using Node.js and Express, so now I need to share it and publish it on a server in order to connect from Front-end.
Can you tell me a proper way to do it?
You could use Heroku for deployment, this way you can know how your app will fare. It's free moreover.
If you're satisfied with it then you can go ahead and buy a dyno or use other platforms like Azure or AWS.
To learn more on how to deploy your existing app to Heroku, visit this page.
The question you are asking is very broad. It can be done in a lot of ways. For me this 2 part tutorial was very helpful:
https://hackernoon.com/tutorial-creating-and-managing-a-node-js-server-on-aws-part-1-d67367ac5171. However, this only covers the installation on AWS EC2. This doesn't differ much from deploying it to Google Cloud, Azure or something local.
In general you need to fix the following steps:
1) Create a server somewhere (local or in the cloud)
2) Install all the stuff to run your app. In your case Node.js at least
3) Put a copy of your app on the server
4) Run it with node
5) Go to the ip of the server
The tutorial gives more details. DISCLAIMER: If you actually want to use this in production there is way more to consider. For example, security policies, setting up proxies, installing certificates etc. Please read up on that properly before you start running production apps.
You can install node on the the production server and then where the project is situated just .
copy that path
Open the Cmd >>
Enter "cd copied path .>>enter
you npm will be install & REST Api will Work.

Twilio Client Javascript SDK

I'd like to know why there isn't a npm / yarn package to Twilio Client Javascript SDK 1.4.
I'm trying to use their voice service, following this tutorial, but in React Native.
Is this package for browser usage only? How could I have access to Twilio.Client on react-native?
I already implemented a programmable-chat with success, using the provided packages twilio-chat and twilio-common.
Meanwhile, is there any way of importing a remote file or using a local javascript file (twilio.min.js) to a react-native app?
Thanks in advance.
EDIT:
Further research lead me to believe that this SDK only work for browsers since it has to deal with audio events, connection status etc.
Correct me if I'm wrong.
I'm now trying to implement react-native-twilio-programmable-voice
.

API Gateway Javascript SDK - Node Js Examples?

So The API Gateway Javascript SDK is great to use in the front-end environment, but since the 10+ script files are required to be available globally, this does not play very nicely in an environment where most developers are used to importing npm packages.
Is there an example of anyone using the API Gateway SDK in backend Node.js environment? Here you cannot put the 10+ scripts in index.html file and I keep getting errors and when I try to make these files globally available for the SDK in Node environment.
There are two AWS SDKs for JavaScript. Use the one for node.js linked in the comment from MaiKaY. And here is the reference for the API Gateway portion of the SDK - http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/APIGateway.html

Categories

Resources