This is the code I wrote following the Thinkster IO tutorial on building a Medium clone (blogging social network) using the MERN stack (Mongodb Express React and Node) and is based on the (Thinkster IO Real World App, from the Thinkster Full Stack tutorial series by Thinkster IO
This code is for the back end. here is the tutorial. The front end code I wrote can be found here.
Click here for the demo
- Authenticate users via JWT (login/signup pages + logout button on settings page)
- CRU* users (sign up & settings page - no deleting required)
- CRUD Articles
- CR*D Comments on articles (no updating required)
- GET and display paginated lists of articles
- Favorite articles
- Follow other users
- Home page (URL: /#/ )
- List of tags
- List of articles pulled from either Feed, Global, or by Tag
- Pagination for list of articles
- Sign in/Sign up pages (URL: /#/login, /#/register )
- Use JWT (store the token in localStorage)
- Settings page (URL: /#/settings )
- Editor page to create/edit articles (URL: /#/editor, /#/editor/article-slug-here )
- Article page (URL: /#/article/article-slug-here )
- Delete article button (only shown to article's author)
- Render markdown from server client side
- Comments section at bottom of page
- Delete comment button (only shown to comment's author)
- Profile page (URL: /#/@username, /#/@username/favorites )
- Show basic user info
- List of articles populated from author's created articles or author's favorited articles
The API specification is listed in the /api folder of this repository
The back end is deployed on Heroku, and the front end is deployed on Firebase. Here is the demo, and here is the production api link https://intense-hollows-36762.herokuapp.com/api
that can be used with any front end for requests
Load the Conduit.postman.{{environment}}.json
files in the /api_spec
folder into Postman
Run npm install
Navigate to your local Mongodb folder and run mongod --dbpath=data --bind_ip 127.0.0.1
Run npm start
Open Postman and begin making requests to http://localhost:3000/api/{{request}}
app.js
- The entry point to our application. This file defines the express server and connects it to MongoDB using mongoose. It also requires the routes and models to be used in the application.config/
- This folder contains configuration for passport as well as a central location for configuration/environment variables.routes/
- This folder contains the route definitions for the API.models/
- This folder contains the schema definitions for the Mongoose models.
Requests are authenticated using the Authorization
header with a valid JWT. We define two express middlewares in routes/auth.js
that can be used to authenticate requests.
- The
required
middleware configures the express-jwt middleware using our application's secret and will return a 401 status code if the request cannot be authenticated. The payload of the JWT can then be accessed from req.payload in the endpoint. - The
optional
middleware configures the express-jwt in the same way as required, but will not return a 401 status code if the request cannot be authenticated.
-
Back end
- Version 1 (Thinkster Tutorial): 22 hours
- Version 2 (personal modifications): 7 hours (to add commentCount and Trending article list)
-
Front end
- Version 1 (Thinkster Tutorial): 37 hours
- Version 2 (personal modifications): 17 hours
Special thanks to Thinkster IO for a great tutorial. The Real World mother of all demo apps is very ambitious and is exactly what the world needs.
The codebase is MIT licensed unless otherwise specified.
To be modified further by Kgotso Koete
Johannesburg, November 2019