In this project I created a Restful blog API with expressjs. There are 2 major routes, a route for a client, and a route for a content management system. The client route lets you see all of the public posts. and then leave comments on them. The content management route lets you create an account, create, update, delete posts, also you get to manage the comments under your post. The posts, users, and comments are saved in a mongodb database. Authorization is handled by passportjs (JWT Strategy).
This api is built in nodejs with the expressjs framework becuase of its popularity. I used MongoDB for the database, and mongoose to interact with it. Authetication is taken care of with Passportjs(JWT Strategy). I used supertest and jest for api testing.
Learning how to test the api routes and setting up test database was difficult, and I didn't do the best job. I definatley tested unnecessary routes, I shoud assume they work because they are functions from other packages and have their own test. Shouuld have focused more on testing things that I created.
- Learn how to build a Restful api
- Learn how to test an api
- Learn how to host an api on heroku
- Implement async/await functions
- Learn how to validate incoming request
- clone then install all npm packages with
npm install
- type
npm run serverStart
into the command line of the api folder
- clone then install all npm packages with
npm install
- change all of the protocals and domains wherever there are fetch requests
await fetch('https://agile-mesa.herokuapp.com/
Should be changed toawait fetch(http://localhost:3000/)
npm run start
you should be able to run and make changes to the database locally