Interop with Javascript libraries (I.e. NPM package AWS Amplify) - javascript

I want to interact with AWS services through a Flutter app, specifically through AWS Amplify library (Although I'm open to other recommendations).
I'd like to manage authentication with Cognito and call various AWS Lambda functions. This is very easy to do if I can interact with the library, but very difficult if I can't!
I know Dart has js interop and NodeJS interop packages, but their examples are bit opaque. The examples look like it generates Dart code (to use as a library) from JS, but the docs look like it just allows us to call Javascript functions from within Dart.
How can I do this?

In flutter, dart isn't compiled to javascript. So you can't use js interop and similar in the client side.
So what you're asking is not possible

Related

Using Netlify Serverless Functions With Parcel

I built a client-side modular weather app by using Openweathermap API and Javascript. Since it's client side it sends the API key to user. So I found Netlify's serverless functions to hide my API keys but couldn't figure out how to use it with Parcel. I use Parcel as a bundler and it seems impossible to me using serverless functions with Parcel. Because it bundles everything into one big file but serverless things should be seperated. I did some research and fortunately there are resources for serverless functions but couldn't find anything for that exact situation. So I'll be grateful if I find a solution for this problem.

Any starter kit or sample to use TypeScript in IBM Cloud Functions / OpenWhisk?

I am developing actions in IBM Cloud Functions and so far have used Node.js / Javascript and Python for coding. I haven't seen instructions on how to use TypeScript with IBM Cloud Functions.
What is the recommended way of using TypeScript, is it to deploy a Docker container or can I use it similar to (more or less) simple JavaScript actions? Any starter packages or samples?
I found the following guidelines so far:
This blog describes using TypeScript in a Docker container with OpenWhisk / IBM Cloud Functions
A second approach is to directly compile and bundle TypeScript actions using webpack and deploy via wskdeploy. It is described in this IBM Cloud Functions TypeScript Starter and the related blog on building IBM Cloud Functions with TypeScript. It even has instructions on unit testing with Mocha.

How to organize Javascript project to allow sharing of code between client SPA and Node server

I am developing an application which comprises a SPA front end and a Rest back-end.
To implement the Rest back-end I am using Node and Express.
Considering that both front-end and back-end are written in JavaScript (and TypeScript), I would like to share some code between these 2 parts (namely Interfaces and simple utils).
So basically my project is composed of three parts: Client, Server, Shared. Therefore I am inclined to have a project directory structure similar to this:
ProjecFolder
ClientFolder
.....
ServerFolder
.....
SharedFolder
.....
I am looking for suggestions on how best organize my project. I have done some research and I have found this interesting article which suggests to use a mechanism based on Gulp tasks that copy all files from SharedFolder into both ClientFolder and ServerFolder and then runs transpling.
I am wondering whether there can be an alternative approach or tools that perform what otherwise has to be configures as Gulp workflow.
My recommendation is to use a package manager tool. When you have dependencies, and the requirements of the server changed, you have to change the module. You don't want the SPA (frontend), to break, when you need to make changes to the server.
This is why package managers give you versions. Each module that depends on your shared code, can use a different version of it. You can use NPM for that. Build a module, publish it, and install it on your frontend and backend.
Many times, in production you split the frontend and backend. The frontend may exist in a file storage system (S3, Google Cloud Storage and similar), and the backend executed on your servers. Then it will be harder to use the same files on both systems.

use nodeJS module without nodeJs

it can look like a very simple question, but as a JS beginner, I would like to know if it was possible to use a NodeJS module (I would like to use this one for exemple : https://github.com/yaronn/xml-crypto) in a webextension without having to change it's code.
Thanks in advance.
I am the author of xml-crypto. xml-crypto is built for node.js and relies on the node.js crypto built in module which is not available for browsers. However there is an alternative browser crypto module called forge. Someone told me they were able to replace xml-crypto dependency in crypto with forge (by making small code changes in xml-crypyo) and that allows to run xml-crypto in a browser. You would also need to use browserify which should be easy here.

Javascript library for both the browser and node

I want to write a javascript library that works like an SDK for an external API.
Ideally this library could be used both for frontend projects, in the browser and for backend projects using node.js.
Initally I wasn't considering node so I was planning to require jquery as a dependency for using the ajax functions (for making the API calls) and deffered objects, but now I have second thaughts.
Considering that my goal is to have the same code base for both scenarios what do you think I should do? Is using the jquery npm package a good idea, or do you have other suggestions?
You can use the jquery package from the npm repo without problems.

Categories