I'm writing a program with meteor and I'm wondering how one would go about splitting a single meteor JavaScript file, like one that is generated upon the 'meteor' command, into a client and server folder (client.js, server.js, etc). I haven't found any good guides. Does anybody know of any?
Thanks
Just create two directories, client and server. Then put the frontend codes in client and the backend codes in server. Take a look at http://docs.meteor.com/#structuringyourapp
Related
Ok this my sound silly but i have no clue on how to publish node.js backend for website i made. I am new at this and i know how to publish a website there are plenty of websites that offer hosting and domain for some amount of money but i don't know about backend. For example let's say i have node.js backend that reads data from MySQL database and sends it to my local-hosted website. And let's say i have nodemon package installed so i run it with nodemon and everything works fine. My question is how to publish this nodejs app along with my website and database.
You should get a VPS (Virtual Private Server) with Docker, It is the best solution.
Just copy your node folder and put it on a node docker image!
Got html front end? Just put it on an nginx docker image.
MySQL too, almost everything is possible with docker!
Want to learn more about docker? Here
Look into Heroku. Easy to use, mantain and deploy. You could either deploy from GitHub repo or directly via heroku.
Look into it here [https://devcenter.heroku.com/articles/deploying-nodejs]
I'm attempting to build a simple react/node/express app from scratch (not using the create-react-app). I've built out a simple back end to pass some data to the front end but am having a hard time figuring out how the two communicate. How can I run the front-end and back-end together and view the front-end with the data passed into it?
I'd like to do this all in one command. Do I have to use a tool like webpack to bundle everything together into one runnable package?
My repo can be found here, it is the react-and-express branch that I've linked to. Any help is much appreciated! Currently I'm running the app by starting index.js but that is only the backend, how do I run my front-end App.js and get the two to communicate?
https://github.com/int-a/contacts-application/tree/react-and-express
You can use concurrently to run two node commands at the same time (1 for front-end and 1 for back-end). And then use the proxy configuration in webpack dev server to alias the calls to the backend port number for the same machine.
Im making a module for node.js and it is meant to serve javascript on the server side (like most nodejs modules) but also needs to enable a javascript file to be shared with a client (browser).
The client is served by an express server, dealing with the routes.
However I can't seem to find a way to server the javascript file from the node module, as a static file (without it having to, either be placed to a static folder by the user or having to parse the app as parameter to the module).
These are two posibilities that I'd like to avoid, as I noticed Socket.IO does not take these steps to share its socket.io-client code.
I looked into their code, to look in how they did it but can't seem to find it.
So I am wondering what the best way is, to share a static javascript file to a client from a node module.
I'm curious if anyone has developed a best practice for organizing Meteor applications that contain external shell scripts, or other back-end processes that happen outside of the node.js server code and the client side js code.
For instance, I have a meteor app that is structured like this:
project-name
client
lib
models
packages
public
server
I have a shell script that processes some external data sources, and a Python script that does some other heavy lifting. These all then help by inserting new data into the Mongo instance. Yes, I know that's a bit of a jumble, but so are the backend data systems. My question is should I put these sorts of projects within the meteor app folder, or should they live outside of the system? Just curious how others are structuring apps like this.
Option #1
project-name
client
...
server
data-processor.sh
other-utility.py
Option #2
project-name
client
...
private
data-processor.sh
other-utility.py
Option #3
bin
data-processor.sh
other-utility.py
meteor-project-name
client
...
private
You shouldn't put any non-meteor files inside your meteor project directory, all of those CAN be picked up by some package, even if standard meteor-platform packages don't recognize the extension. So putting them in the /server might cause problems in the future. The /private folder on the other hand is meant for resources used by your application, so placing the scripts there is unsemantic and inelegant.
To avoid moving those scripts outside of the project folder you can store them inside a hidden directory, that is any directory with name starting with a dot, i.e. /.scripts. Files placed there will not be picked up by Meteor application.
I want to create a simple Javascript program with a HTML interface. The program will run in Chrome. I will also use node-serialport and Node.js to comunicate with an Arduino. I have a HTML and JavaScript file done, but I have no clue how to run it, or how to implement Node.js or node-serialport, nor how to "start" the sever. Initially it will only be running locally, but eventually it may become a real sever. For now, how do I run all that locally?
EDIT: I'm using the sample code from http://brandontilley.com/2012/03/02/controlling-an-arduino-from-nodejs.html, with the CoffeeScript converted into JavaScript.
Lucas, glad you found the blog post useful; perhaps I should add this information to it.
Getting the sketch into your Arduino
Just fire up the Arduino application, paste in the sketch code, and hit "Upload." Should be all you need to do here.
Starting the Node.js Server
What operating system are you using this on? Finding out how to access your Arduino microcontroller via node-serialport will differ based on your OS.
In the source code, change the string value of port to be your Arduino's device (once you know it). Also, the script depends on Express and (of course) node-serialport from NPM, so run npm install express serialport in the directory where your JavaScript file is saved. Finally, run the file with node server.js (assuming server.js is the name of your file). Then you can access the server at http://localhost:8080.
You can use node.js to serve up HTML with Express. If your main Javascript file is called server.js, then run it by typing:
node server.js
at the command line.