Using a .NET class library in NodeJS app using Blazor - node.js

I have a .NET Standard project that includes a bunch of models and methods, and I want to use them in a NodeJS application written in TypeScript. All the samples I see for Blazor JavaScript interop integrate with JS through Razor files, but I couldn't find any samples that show how to integrate .NET code with NodeJS. Is this possible at all and if yes, how? Thanks!

This is not possible Client-side Blazor works only in browser and interop is only with browser JS, since it is browser who run WASM and JS inside themselves.
Previously you can theoretically integrate some NodeJS inside ASP.NET Core application using NodeServices, but they are would be obsolete in .NET Core 3. See https://github.com/aspnet/AspNetCore/issues/12890
If you want to run some code from Blazor inside NodeJS likely you have to create separate command line application and communicate between it and your NodeJS application.

Related

IIS/ASP.Net vs NodeJs/ExpressJS

I'm very new to NodeJs/expressJs, i read tons of articles on internet and still don't understand it
is NodeJs a web server like IIS ? if so can i host an asp.net app in NodeJS ?
Is expressJs a framework like ASP.NET ?
I currently work on both IIS ASP.NET applications as well as NodeJS/ExpressJS systems and the below is what I have noted to be different:
IIS:
Windows server based
Can have strict setups such as MVC etc
Built in deployment that compiles the entire website
Setup can take quite some time to create all modals and get all
plugins working etc
Services can take some time setup and modal mapping can be tedious
NodeJS/ExpressJS:
Not Windows based. I run this typically on an Ubuntu server with
Nginx to push the domain to the public
Easy to setup and fast to get something basic online
Does not natively compile and runs files as they are
Uses npm package manager with easy to install packages
Does not have strict setups but you can technically create your own
MVC style system
Code can quickly become messy however with the correct approach you
can manage the amount of code easily.
NodeJS is not a web server. It is a backend server (Such as a REST API etc)
ExpressJS sits ontop of NodeJS to add functionality and is essentially a framework. Coupled with jade/pug you can write js inside the html.

Can we use angular project and that will use in my two different API backend projects (i.e. node and .net core)?

For an example, I have one angular ui project that fetches values and perform operations.
I have one backend API project in .Net Core and now I want to reuse angular ui project with node js.
Is it possible?
How to configure it and which are the main points to take care that angular project support both.
How can I deploy it?
Angular is a client side application that run's in clients browser, as long as the REST API or service you connect has Same API endpoints and same object models and authentication etc everything will work as intended.
REST is platform independent like the web services and also language independent. It doesn't matter if you use .Net Core or some nodejs framework.
Once the angular application is build ( ng build --prod) you get a bundled application files in dist folder you can host these files in any web sever just like you host normal html file.
The only change you have to make in the the Angular application will be to change the host URL (if there is any change) normally configured in environments folder
Take help of environment file and change the api as per your requirement.

Reactjs + Electron + Nodejs

I've been researching for long time but haven't found what I need. Maybe here someone can help me out.
What I want:
I'm trying to create an application that will run inside electron. Both frontend and backend should be encapsulated within a single executable, so I was thinking React js and Nodejs would be a good option.
But it's not as simple as I thought. Found a good boilerplace for reactjs https://github.com/electron-react-boilerplate/electron-react-boilerplate but I have no idea how I could encapsulate nodejs as a backend to it.
It'd also somehow would need to be integrated with the release package and so on...
Additionally I'd need to have a webserver that will run on localhost:[port] when you launch the application.
Technical Summary:
So basically:
Electron with React js - as the application 'face'
Nodejs - as the backend of the application
Webserver running locally - (using react js).
In the application, I would put link to the pages that is served by that locally running reactjs web app.
Hope I was clear. And I really hope someone can help me out.
Thanks!!!
as you know the serverside part is separate from front end.you can lunch react electron together like this article https://flaviocopes.com/react-electron/ .but serverside must start to stand alone . you could use pm2 for launching them.http://pm2.keymetrics.io/
lets talk about electron. what is electron?
according to electronjs.org :
Electron is an open source library developed by GitHub for building
cross-platform desktop applications with HTML, CSS, and JavaScript.
Electron accomplishes this by combining Chromium and Node.js into a
single runtime and apps can be packaged for Mac, Windows, and Linux.
so the electron is a tool for creating desktop applications.it uses chromium engine for accessing resources of the operating system level. but the intention of that is creating apps not a serverside job.
if you have some needs and logics that must handle in a server you should be considering that. otherwise, read about serverless applications.

Converting an node js app to android app

I have developed a web app in node js using express which also involves mongodb. How to convert it to an android app ?
My main app file is directly inside the main application folder.
Your subject in this thread looks confuse. I think that you want to convert web application (can be express.js app, php app, or jsp, etc) into mobile application (ios or android).
If it is so, you can use cordova to do it.
Please read this document.
http://cordova.apache.org/docs/en/3.5.0/guide/cli/index.html

Do we need Node.js and Express.js while working with Angular2?

I built a sample web application using the following -
Angular 2
TypeScript
ASP.Net WebAPI 2
Mongo DB
Karma/Jasmine
Node.js (only as a server, just to the extent as specified in Angular2 Quick Start)
Considering the above tech stack do we have any need of using Node.js or Express.js for building a production web application? Is any of the above tech is replaceable with Node/Express, for better performance/memory utilization/code maintainability/faster development?
You'll need Node.js for development time tooling - for instance, TypeScript compiler and running Karma/Jasmine tests.
Regarding Express.js - you can do without it. An Angular 2 application does not rely on a back end framework. It could be served as static assets from a web server. Pick any back end framework that suits your needs.

Resources