How to use sequelizejs in the browser? - client-side

Is it possible to use sequelize on the client side? Are there solutions for that?
Knex.js runs quite fine with the websql provider, is there a way to use sequelize the same way or with another adapter?

Related

Is a direct connection between a react native app and firebase realtime database good practice?

I am building a small mobile app with react native.
My initial thoughts were, that it is safer to communicate with the database over a running nodejs backend server in order to avoid security risks due to direct connection between mobile and DB.
Now i want the clients to receive realtime updates from the DB and the only way that i can think of, is to connect the mobile app to the firebase realtime database and subscribe to changes without having any backend server between it.
Is this a good way to go or are there alternatives?
Whether something is a good way is typically opinionated. But it is definitely possible to build a secure app that directly accesses the database, because you can control access to the data with server-side security rules.
For more on this, I recommend checking out my answer to Is it safe to expose Firebase apiKey to the public?
It might also be useful to check this video where we live-code a secure voting app.

Can we call firebase as a server?

I am using firebase for storing data through android application. I want to architecture diagram for that application, so can I call the firebase as a server? I am trying to use client server architecture, so for the server, I write firebase as server. Is this correct?
Depending on how you use Firebase Realtime Database in your app, I'd indeed either visualize it as a server or as a database.
I find the latter especially useful if you still want to explain the nature of the app talking directly to a cloud-hosted database. Visualizing it as a server makes it easier to brush over that, so is a good option in cases where that is needed.

Can Amplify Authentication SDK can be used on server side?

I would like to use Amplify instead of amazon-cognito-identity-js in my lambda functions (to sync the cognito users with their profiles i store into another database).
On the client side everything works fine, but i am not able to use it on the server side.
I don't find any resources on the internet, and i am fighting since 2 hours trying to make it works, i start wondering if we are supposed to do that.
Does someone know how to configure Amplify by requiring only #aws-amplify/auth?
Auth.configure is not a function
Amplify Auth is actually designed to work with the browser. So it's not suitable for your lambda.
If you're using node then you will need to refer to the AWS SDK for JS instead.

How to establish a connection to DynamoDB using python using boto3

I am bit new to AWS and DynamoDB.
My aim is to embed a small piece of code.
The problem I am facing is how to make a connection in python code. I made a connection using AWS cli and then entering access ID and key.
But how to do it in my code as i wish to deploy my code on other systems.
Thanks in advance !!
First of all read documentation for boto3 dynamo, it's pretty simple:
http://boto3.readthedocs.io/en/latest/reference/services/dynamodb.html
If you want to provide access keys while connecting to dynamo, you can do the following:
client = boto3.client('dynamodb',aws_access_key_id='yyyy', aws_secret_access_key='xxxx', region_name='***')
But, remember, it is against best practices from security perspective to store such keys within the code.
For best security efforts use IAM roles.
boto3 driver will automatically consume IAM role if it is attached to the instance.
Link to the docs: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/iam-roles-for-amazon-ec2.html
Also, if IAM roles is to complicated, you can install and aws-cli and run aws configure on your server, and boto3 will use the key from here (less secure than a previous approach).
After implementing one of the options, you can connect to DynamoDB without the keys from code:
client = boto3.client('dynamodb', region_name='***')

Is it safe & possible to do almost everything on the cloud side with firebase?

I am using Firebase for my new project. This will be used on both Android and IOS. As you can guess I don't want to write the same code over and over again for both OS.
I am considering to code most of the work with Javascript on the cloud functions. In order to do that I need to use HTTP Requests to call my functions since firebase doesn't support any other way to call cloud functions.
There is two question in my head about this.
Is this possible and does it makes sense?
Since I've been using HTTP Requests all the time isn't that make my app open to listening with tools like Wireshark etc if there are multiple users on the same network? (I know Firebase now supports SSL but do I have to but a domain and license for that?)
What is the best way to do it in an engineer's perspective?
You can certainly move more of your app logic into Cloud Functions. But it's not really true that the only way to invoke a Cloud Function is via HTTP. You can also push data into your database to invoke a database trigger. I gave a talk on this at Google I/O yesterday about how I made a game with all the logic in Cloud Functions. You can watch it here.

Resources