It's time to make your own API!
Using what you have learned about Express, Express Routing, RESTful routing, CRUD operations, and Sequelize, use the Sequelize ORM to implement full CRUD functionality on a model (subject of your choosing).
- The model you choose to use should have at least three fields, as well an id field.
Example:
column name | type |
---|---|
id | integer |
createdAt | timestamp |
updatedAt | timestamp |
name | text |
wodgets | integer |
quantity | integer |
- Your API should be accessible via five routes:
Example:
Method | Action | URL | Functionality |
---|---|---|---|
GET | index | /widgets | list all widgets |
POST | create | /widgets | add a widget |
GET | detail/show | /widgets/:id | show one widget |
PUT | update | /widgets/:id | update one widget |
DELETE | delete | /widgets/:id | delete one widget |
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
- Sequelize init
Recommended Workflow:
- Stub out your routes, write them
res.send("test")
for initial decleration. - Declare your model and migrate.
- Link your model to your server.
- Update your routes and make the magic happen!
Add a second model to your API. This model should relate to your first model via a 1:M relationship.
Once added, update your GET and POST routes for this second model which allow you do the following with your API:
- Show all elements from second model that relate to your element from first model at :id.
- Add a new element to your original model that include related elements from this second model at :id.