How to deploy a simple json-server? - reactjs

I completed an online React course and deployed my application to Heroku. During development, I used the 'json-server' module found at https://github.com/typicode/json-server. This served up a folder on my computer which contained a simple json file and a few images for my website while conforming with the REST API. What do I need to do to get the server to operate independently of my machine so that my application can fetch the data ? I have zero experience doing this.

if you mean you want to create a server for your site,
first of all, you need to get a server, which can run nodejs , then you need to deploy and run your JSON server via a nodejs(express) app.
then you can connect to your server via your website/app
in order to do these things, you can follow tutorials
there are lots of tutorials about it.
hope you got the idea.

Related

Hosting Angular fullstack project

I started a new Yeoman angular-fullstack project (client-angular.js, server-node.js)
(generator: https://github.com/DaftMonk/generator-angular-fullstack)
I have 2 seperated directories for client and server,
I want to launch the app but the deployment don't show any index.html file,
The question is, Should I make 2 different hosts for the server and the client?
if no, how can I host and use the united projects?
No, it is not needed to create 2 different hosts for the server.
The server needs to point to app.js, usually located at server/app.js, as this is the entry point (instead of index.html) of your app. How this is done depends solely on the server you intend on using.
If you consider using IIS you can take a look at: Installing and Running node.js applications within IIS on Windows
As for the other deployment options, as laggingreflex said, "Heroku is the popular choice to host node.js projects". The angular-fullstack git site has more information on deploying to Heroku or Openshift.
As a side note:
Deploying to IIS requires a bit more attention than the information in the link specified. You need to set file access, create a web.config file as well as a few other stuff. At least, I had to...
You'll need a host that supports MongoDB assuming you kept the Database the same after generating your application. Heroku is a great option as it allows you to setup up plugins like mongolab or mongohq fairly easily. I would also recommend looking into Digital Ocean as they allow you to set up a droplet/server that has what you need for the application to run.
If you go with Digital Ocean and are a student check out https://education.github.com/pack. You'll actually receive $100 credit towards a new Digital Ocean account which will let you test things out.
Good luck!

Website that communicates with Server

I'm a newbie. Im thinking about developing a website that people can be come members of and login. I know that ill need to have a server with a database to store info. What i need to know is, do i just need to create the server host site host it and then have my website hosted somewhere else. To sum up, what's needed in the process of developing this type of site?
No, you can host everything in the same server. Back-end and front-end are words just to describe the organization of your code, being HTML, CSS and Javascript files your front-end, and the rest your backend.
Most host services today have Ruby, PHP and ASP supported by all plans, just as MySQL. There are no need for developing two parts in your application - but you can do that if you want.
I suggest you start by studying what is the MVC structure.

How do I separate the RPC client and server so that the server runs on app engine and the client runs on my computer?

I'm very new to all this, so please bear with me. I just completed this tutorial on RPC in GWT. In the tutorial, you create a stockwatcher application that displays stock information. The application gets data from a server using RPC. I deployed the project to app engine and it works great.
Now I would like a separate, normal java project that runs on my computer and displays stocks that it retrieves from the app engine server using rpc. In the stockwatcher tutorial, there is a client and server package. I refactored the client package into a new project to start. I understand that I need to give it the appropriate url, but I'm not sure how to do that. The StockPriceService has the annotation #RemoteServiceRelativePath("stockPrices") so my first thought was to somehow change that to the correct app engine url. Is there an annotation that allows me to put in the entire url? If someone could point me in the direction of a tutorial that deals with this, I would greatly appreciate it.
THANK YOU!!! :)
Edit
I'm trying to make a client that will run on my computer, another client that will run on my phone, and a simple app engine server that will store some data. After doing the RPC tutorial, using RPCs seemed like a good way for me to send and receive data. I just don't know how to setup the RPC service across multiple projects.
Edit 2
I just saw this so I guess what I want to do isn't possible. I guess my new question is, what's the best way to send and receive data between app engine and a non-gwt project?
Pls see the following links
https://developers.google.com/appengine/docs/java/gettingstarted/
https://developers.google.com/web-toolkit/doc/1.6/tutorial/appengine
An appengine project will run your machine, you can really deploy it, but you need an account.

connection between postgresql db and application(jsf+hibernate) running on cloudfoundry

