Express ionic app - javascript

Is it possible to turn the public folder of an ExpressJS web app into a client side ionic application that continues to connect to an express server hosted elsewhere? If so, is this a good practice?

Related

Deploying a node.js frontend and spring boot backend as a self contained app locally

I have a web app that has a separate spring boot backend and a nodejs frontend.
is it possible to make them both run on the same bundle, like building a singe executable? or do i need a stand alone service for each? Both are having their own jenkins pipelines and git repositories.
My backend server is just a API that provides the frontend with simple data via REST services. If it is possible what would be the way to do it?
A nodejs is a backend technology, not frontend.
You can use a nodejs as an entry point to a spring boot application but it is a code running on the server side. So nodejs is not just a list of static files as it happens for a real front end developed in react, angular or vue (or vanilla javascript). It has also an engine to run the code.
So is not possible to run nodejs server using files that are compressed in the executable jar. Instead is possible to put a real front end application (react, angular...) adding static files in the directory /resources/static
It was maybe a little missleading. My frontend is an app runing on node.js server and may backend is a java app runing on spring boot server. They are communicating on localhost via Rest.
I want to create a single entry point that starts the node.js server (I call this unit frontend) and the spring boot server ("backend") at the same time. So it feels like a self contained system.Currently the spring boot app is delivered as windows executable.

Can I run my Node.js/Express backend and React.js frontend together in the same file structure?

I am making a web app that uses a Node.js/Express backend and a React.js Frontend. Right now I have my Node.js code that validities login/registration credentials in a separate folder running on localhost:5000 while my React.js frontend login/registration form code is running on localhost:3000.
My question is would it be easier to put both my frontend and backend code into one file structure so I don't have to send the data from my form to my backend running on another domain so for example both my Node.js and React.js code would be running on localhost:3000 and would just send the form information to the Node.js files that validate the user credentials instead of having to use a fetch method to send my form data to the backend. Is this even possible?
Yes, it is possible, you can use Express to serve your static files (frontend ReactJS) and also your backend routes. Take the following Github repository as an example.
https://github.com/Bikranshu/express-react-boilerplate
That is possible, A monolithic architecture with express and reactjs (https://medium.com/#sesitamakloe/easy-express-react-monolith-chapter-1-a1567c6ff483)

Proxy in production React for fetch API express

I was developping a app with React app. In developing env i was using proxy but I'm deploying the app and I saw that proxy didn't work in.
I read about http-proxy-middleware. It can be a solution or it don't works too?
Any way to do this without config the server with redirects to other port?
I need to continue fetching to my API server.
The best way what I found without configure server and NGINX is follow this steps:
Build front
Move folder into a backend server.
Put that code after routes:
if (process.env.NODE_ENV === 'production') {
app.use(express.static(`${__dirname}/yourFrontFolder/build`));
app.get('*', (req, res) => {
res.sendFile(`${__dirname}/yourFrontFolder/build/index.html`);
})
...
And build your backend code and access to your backend port like frontend.
You don't usually need a proxy in your React app when it is deployed. To deploy, you usually run npm run build, which creates a build directory containing all the compiled JavaScript and HTML files you need for the deployment. These are then served by a web server, such as NGINX or by your backend application.

How to create a react-redux app with node server as backend?

I am trying to create a react-redux app using node server as backend. Is it possible to make the node server serve the react-redux app instead of running react-redux using dev server a=in one port and node on another port?
Need some idea to start with. Thanks in advance:)
Yes.. it is
you can serve you react app on '/'
and listen for API request in another route
so you don't have separate codebase for the react app and the api backend code
You can use express to serve the react app on a particular route
i.e my-app.com/
then serve backend related content on another route
i.e
my-app.com/api
so when a request is made to my-app.com/ express serves express serves backend resource or API
There are a few steps I take when creating an express/react app together. I'll create a server and a client directory. The client dir is created with create-react-app and the server can be created via express-generator for example. My project dir (the one that contains both of them) is basically just glue that melds the two together. In the client app, I'll add proxy:localhost:3001 (or whatever port your express api is running) and I use concurrently to run both servers (client and server - as client is being run by webpack-dev-server) at the same time. They run as separate servers during development, but when I make an api call, it's as if I'm making it directly to the express server itself.
The only other thing to worry about is deploying the application. You can use the build command that comes with create-react-app and copy that over to the public directory in your express application that is served up via express.static.
Here's a quick example to take a look at:
https://github.com/overthemike/heroku-skeleton
This is an useful doc for redux SSR setup. This helps avoiding running client and server at two ports.
Redux SSR

What the best way to deploy javascript based web app?

I'm a j2ee developer and till now I've deployed web apps in Tomcat, Weblogic and many App Servers, which were completely j2ee based.
Now I'm developing a Javascript based app that uses require js for module, QuickBlox and Firebase JS.
Now what are my options to deploy them so that a user can use them for chatting purpose like via www.chatapp.com
We are using Amazon's cloud platform EC2(I'm new to it).
From my experience, NodeJS is the way to go if your application will be a Single-page application. NodeJS will give you the ability to manipulate your application on the fly in the server side with pure JavaScript if necessary.
To start with, you can use ExpressJS to serve your files. From ExpressJS documentation:
var express = require('express');
var app = express();
app.get('/', function (req, res) {
res.send('Hello World!');
});
app.listen(3000, function () {
console.log('Example app listening on port 3000!');
})
The app starts a server and listens on port 3000 for connections.
Read the ExpressJS docs for more information. There is a lot of ways to serve files in NodeJS. You can search for more in npmjs.com
If you are using Firebase as your backend, and just need to serve your HTML/CSS/JS files to clients, you could simply place those files in an S3 bucket and enable static website hosting.

Categories

Resources