How to host nodeJS project to firebase? - node.js

I am using node, express and more other dependencies for the project. I wonder how to host this project on firebase. My project will have controller, view , and any other folders to make the project possible.It already has view engine like pug/handlebars.
Tutorials online only show how to host firebase with single index.html in public folder. How am I suppose to host my project with all other folders? I know how to use firebase in nodeJS, but how to host the project on firebase? How firebase will access the server file(either app/index.js)? Where should I put all these folders?
Hopefully I am not asking to much. If my question isn't clear, please let me know so that I can make clarification.

You're in luck. Firebase just this week released a video that walks step-by-step through setting up an Node.js/Express app on Firebase Hosting.
This has only been possible since the integration of Cloud Functions with Firebase Hosting, which was released at I/O 2017. Most tutorials likely are from before that time, when there was no way to run server-side code on Firebase Hosting.

You can do this by firebase cloud function.
Deployment auth is handled by the Firebase CLI, so getting a hello world up and running is literally:
firebase init functions
firebase deploy
A simple hello world function
functions.https.onRequest((request, response) => {
response.send(“Hello from Firebase!”);
});
Note: You can use express with firebase function.
For more follow documentation link: https://firebase.google.com/docs/functions

Related

How to LInk Backend(Node.js) to front-End(React)

I am starting out on React.js after learning Node.js using Express. But I don't know How to Link my Backend App to front end React files? Can someone provide me a simple solution to the problem
You can begin with this steps, you got a thousands of topics about to make a complete and solid infrastructure:
Initialise your node.js server with port, cors (if you need)
Learn how express work with node.js and create your first route
Initialize your react project with or without npx create-react-app
Create your first frontend component and fetch data from your API
Link : https://www.freecodecamp.org/news/create-a-react-frontend-a-node-express-backend-and-connect-them-together-c5798926047c/

How to connect NodeJS with ReactJS front-end

I am new to reactJS. I am working on project which uses following :
Front-end : ReactJS
Backend : NodeJS (Express)
Front-end runs on port 3000
Back-end runs on port 8088.
I am planning to deploy application on amazon AWS.
What i am trying to do is load reactJS front-end when i make request on http://localhost:8088/
I know using axios we can make request on backend server and display fetched data.
What would be standard way of loading ReactJS front from the nodeJS ?
I'm not sure if this is the answer you are looking for, but generally in development you use something called proxy in your package.json in the client (react) folder:
{
// Other stuff
"proxy": "http://localhost:8088"
}
and then when you'd want to deploy you'd run npm build for your react folder and serve that generated folder called build. But as I said, you usually do that only when deploying your application onto server, not the actual development.
Also I'd suggest checking some of these videos, that are focused on deployment, because that is what I think you are asking, right ?

Creating a Node.js REST API using Firebase Cloud Functions, without Express?

I am working to create a serverless REST API via Firebase Cloud Functions, which seems to work well but the examples and documentation all seem to use a monolithic solution, since they use the Express framework and essentially map the root http request to the Express app, then let it handle the routing. I understand that this is because the Firebase Hosting platform does not have the ability to handle http verbs.
My expectation was that a serverless / FaaS approach would have a function for each endpoint, making for easy updates in future since there's no need to update the whole app, just that single service - i.e. a more functional approach.
What am I missing here? Why is the approach to use a single function to contain an express app? Doesn't this defeat the purpose of a serverless / Cloud Functions approach? And is there any other way of doing this?
The documentation shows how to create an endpoint without the help of an Express app, router, or middleware:
exports.date = functions.https.onRequest((req, res) => {
// ...
});
All you have to do is arrange to send a response with res.send(...) or similar.

How to sync react native app with express app?

I am using react native android app for recording calls.Once the call get recorded, it should be uploaded to serer(express js and mysql) with call details.Suppose the app is in offline the file should uploaded to server whenever the app comes to online.How should i acheive this.
NOTE: All the above mentioned process should be run in background.
I found some solutions like pouchdb. For react native (pouchdb-react-native) npm and for express js (express-pouchdb) using this npm can i achive the sync? and how?
It is possible - using PouchDb server and LevelUp - to sync PouchDb with different backend databases. See this answer for details and the Nolan Lawson article on LevelUp.

Firebase host:i can deploy but how to hide source code

i have deployed my website by using Firebase host but when i do Right Click > View page source: i can see source code and my firebase Project information
So How can i hide it ; Will i have to use Node.js ? or Cloud functions ?
i have tried node's http npm
const http = require ('http');
onRequest();
function onRequest (req , res){
http.createServer(onRequest).listen(3000);
console.log("Success");
}
but it does not help
i am really confused please help me
If you want to hide some stuff from your users you will need to hide it in the server side. So with Firebase, you can use the Firebase Cloud Function. They accept nodejs, python and typescript. If you want to store variable in your website, then use the database.
After that, make sure to set your database rules safely.

Resources