How can I integrate a nodejs server in my react-native app? - node.js

I'm creating an app with react-native. I also have a node server that can get data from a PostgreSQL database. Now I have to launch the app and the server with two different commands on two different terminals (npm start, node server.js).
Is there a way to run the node server on the react-native app in a way that I don't have to launch both the app and the server every time?

Related

How can I convert a Node Js web application to a desktop application?

I have created a Node js Web application which is running on an express server. It is a web automation application which is made using puppeteer. I want this app to run in headful mode which is not possible if I deploy this on servers (for eg Heroku). So instead of deploying this application,I wanted to create a desktop app which runs this application on the local host everytime. Is there any way to convert this web application to a desktop application and run it on local host through the desktop app only?
Your best bet would be using Electron.
It is used for cross-platform apps with Nodejs and interacts like website, so you wouldn't need to rebuilt your app from scratch.

How to run separate node server in electron app

I'm building an Electron app using React.
I couldn't get the native node module "printer" to work in electron. There were problems while rebuilding native node module. I need the list of printers that are connected to the device in my app. Then print text using specific printer.
So I decided to run an express server separate from electron. Express app needs to have its own node_modules and package.json. And client side will connect the local node server via http request to localhost.
Is it possible to do so? How can I add express app to the dist folder which is created by electron-builder and make it run when electron app is launched?
There is already a way to way the native printing functionality in electron.
Please follow the below link.
https://www.electronjs.org/docs/api/web-contents#contentsgetprinters

Electron JS/Node JS desktop app as a local network webserver

Is it possible to make an Electron JS desktop app that is a web server, so that when we start the app the server will also start and we can access it from other computer within the same network/LAN?
Yes, it is.
Yout can run you server (express or just bare http/https/http2) on main process.
Also you can child_process.fork() or child_process.spawn(). It works fine.

how to deploy nodejs rest api with express framework on production server windows

I have created a node.js rest api created using express framework for routing. I have used tutorial
Now I want to deploy that rest api on actual production server. How to achieve that thing.
I have gone through below links.
Deploy node js application with express framework on production mode --- Only for linux. I need for windows.
Deploying NodeJs Express Rest API to Windows 10 IoT -- a little bit similar problem but no solution
https://stackoverflow.com/a/38652869/2810015 -- this said to run npm start on production server after copying all of the files on server. But this is not working fine either.
Any help will be highly useful.
You use pm2?
Usually I use it to start the application. It works for both windows and linux. He leaves the service initated, and in case something happens that knocks the service up again.
You install it on the server, and instead of using it
node server.js
You use the command below
pm2 server.js start
Link: http://pm2.keymetrics.io/docs/advanced/pm2-module-system/

How to live-reload node.js(Express) server with react.js

Hi there,
I having some problems with back-end of my project.
Bascily I'm using create-react-app as my boilerplate and trying to attach server on express with socket.io . I did some tutorials etc. But all of those servers based on build version of my app. I'm trying to find solution where I can code on react files and see result on my server same time, not rebuilding whole app each time I made any changes to it.
Here is git with project:
https://github.com/7sleepwalker/boilerplate_server
At the moment I have: server runing at localhost:3001 (based on build files of app)
production app runing at localhost:3000
Any ideas how to join both?

Resources