This is the repository of a REST-API that provides access to data about some of the projects done by Emmethub. It has been created using Expressjs and covers the 4 main http methods. It stores data in a JSON file. The comments the file app.js allow easy understanding of how it functions.
HTTP method | EndPoint | Public Access | Example |
---|---|---|---|
GET | /api/ | TRUE | https://emmethubprojectsrestapi.herokuapp.com/api/ |
GET | /api?id=2 | TRUE | https://emmethubprojectsrestapi.herokuapp.com/api?id=2 |
POST | /api/repositories/new/ | TRUE | https://emmethubprojectsrestapi.herokuapp.com/api/repositories/new/ |
PUT | /api/repository?id=2 | TRUE | https://emmethubprojectsrestapi.herokuapp.com/api/repository?id=2 |
DELETE | /api/repository?id=2 | TRUE | https://emmethubprojectsrestapi.herokuapp.com/api/repository?id=2 |
sudo apt install nodejs #(for linux platform)
npm i
- Add the below line in your package.json file as one of the scripts value:
"dev": "nodemon app.js"
npm run dev
If while using the GET endpoint no JSON data is returned it means that someone used the DELETE endpoint to delete all the data provided by this API. Hence you can: 1.Clone this repo and run it locally, that way it will work well with all the original data. 2.or use the projectsData.json file in this repo together with the PUT method to add data to the hosted api.
npm init
npm i express
npm i nodemon --save-dev
- Node
- Express
- Nodemon
- Add this in package.json
"engines": {
"node": "14.15.1"
}
- Then run the following terminal commands:
install heroku
heroku login
touch Procfile
- Add this line in the Procfile which will depend with the name of your server file which in my case is app.js:
web: node app.js
- Then run the following terminal commands:
heroku create
heroku login
touch Procfile
git add .
git commit -m"first deploy to heroku"
## optional for pushing to github: git push -u origin master
git push heroku master
app.js
package-lock.json
projectsData.json
LICENSE.txt
package.json
permaProjectData.json
README.md
This project is MIT licensed see my MIT LICENSE for details.
Copyright © 2021 Charles Kimani & Emmethub.
- Website: https://emmethub.com/founder
- Github: @kimanicharles911
- LinkedIn: @kimanicharles
Give a ⭐️ if this project helped you!