signzyCodetest

NodeJS Scripts to perform some MySQL operations

####My Environment

Software Version
OS Ubuntu 14.04
NodeJS 4.5
MySQL 5.7

Steps to run on your machine:

  1. Install NodeJS v4.5.0 based on docs
  2. Install MySQL v5.7 based on docs
  3. Run sudo mysql_secure_installation to secure your existing mysql installation on linux, if you are running another OS, check docs
  4. Install Git based on docs
  5. Clone this repo
  6. Run npm install at the root directory of repo
  7. Edit index.js and add database credentials(create a database in mysql using shell) to it
  8. Run the script node index.js, wait for completion
  9. Verify data in the database by running SELECT * FROM '<tableName>', it should return with all the rows, replace <tableName> with your table's name in the DB.
  10. Run node api.js, this make the app server to LISTEN on port 8082, check if the port is open and not being used by any other app on your machine.
  11. Goto your browser, open URL http://<server:port>/search/<query>, it will return with an array of 5 rows from DB, if search results true, else it will return an empty array. If the <query> is less than 3 characters, it'll return HTTP 400 bad request.