How to connect Mongo database to node in MacOs - node.js

I was uploading material for a website on mongo by node previously on my windows pc. Now, I don't have much idea about the technicality of it but all I used to do was open postman, open cmd, type "node index.js", cmd would show "connected to port 3000" and when I used to upload them through postman I could see the changes in Mongo.
Now that I have switched to mac, I don't have much idea how to go about this. I installed mongo, node, and npm using homebrew but I don't know how to set up a local connection between node and mongo to upload to the database.
Any help would be appreciated. Thank you.

ok...I am actually building a APP with MERN stack on Mongodb.
A mac is not much different...sorry a mac is way different-
Postman doesn't work well with mac at all-
Infact I can't even find anything to test a backend with on a mac using Postman from their own official page.
I found this helpful for testing an app with Postman-
https://tech-cookbook.com/2020/04/27/how-to-use-postman-on-mac-os-catalina-get-request-rest-api-example/
It's hard to find sources on Google because it has become a capitalist pig for corporations to sell on....I feel you.
When I started looking for help, I ran into more buy this product than actual tech help.
You can also pull from github repositories...because mac's provide additional security for the users, it's almost guaranteed 20 additional steps in development than a windows.

Related

Migrating MongoDB from localhost to server

I completed development of a web application for my university doing everything on localhost. Now I want to migrate the backend and the MongoDB to the stakeholder's (my university) server environment. I tried finding different ways to do so but I haven't found a solution. Please help me in resolving this. Any links and working examples or videos would help a lot.
Tech stack used for backend:
1. NodeJS
2. MongoDB
3. google maps client api
I would suggest using a database software interface like
Studio 3T, Robot3T or any others that have a backup and/or export and/or import feature.
If you have access to the machine and can install tools for MongoDB there are some terminal tools to do this.
Mongo Import
https://docs.mongodb.com/manual/reference/program/mongoimport/
Mongo Export
https://docs.mongodb.com/manual/reference/program/mongoexport/#bin.mongoexport

Node JS web application to LAN application( Desktop App)

I am very new to Node JS. recently developed a web application in NodeJS & hosted it on a common server along with Database for a clinical management.
Now I have an immediate requirement of making it as a desktop application so that users in a clinic can run the exe on their desktop and the application where its installed will create a database for other users to connect and make their updates.
Checked articles with Electron, node-webkit but didn't work for my current solution.
Is there any other alternative solution where I can make it as a desktop for Windows and Mac. Seeking your kind help !!!
There is the software NEXE which shows promising results however, when it comes down too it, Node.JS is a perfectly fine platform for production environments and is quite performant for the use-case you suggest. You can bundle a Node.JS installation and call upon it from your C code using system, exec or spawn calls. You can also open your favourite browser from the command line, while Google Chrome has the --kiosk flag to show in widescreen by default.
Just some ideas.

MongoDB accessible through localhost but not 127.0.0.1

I am trying to run a web application locally that uses grunt and mongodb. The app allows users to upload information which they can then view in their gallery.
started mongodb with mongod --port 3000 --httpinterface
(As mentioned in the comments, I have tried running it without the --httpinterface as well)
browsing to 127.0.0.1:3000 gives a page with only the text "It looks like you are trying to access MongoDB over HTTP on the native driver port."
browsing to localhost:3000 loads my application
the application sends data over 127.0.0.1, and it is not going through
It seems very relevant to what is going on in this question.
I hope this will not be considered a duplicate, because after finding that question I tried to work through the answers offered without success. If I was able I would have tried pursuing this issue in the comments there.
Following the answers on that question I tried running mongo with a config file without success (no config file existed beforehand, I tried to create one with the sample offered on the mongo website but it rejects it). I also tried deleting the lock files and repairing mongo. Nothing has changed.
It's probably worth mentioning that the application I'm working with is an existing, sparsely documented project that was given to me for a school assignment. It is far more complicated than anything I have ever worked on and I am very unfamiliar with tools like mongo.

