A Journal: Building a Writers Outlet for my girlfriend - The backend

_saul_ profile image Saul Updated on ・1 min read

The Backend

I started modelling the database, something simple to start saving the writings as posts.

So i started with a table for "categories" where it with hold an "id" and "category" fields, another called "posts" where it will hold an "id", "title", "subtitle", "post", "excerpt", "image_url", "created_at" and "category_id" fields.

As you can see there is a relation "one to many" between both tables through "category_id" on the "posts" table and the "id" on the "categories" table.

Having the initial database set up, i proceeded to start bulding the REST app from which i would use the endpoints to populate the site.

I made a new Node app with the following dependencies to start with:

  • body-parser
  • cors
  • express
  • jsonwebtoken
  • mysql

About the usage of certain dependencies, i used "cors" to only allow calls to the endpoints from the site. "jsonwebtoken" to verify the call to the endpoint.

With this i made four endpoints so i could get "all posts", "single post", "all posts by category" and "all categories".

Now thinking further along, i added a "users" table to have another app for her to log in and create new posts. The table will hold an "id", "user_name", "user_email" and "user_password" (this will be a hash, no plain text password will be stored).

Since im pretty fast with the Codeigniter framework i will spin a simple app right away, i will show some screens in the next post.

Thank you for reading.


Editor guide