DEV Community

Cover image for Frustration learning MERN from LAMP
Mike
Mike

Posted on

Frustration learning MERN from LAMP

16 years ago my journey into PHP started with a Lynda PHP tutorial and some basic HTML/CSS from school and LAMP server. Took 10 years but eventually reached my goal of creating a successful SaaS product.

Every now and again new trends popup and from where I'm sitting MERN is the next step, but let's look at what I know:

  • MongoDB: No more structure just JSON "collections" and indexes for optimization
  • Express: APIs, probably the thing I should learn the most about yet know the least about
  • React: Reusable components. HTML/CSS/JS = a Button or List or Card. Data goes down the component tree, events go up the component tree. Git repos for components sounds cool. fml
  • Node: If chrome was running a on my hosting

For fun let's compare that to LAMP:

  • Linux: an IP address, a username usually root and a password then google for commands, but always first "sudo apt update" then "sudo apt upgrade"
  • Apache: something people used to fight about if it's better than nginx, but then they stopped
  • PHP: <?php echo "just the best"; ?>
  • MySQL: /phpmyadmin

As SaaS is high value task building a user authentication system with a few different tiers is always a good start and in LAMP this would be as simple as copy a few lines of code from my latest project, $_SESSION=['PAID'] and off to the races.

In MERN basically everything is stored in the browser so you need JWT to authenticate anything stored in the server-side database that is protected. This is frying my brain going through all the different methods. The moment your API key makes it way to the browser its game over so my guess is Node renders a token into the session... Don't want to pass it to a 3rd party to handle authentication, simple email and password is the goal.

Keeping the database safe (if more than 3000 records are lost you legally have to disclose) is my #1 concern. Client-side seems so much more difficult in MERN.

What am I missing?

Top comments (1)

Collapse
 
mikem1 profile image
Mike

Thanks for the comment, stateless concept I will look into more. Think I have the basic concept.

Client sends username + password to /user, server response HTTP 200 + JWT.
Cliend sends GET/POST/PUT/DELETE to /route + JWT, server response HTTP 200 + results.

My next project is to build a PHPmyAdmin inspired way to, as automatically as possible and without coding, turn the SQL database form an existing PHP project into a JWT protected REST API for each user with say 7 different roles (trial, basic, advanced, paymentpending, admin, test, public).
Best example so far has been neoan3.rocks/

Wish me luck! :D