Using Netlify Serverless Functions With Parcel - javascript

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.

Related

Lambda functions with ESM

First of all, I am a Node newbie, moved from PHP development, so the question may be dumb..
I am in the process of developing a webservice using node with ESM ("import" syntax).
Now I am trying to build some microservices to do background operation using Lambdas with SQS as a trigger and Serverless framework as a deployment tool..
Now that I deployed the first Lambda, I realised ESM syntax isn't supported by Lambda but all services / factories are in ESM syntax already..
What's the best way to manage this lambda function based on services in ESM syntax?
And how do you deal with the common services used in both web service and lambda package?
I don't want to duplicate to both projects in IDE if that makes sense.
Hence, I was hoping to place this serverless framework in the same folder and manage it from there, but unsure if this is the best way to move forward..
If I used 'Typescript', which I haven't had a chance to explore yet due to the deadline of the project, would I not have faced this issue with Lambda deployment?
With Serverless Webpack you can have both ESM and TypeScript support.
For common services, you can consider publishing them as packages, installing them directly from GitHub URLs or just place everything in the same repository and import them directly, whatever works best for you.

How do my Vuejs frontend and my node express backend interact with each other and do i need the vue-cli?

I am trying to build a simple website with nodejs, express and vuejs.
In tutorials i saw people recommending having the frontend and the backend communicate through an API by using the vue-cli. (example). 1. Do People use this method in production as well?
I also saw that you can build the vue cli files into a /dist folder and move this folder into the backend. Then you can use the backend to serve the generated index.html (example)
2. After doing this, is vue.js still communicating with the backend through the api i wrote with the vue cli for development?
3. Do i have to change code in the backend to deploy the website this way, other than statically serve the index.html file that was build by the vue-cli? and lastly 3.Can i just npm install vue and use the provided vue.min.js in a scripttag and just lose some usablillity while developing?
I hope my question is understandable and i appreciate every answer.
The backend typically serves the frontend via REST API.
Your Vue app is completely separate from your backend. Most applications keep business logic in the backend and use the frontend as a view. For smaller projects, you can keep the logic in the browser.
To answer your question directly: No, the Vue CLI is not used for that. It's purpose is to enhance your development process.
Relevant topics you should learn about: Representational state transfer (REST), Single page applications, Ajax
Advanced / less relevant topics: GraphQL, Server side rendering, HTTP, web sockets, MVC

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

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

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 Meteor without its templating library

I'm building an app that uses only Polymer to structure the frontend. As a backend I'd really like to use Meteor with their Mongo realtime database.
I only need the part of Meteor that implements the DDP prototcol and provides the Mongo API to the client. Is it currently possible to remove the rest of the client libraries? I don't need jQuery, Blaze, Tracker and so forth.
I've already tried removing meteor-platform from the project, then adding all the packages meteor-platform consists of. This results into errors like ReferenceError: Meteor is not defined. It seems like this is not supported currently.
What I then used was Asteroid which is really nice. But using it prevents me from using Meteor packages like GroundDB for example.
Reading on the Meteor website gives me the feeling that it should be possible to use only some parts of Meteor, but this doesn't work for me.
What's the best way to tackle this problem?
Edit: I've uploaded a leaderboard example with the failing setup on GitHub. Meteor.isServer is causing the error. If you comment out the server stuff it works.
You're missing two packages:
meteor add meteor underscore
The meteor package is the one that exposes Meteor.isServer.

Categories