/emmethub_projects_rest_api

#Capstone-Project | This is the repository of a REST-API that provides access to data about some of the projects done by Emmethub. It is created using Expressjs the Nodejs framework. https://emmethubprojectsrestapi.herokuapp.com/api

Primary LanguageJavaScriptMIT LicenseMIT

Version License: MIT

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.

Deployed at

API Usage
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

Setup/Installation Requirements

Install Dependencies
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"
Development Usage
npm run dev

No Data/JSON returned ?

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.

How It Was Built

Node
npm init
npm i express
npm i nodemon --save-dev
Dependencies
  • Node
  • Express
  • Nodemon
Deploy to Heroku
  • 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

folder structure

app.js 
package-lock.json      
projectsData.json
LICENSE.txt  
package.json  
permaProjectData.json  
README.md

License and Copyright Information.

This project is MIT licensed see my MIT LICENSE for details.
Copyright © 2021 Charles Kimani & Emmethub.

Author

👤 Charles Kimani

Show your support

Give a ⭐️ if this project helped you!