How can I generate image with Nodejs - node.js

I've made dynamic image generate service like this https://dummyimage.com/ by PHP.
now I'm thinking of make a dynamic image generator with nodejs.
but it's not as easy as thought.
what kind of module can I use for dynamic image generate?

Another possibility is to use the pureimage package which is a pure JavaScript implementation of the HTML Canvas 2D API for NodeJS. It has no native dependencies.

you may use this node module for generating random images. https://www.npmjs.com/package/js-image-generator

I created a thing that generates images from a "function app". Hosting this on Azure costs me only "pennies per month".
You can copy my code and repurpose it. (also function apps support using javascript, which would work similarly)
https://github.com/djangofan/chord-bars

Related

How to create low code based workflow setup in nodejs?

I want to create a workflow automation where an activity comes in and user can setup a multilevel workflow.
For frontend i am using https://reactflow.dev
How to structure things in nodejs backend. Things like database, accessing control flow statements, statements which requires crons.
You also may want to have a look at node-red.
It's an open-source product that does exactly that.
There's a set of built-in nodes.
You can develop your own nodes, or import 3rd party ones. Which are stored in NPM.
You can also just create a node with javascript or typescript code in it, on the fly.
You should check Flumejs: https://flume.dev/
https://flume.dev/docs/quick-start/
Also you should see this code sandbox example. Try to read the code
and all the dependencies: https://codesandbox.io/s/node-based-code-generation-test-forked-ll9flz?file=/src/App.tsx
I hope you find this helpful.

Yesod - shared types between server and client

I'm used to working with Dart, where sharing types between server and client is as simple as importing the relevant packages into your project.
Can something similar be accomplished with Yesod/Haskell? Should I use GHCJS for the client? Maybe Elm? The goal is not having to worry about the data getting mangled in transit between server and client - and also not having to write a single line of JS. :o)
I haven't been able to find any good, beginner friendly docs on how to best tackle this challenge using Haskell. I suspect I just haven't looked in the right places. Any and all help is more than welcome.
To achieve this with GHCJS you can just build your project out of three core packages in this fashion:
frontend - something based on ghcjs-dom, I like Reflex-dom
backend - use your favorite framework, I like Snap, Yesod should work just the same
shared - code shared between frontend and backend
Where frontend and backend both depend on shared of course. Frontend is compiled with GHCJS, backend with GHC.
If you would like to see a complete example I would highly recommend studying hsnippet. Take a look at WsApi.hs where a set of up and downstream messages is being defined. All the JSON instances are derived in one place and imported in both frontend and backend.
Hsnippet uses websockets. This is not a requirement of course. You could use regular XHR in your own app. The principle stays the same. You define your API and serialization instances (usually JSON) in the shared package and import the relevant modules in both frontend and backend.
Personally I also share validation code, database entity definitions generated with persistent etc. Once you set it up sharing additional stuff is mostly a copy paste to one of the shared modules and then import wherever.

is it possible to use the gatsby static site generator with reactrb?

So, I'm basically still pretty new to the whole npm/react.js (let alone react.rb) ecosystem, and I'm wondering if it would be possible to use reactrb with the gatsby static site generator.
I've been attempting to get opal/reactrb support through opal-webpack, but have been running into some issues (see this issue for some backstory https://github.com/cj/opal-webpack/issues/36). Specifically where I got stuck was trying to get it to play nice with bundler.
Is combining reactrb components with gatsby something that's even feasible? I'm hoping the answer is yes.
Sorry for the very late response. Reactrb has been renamed ruby-hyperloop and yes, you can certainly use it with Gatsby and any static site generator. The Hyperloop website is built with Middleman for example.
The best way to integrate Hyperloop into a static site generator is by using Hyperloop.JS https://github.com/ruby-hyperloop/hyperloop-js which has not server footprint at all.
Please see the Hyperloop website for examples and tutorials: http://ruby-hyperloop.io/
You can fetch data into Gatsby form any kind of source. You need to create a source plugin. The answer from #BarrieH is accurate, but could be slightly misleading.
You cannot query directly from an external GraphQL API into a component. Gatsby works by loading all your data into its own nodes system, then you pull data from those nodes into your components. This is what allows Gatsby to compile your data to static JSON files on disk, pre-fetch data for other pages, and so on.
Here's the relevant docs:
https://www.gatsbyjs.org/docs/create-source-plugin/

securing the source code in a node-webkit desktop application

first things first , i have seen nwsnapshot. and its not helping.
i am building an inventory management system as a desktop app using node-webkit . the project being built is using compoundjs (mvc javascript library). which have a definite folder structure (you know mvc) and multiple javascript files inside them.
the problem is nwsnapshot allows the app to have only a single snapshot file but the logic of application is spread over all the folders in different javascript files.
so how do i secure my source code before shipping it to client? Or any other work-around Or smarter way (yes, i know about obfuscating).
You can use nodewebkit command called nwsnapshot to compile the javascript code into binary which will be loaded into the app without specifying any js file
nwsnapshot --extra-code application.js application.bin
in your package.json add this:
snapshot: 'application.bin'
It really depends on what you mean by "secure".
You can obfuscate your javascript code fairly well (as well as potentially improve performance) by using the Google Closure Compiler.
I'm not aware of any off-the-shelf solutions to encrypt/decrypt your javascript, and honestly I would question the need for that.
Some people think they need to make it impossible to view their source code, because they're used to dealing with compiled languages where you only ship binaries to users. The fact is, reverse-engineering that binary code was never as difficult as some people think it is, so if there's any financial incentive, there is practically no difference between shipping source code and the traditional shipping of binaries.
Some languages have offered genuine encryption of deployed assets, such as Microsoft's SLPS. It seems to me that the market for this was so small that Microsoft gave it to a partner (just my view). The truth is that most customers are not interested in taking your source code; they're far more interested in your ability to service and support that code in an efficient manner, while they get on with their job.
You may consider to merge the JS files into one in the build process and compile it.

Sharing a class between Node.js and the browser

If i have a class, what is the best way to share that class and use it in both the browser as well as Node.js?
For example a game that uses a 2D Vector math class on both the client-side and the node.js.
NowJS is a pretty elegant way to share variables and functions between client JS and Node JS through an automatically sync'ed shared namespace.
There's also dnode, which the author comments on in response to a posting about NowJS here: http://news.ycombinator.com/item?id=2316079
Also, Haxe, a language that lets you write using the same language for the browser and the server.
Take a look at NowJS, which should do what you want.
Write it as CommonJS/Node.js module, so it works normally in Node.js, and then pack written module for browser using Webmake. It's simplest way to share same codebase on both sides

Resources