Giter VIP home page Giter VIP logo

idea-case-backend's Introduction

Idea Case 2019K Backend, Express Version

This version uses Express (instead of Hapi). Now ready for studying!

Table of Contents

BACKEND TOOL SET

  • Git for Windows (2.20.1.windows.1), including the Git Bash
  • VS Code 1.29.1
  • Node v8.11.4
  • npm 5.6.0
  • (many node packages installed based on package.json, See below)
  • Postman v6.7.1
  • MariaDB 5.5.46 (But newer versions should work fine too)
  • MySQL Workbench 8.0.12 CE = Community edition (Not 100% necessary, only if want GUI SQL editor)
  • ssh, for creating the SSH tunnel, but first do without the tunnel, as it adds another thing to debug/fix

BACKEND INSTALLATION GUIDE

(((0. Have the SSH Tunnel to Maridb database defined so that finally it shows: L3308 localhost:3306
(That is the correct way! localhost:3306 here means how it's called inside Mariadb, our destination is the 'localhost' = Mariadb.))))

  1. Have a possible common root folder (root root folder) called "Case2019K" for both Frontend and Backend repos. Then you can open both projects to editor with one "Open folder" command
  2. clone Backend repo from GitHub while in that common root folder > git clone repolinkfromgithubcom
  3. > pwd to make sure where you are! Then cd to repo
  4. > pwd again for folder awareness!
  5. run > npm install if in the repo root folder, to automatically install the dependencies from the package.json. (Somebody else has already run the npm init & needed npm install thisandthat commands earlier)
  6. Create env_variables.sh file to some folder outside the project. Example contents below DB_DATABASE is actually your schema name on the database server. If you use mariadb.haaga-helia.fi it has the same name as username (Haaga-helia shared server thing only!). If you use your own installation of mariadb, it could be e.g. "test" Double check that the host and port are 'localhost' and '3308'. (If you use the SSH tunnel). Well, just be aware of all the settings and what are correct in YOUR case.
  7. >npm run db:init to run the db creation/reset script and get the shared test data (We should soon remove/consolidate/merge the scripts from the Database folder, as we should only have one set of drop, create and insert statements in our project)
  8. >npm start
  9. test e.g. http://localhost:8787/api/category/all and http://localhost:8787/api/category/all or even the POST services if using PostMan
  10. now ready to setup and run Frontend project

(You can of course also first run without env variables, use hard-coded values, though do not then accidentally enter the values in git.

And also with local MariaDB installation, localhost, port 3306, without the SSH tunnel

And then, when all tests ok with basic version, start to add compicating things)

// ******** Sample env_variables.sh file (run it in console before starting the backend) ********** export BE_API_URL_PREFIX="//api" export BE_SERVER_PORT="8787" export DB_DRIVER_MODULE="mysql" export DB_HOST="localhost" export DB_PORT="3306" export DB_USER="XXXXXXXXXXXXXXXXXXXXX" export DB_PASSWORD="XXXXXXXXXXXXXXXXXXXXXXXX" export DB_DATABASE="test" export DB_DEBUG="true" export DB_MULTIPLE_STATEMENTS="true" export DB_CONNECTION_POOL_MIN="1" export DB_CONNECTION_POOL_MAX="7" // ****************** END of env_variables.sh file ******************

source env_variables.sh will run the export commands. Works at least in Windows GitBash console.

PostMan link for the common PostMan tests: (Not yet created)

https://www.getpostman.com/collections/not_yet_there

SSH Tunneling to mariadb.haaga-helia.fi

Windows system:

On Putty:
  • Host Name: mariadb.haaga-helia.fi
  • Saved Sessions: MariaDB server SSH Tunnel
  • Do no change the other defaults (Protocol: SSH, Port: 22)
  • After saving, go to Connection / SSH / Tunnels
  • Write to Source Port: 3308 This is our own computer port (marked often with big L) !!!
  • Write to Destination: localhost:3306 (This means where to go in mariadb.haaga-helia.fi, there localhost = md.h-h.fi!!!)
  • Click on “add”, select the session “MariaDB server SSH Tunnel” you just create and save it again.
  • Now you can click open on the session “MariaDB server SSH Tunnel” to use it

Unix system: (Or e.g. in the Git Bash console on Windows, though might need to omit -f in Windows sometimes?)

> ssh -f [email protected] -L 3308:localhost:3306 -N

The executed ssh command sets up an ssh tunnel through the cli. After execution allow the fingerprint exchange with "yes" and type in your student accounts password.
NOTE: DO NOT CLOSE THE TERMINAL. Closing the terminal will close the tunnel. NOTE 2: If you are use an older version than windows 10 please use putty or another ssh client to create the same tunnel.

Command-line commands available

Usefull links

  • Express.js docs in case its needed express.js
  • All knex.js commands knex.js NOTE: ctrl+f is your friend
  • All ES6 features can be found on this cheatsheet ES6
  • Git cheatsheet git

idea-case-backend's People

Contributors

dependabot[bot] avatar eeashin avatar genttunn avatar jandsten avatar katjapennanen avatar khemrajneupane avatar linhpham199 avatar nganhavan avatar pikachu0214 avatar timedem0 avatar valju avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.