The application(JSF+hibernate) is been deployed using the vmc commands as on the cloudfoundry site. able to see the welcome page. postgreSQl service is binded with the application but the application is not able to connect with the database.
And also viewed about the VCAP_SERVICES using java but dont know much about it rather how to create it.
Cloud Foundry uses auto-reconfiguration if you have one service (either MySQL or Postgres) bind to your application. That means you don't need to touch your code at all!
Please review the following article on our docs site:
http://docs.cloudfoundry.com/frameworks/java/spring/spring.html#using-cloud-foundry-services-in-spring-applications
If you still have issues, go ahead and upload a war file of your app and we can take a look.

How do these fit together : Silverlight, Apache, PHP, MySQL, Web Services?

I have been attempting to teach myself quite a bit about silverlight, and how it all works, for the past few weeks, and I am to the point in my app development where I would like to connect up to my web server's MySQL database.
My web server is capable of running ASP.NET pages, but is Apache, and natively runs PHP (which is what I'm far more familiar with). It has a MySQL database engine, and I am very well-versed in your typical dynamic page creation with PHP and MySQL.
What I'm NOT familiar with are these "Web Services" that people keep mentioning every time I find an answer regarding the question of "how do you connect silverlight to a database?"...
So my basic question is really one of data FLOW, and where everything fits in the puzzle, and how to get it all working in this particular configuration. Most of the answers I have seen deal with IIS instead of Apache, ASP.NET instead of PHP, and MS SQL Server instead of MySQL.
Also, answers tend to start using abbreviations and acronyms without actually explaining what they stand for.
For example: What is WCF, and RIA services, and how do they fit in to the puzzle as a whole?
I suppose I'm just looking for a top-down overview of the structure of data flow on a MACRO level, not on the micro (code) level.
(Edited to add:)
Also: I have done vb.net apps in the past which have used MySQLConnector.NET to pull from my web server's database remotely, but I understand that the client machine would have to be whitelisted as a remote machine, meaning I'd have to open my MYSQL server up, and make the access mask basically %.%.%.% in order for any client to connect... and that is undesirable... so if I understand things right, the web service runs on the web server, and the client sends requests to it, and the web service acts as an intermediary, grabbing the data from the database (possibly with some sort of "stored procedure" look-alike?), and passes the data on to the client... which also means all database access credentials are on the server, and not inside the (potentially hackable) client...
Do I have it right?
Also, when answering, I need to know where the access to the web services is... in the silverlight APP project code, or the silverlight WEB project code...
I have found this wonderful tutorial that helps to explain it...
http://www.designersilverlight.com/2010/05/23/php-mysql-and-silverlight-the-complete-tutorial-part-1/
Here is how I understand it all working.
There are 3 "Layers" to the process: The application, the web server, and the database.
The application calls out to the web server to execute a script file (like a normal PHP script). There script file can have normal URL variables passed to it (like script.php?foo=bar, so $foo is defined as "bar" in the script)... so you can use those URL encoded variable/value pairs to tweak your script results as you would normally with a web page.
I imagine you would have one script per TYPE of database query, with var/value pairs to tweak your results. So on your web server you would end up with numerous PHP scripts, just like you would normally for a website with different pages, and you pass variables in to those scripts to customize the results.
For example, for users, you could have a get_users.php script that would return all users...
but get_users.php?loggedin=true would get all users that are logged in currently
get_users.php?loggedin=true&ingame=true would get all users that are logged in and in a game... You just script the logic and the resulting SQL query accordingly.
All of the results are encoded either with XML or JSON (Javascript Open Notation: see What is JSON and why would I use it? ) for transport to the app... the app, in effect, is reading the results of an echo of the JSON encoded stuff.
If you were to open these scripts in a web browser, the only thing you would see is a text printout of the JSON data... no web page... just data that is read by the app and then decoded in to objects.
So in effect, the silverlight app is reading a text output of a PHP script executed on your web server, and interpreting the output.
^^^^^ THIS IS THE SHORT ANSWER TO MY QUESTION. :)
To be blunt, the whole use of the terminology "web service" is misleading, and what was really leading me astray. I thought it was some sort of service or app you had to install on your web server just like PHPMyAdmin or something.

Resources