Deploying Sails to a standard web server (Windows)?

Today I discovered Sails and have been watching a few tutorials. One thing I can't seem to work and find out is how to deploy it to a standard web server, like for example via an FTP client. I've seen the tutorial on how to deploy it to a Heroku account, but this isn't really what I'm after, as we already rent a Windows 2012 server.
I've got a feeling I'm completely missing something here, so can someone please help me out :)
Many thanks
You can transfer all files via FTP to your Webserver (include all node-modules).
But you have to make sure NodeJS is installed on your server. Than login into your Server (e.g. via SSH) and start your Sails-App (node app.js)

How Do I Set Up The MEAN (Mongo, Express, Angular & Node) stack on Nitrous.IO

I using the upcoming weekend to check two things off of my 2013 project list:
Give Cloud Development A Try
Try ANGULAR.JS
My game plan is to set up the MEAN stack on Nitrous.IO and then use the stack to complete one of the many Angularjs tutorial projects available online.
Questions:
I'd be interested in hearing if anyone has set up the MEAN stack on Nitrous or otherwise or if anyone is aware of any good blog post that go through the process for someone with little to no javascript development experience.
Also, if you have setup a MEAN stack are there any things you would do differently or are there any invaluable resources I should be aware of.
Some Resources I Found Useful:
I've been researching online for the past week and have uncovered some great resources, but it would be great to see what others have found or can suggest. Below are some links to some resources that I have come across that may be helpful to others:
Building Angular Start-up Stack - Toronto Meetup Stream
Egghead.io Offers some great Video tutorials on Angular
Google's Angular site has a wealth of info.
USC Linux User Group Youtube video on MEAN on Amazon AWS
Thanks in advance for any resources, insights or guidance.
Since you are starting on JavaScript I would suggest that you start simple. For example
Build a simple web site with Node.js and Express (no Angular, no Mongo).
Deploy it to the cloud.
Then add Angular and see how the structure changes when you use an MVC framework on the client side (e.g. your backend becomes a plain REST API).
Then, play with Node.js and Mongo probably outside your simple Node/Express/Angular app to get the hand of a NoSQL database and database access from Node.js (the fact that everything is async brings some interesting challenges for beginners)
Then integrate Mongo into your app.
Ok, here's how I successfully set-up the MEAN stack on Nitrous.IO.
First, many thanks to Valeri V. Karpov and his The Code Barbarian blog. In July he had a blog post titled Introduction to the MEAN Stack, Part One: Setting Up Your Tools. I primarily followed his article, only making adjustment dictated by the Nitrous cloud platform.
So here are the steps:
Create A Nitrous Box: Go to the Nitrous site and sign-up for an account. Please note the free account does not provide enough storage to accommodate the full MEAN Stack. You'll need at least a "Start" pricing plan - at $9.99 per month.
Create A Nodejs Box: Once you complete your registration and select a pricing plan, its time to create a Nodejs box. Follow the instructions on the Nitrous site. The box comes preconfigured Nodejs.
Install Mongodb: To install Mongodb on your box, go to the shell prompt and type: parts install mongodb You can confirm the installation was successful by typing parts start mongodb. To stop the mongodb server you type parts stop mongodb.
Confirm your Node & NPM Installations: Type node at the command prompt. You should see a > sign if node is installed correctly. You are now in the node shell. Type control-c to exit the shell. Type NPM at the prompt and you should see some usage information
Install Express: type npm install express -g The -g flag means the package will be installed so you can run it from the terminal. Note, if you are using the free box you will likely encounter errors during the Express installation as a result of you exceeded the allocated storage.
From here on you can follow Valeri's article at Step 4 Creating an ExpressJS application..
Good luck and enjoy.
Use Bitnami https://bitnami.com/stack/mean. I like it a lot, pretty simple and concise. In my case it was for Windows and it was a seamless experience

Resources