FireShort icon indicating copy to clipboard operation
FireShort copied to clipboard

Implementation of FireShort API and its Documentation

Open JithinAntony4 opened this issue 5 years ago • 15 comments

Implement FireShort API and its complete documentation:

  • [x] Implement FireShort API
  • [x] FireShort API Documentation has been added
  • [x] Documented how to setup cloud function (FireShort API) on both cloud and locally

What is the current behavior?

  • Same as previous except in the API Section

What is the new behavior?

  • A new button added in the Admin dashboard (API Settings)
  • A Page has been added (/admin/settings/api), here I specify all information related to the FireShort API
  • Added new dependencies
  • Added new README.md for How to setup Firebase Cloud Functions

Other information?

It will never conflict with other files, the only files which will affect are Admin.js, App.js, package.json and package-lock.json because

JithinAntony4 avatar Oct 02 '20 12:10 JithinAntony4

Thanks for opening this pull request 🎉🎉! Please check out our contributing guidelines and provide us atleast 24 hours to review this PR

boring-cyborg[bot] avatar Oct 02 '20 12:10 boring-cyborg[bot]

Hey @JithinAntony4, looks like you have made an error in your imports in the Settings.js file : "Module not found: Can't resolve 'swagger-ui-react' in '/Users/monish/Downloads/fireshort-master/src/components'" please fix this

@monizb I'm already added swagger-ui-react on package.json make sure that you've installed.

JithinAntony4 avatar Oct 02 '20 13:10 JithinAntony4

Hey @JithinAntony4 , thanks for this amazing PR 🥳🥳🥳 Very few of the PRs like yours are made in a good spirit for Hactoberfest, I have looked at the UI part and have seen you using Swagger UI for API documentation part, I havent deployed the functions part locally and had a few questions which hopefully you can give me a clarity about:

  1. How is the API Key being generated?
  2. What are the steps taken by you on the authentication part of the request
  3. How would you write the perfect Firestore security rules for the API part?

Also can you please provide a gif showing the API in action so that we can have some clarity, thanks a lot and congragulations once again! 🥳🥳

monizb avatar Oct 02 '20 13:10 monizb

@JithinAntony4 Some of the errors and Bugs I have noticed by now:

  1. While testing the APIs I always get this error: TypeError: Failed To Fetch .But When I try to use the API from Postman It seems to be working 4 out of 5 times and sometimes returns the same Failed to Fetch (I have tested only get all URLs API right now
  2. The Object keys returned are not consistent, some times it returns lurl key first sometime locked key first
  3. When I try to use the create API route, it does create a new link with the speicifed lurl but the shorturl is empty, also the name key should be optional and when left blank should automatically create the short id as it happens right now.

The 3rd problem seems to happen because you are not setting the 'curl' property in the DB rather you are adding a 'name' property which is not recognised by the app.

monizb avatar Oct 02 '20 14:10 monizb

Hey @JithinAntony4 , thanks for this amazing PR 🥳🥳🥳 Very few of the PRs like yours are made in a good spirit for Hactoberfest, I have looked at the UI part and have seen you using Swagger UI for API documentation part, I havent deployed the functions part locally and had a few questions which hopefully you can give me a clarity about:

  1. How is the API Key being generated?
  2. What are the steps taken by you on the authentication part of the request
  3. How would you write the perfect Firestore security rules for the API part?

Also can you please provide a gif showing the API in action so that we can have some clarity, thanks a lot and congragulations once again! 🥳🥳

Hey @monizb

  • Currently there is only one API Key for the Admin, If keys didn't present, one Key automatically generated using nanoid and save it.
  • Accessing API is like curl -X GET "https://%YOUR_CLOUD_FUNCTION_URL%/v1/url" -H "accept: application/json" -H "api_key: API_KEY" (getting all links / urls)

JithinAntony4 avatar Oct 02 '20 14:10 JithinAntony4

  1. While testing the APIs I always get this error: TypeError: Failed To Fetch .But When I try to use the API from Postman It seems to be working 4 out of 5 times and sometimes returns the same Failed to Fetch (I have tested only get all URLs API right now Hey @monizb If you use cloud functions in locally there's a problem with chrome web security in order to get rid restart chrome or chromium with the --disable-web-security argument. example chrome.exe --disable-web-security --user-data-dir="[some directory here]". if you run in locally make sure that scheme should be http

JithinAntony4 avatar Oct 02 '20 14:10 JithinAntony4

3. When I try to use the create API route, it does create a new link with the speicifed lurl but the shorturl is empty, also the name key should be optional and when left blank should automatically create the short id as it happens right now.

@monizb This bug is fixed now.

JithinAntony4 avatar Oct 02 '20 14:10 JithinAntony4

  1. While testing the APIs I always get this error: TypeError: Failed To Fetch .But When I try to use the API from Postman It seems to be working 4 out of 5 times and sometimes returns the same Failed to Fetch (I have tested only get all URLs API right now Hey @monizb If you use cloud functions in locally there's a problem with chrome web security in order to get rid restart chrome or chromium with the --disable-web-security argument. example chrome.exe --disable-web-security --user-data-dir="[some directory here]". if you run in locally make sure that scheme should be http

How would a normal user use this without disabling that? I think you need to use cors package to fix that security issue there. Also have you edited the name key to curl?

monizb avatar Oct 02 '20 15:10 monizb

  1. While testing the APIs I always get this error: TypeError: Failed To Fetch .But When I try to use the API from Postman It seems to be working 4 out of 5 times and sometimes returns the same Failed to Fetch (I have tested only get all URLs API right now Hey @monizb If you use cloud functions in locally there's a problem with chrome web security in order to get rid restart chrome or chromium with the --disable-web-security argument. example chrome.exe --disable-web-security --user-data-dir="[some directory here]". if you run in locally make sure that scheme should be http

How would a normal user use this without disabling that? I think you need to use cors package to fix that security issue there. Also have you edited the name key to curl?

@monizb cors bug has been fixed

JithinAntony4 avatar Oct 02 '20 19:10 JithinAntony4

Sider detected 2 errors on analyzing the commit d501f54.

We recommend fixing them as possible by updating the dependencies, configuring the analysis tool, configuring sider.yml, turning off unused tools, and so on.

If you have problems or questions still, feel free to ask us via chat. 💬


You can turn off this notification if you don't want to receive it from now on.

ghost avatar Oct 03 '20 05:10 ghost

@JithinAntony4 right now Signup Features are being added and the entire DB structure is being changed, so it will take a few days to change this PR and merge it,so I am going to add the hacktoberbest-accepted label so that your review period starts

monizb avatar Oct 03 '20 11:10 monizb

@JithinAntony4 are you up for changing the API to store the data based on the recent DB structure?

monizb avatar Oct 06 '20 16:10 monizb

@JithinAntony4 are you up for changing the API to store the data based on the recent DB structure?

@monizb yeah just take a look on it .

JithinAntony4 avatar Oct 06 '20 16:10 JithinAntony4

@monizb I've resolved the conflict, just a look at it

JithinAntony4 avatar Oct 11 '20 11:10 JithinAntony4

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Dec 10 '20 12:12 stale[bot]

This PR seems to have gone stale, adding label accordingly

github-actions[bot] avatar Feb 19 '23 02:02 github-actions[bot]