For our first MERN app mini project you will be building a personal blog (longterm feel free to use this for outcomes!). First, it's time to make your own API!
Using what you have learned about Express, Express Routing, RESTful routing, CRUD operations, and Mongoose, use the Mongoose ODM to implement full CRUD functionality on a model (subject of your choosing).
MERN is an acronym for an app that utilizes Mongo/Mongoose and Express for the backend (typically an API layer), and React/Node for the frontend.
How we make it work:
- we will build an express server that makes mongoose CRUD requests to a Mongo db.
- we will build a React frontend that will make calls to our express API for any data.
- The model you choose to use should have at least three fields, in addation to the default
_id
field.
Example:
column name | type |
---|---|
_id | integer |
name | string |
title | integer |
content | string |
- Your API should be accessible via five routes:
Example:
Method | Action | URL | Functionality |
---|---|---|---|
GET | index | /blog | list all blog posts |
POST | create | /blog | add a new blog post |
GET | detail/show | /blog/:id | show one blog post |
PUT | update | /blog/:id | update one blog post |
DELETE | delete | /blog/:id | delete one blog post |
You will need to:
- Fork and clone this repository!
- Run
npm init
to start your node project. - Create a
.gitignore
and add everything to ignore - Create your Express App
- Add Mongoose functionality!
Recommended Workflow:
- Stub out your routes. For the purposes of initial declaration,
res.send("test")
to make sure you're hitting them. - Link your model to your server.
- Update your routes to "do something" and make the magic happen!