{"id":20857172,"url":"https://github.com/walkingriver/notify-api","last_synced_at":"2026-04-24T06:32:58.808Z","repository":{"id":38809813,"uuid":"163585904","full_name":"walkingriver/notify-api","owner":"walkingriver","description":"A firebase-hosted web service used in my @Pluralsight course on Builidng PWAs with @IonicFramework.","archived":false,"fork":false,"pushed_at":"2023-03-06T10:35:44.000Z","size":398,"stargazers_count":1,"open_issues_count":8,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-19T07:13:27.277Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/walkingriver.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-12-30T12:32:05.000Z","updated_at":"2021-09-14T12:50:02.000Z","dependencies_parsed_at":"2024-11-18T04:36:49.420Z","dependency_job_id":"e2a9c91b-18d8-4d72-84be-7c23bf76cf98","html_url":"https://github.com/walkingriver/notify-api","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/walkingriver%2Fnotify-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/walkingriver%2Fnotify-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/walkingriver%2Fnotify-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/walkingriver%2Fnotify-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/walkingriver","download_url":"https://codeload.github.com/walkingriver/notify-api/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243230060,"owners_count":20257640,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-18T04:36:40.113Z","updated_at":"2025-12-26T06:39:06.730Z","avatar_url":"https://github.com/walkingriver.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Background\n\nAs part of my recent Pluralsight Course, [Building Progressive Web Apps with Ionic](https://app.pluralsight.com/library/courses/progressive-web-apps-ionic/), I needed a public-facing API that its demo application could call. I implemented a simple Node/Express web service and deployed it to Firebase Functions using Google free \"Spark\" Plan. One major drawback to the Spark Plan is that it has a pretty low threshold limit for the number of requests per minute it will allow. In this post, I will describe how you can download the web service's code and host it both locally and in your own Firebase account, and then how to modify the course's demo app to call your version instead of mine.\n\n\u003c!--more--\u003e\n\n\n# Install the Prerequisites\n\nIf you are following along in the course, and have completed installing the tools, you should have everything you need already.\n\n## NodeJS\nYou will need at least Node 6 to run the API. You can download it directly from www.nodejs.org.\n\nOnce Node is installed, you also have `npm`, and can use it to install the rest of the tooling you'll need.\n\n## Firebase CLI\n\nNext, install the Firebase tools.\n\n```bash\nnpm install -g firebase-tools\n```\n\n# Clone the Repository\n\nWith Node and Firebase out of the way, you can clone the project's repository from GitHub. Remember, cloning creates a folder, so there is no need to provide an empty folder first. Use either of the following commands, depending on how you prefer to interact with GitHub.\n\n```bash\ngit clone https://github.com/walkingriver/notify-api.git\n# or\ngit clone git@github.com:walkingriver/notify-api.git\n```\n\n# Install the Dependencies\n\nEnter the folder created during the repository clone, by default it will be `notify-api`, and then install its dependencies.\n\n```bash\ncd notify-api\nnpm install\n```\n\nNext is a quirk I find particularly annoying. The API lives in a folder called `functions`, and it also has a `package.json` file. Thus, it also has dependencies. Enter that directory and install them, too.\n\n```bash\ncd functions\nnpm install\ncd ..\n```\n\n# Create Firebase App\n\nOpen a browser to the [Firebase Console](https://console.firebase.google.com). If you have not yet registered with Firebase, do that first. \n\nOnce at the console, Add a new project. Call it anything you want, but remember your choice. If you pick something that isn't unique, such as \"notify-api,\" some random characters will be automatically appended for you. You can probably keep the default settings, but you may want to ensure that the Location is somewhere close to you. Accept the terms and click `Create Project`.\n\n# Connect Project to Firebase App\n\nNow that you have a project, you need to connect it to the repo that you just cloned. First, make sure you are logged into Firebase. Enter the following command.\n\n```base\nfirebase login\n```\n\nIf you are not logged in, you will be directed to do so, and a browser will open to let you do that. If you are logged in, the command will tell you so.\n\nNext, enter the following command to connect this local project to the Firebase project.\n\n```bash\nfirebase use --add\n```\n\nAll of your Firebase projects will be displayed. Use the up/down arrow keys to select the project you just created and continue.\n\nYou will be asked to provide an alias, such as \"staging\". This is to enable support of CICD, where you can deploy different versions of the app to different projects. In this case, I recommend keeping it simple. I named mine \"default.\" Type your preferred alias and continue.\n\n# Verify Service Functionality\n\nTo verify that the service is working, you will want to build it and run it locally. These commands should be run from inside the `functions` folder.\n\n```bash\ncd functions \nnpm run build\nfirebase emulators:start --only functions\n```\n\nIf all goes well, you will be provided with some command output that includes the URL of the API itself. Here is the output from mine.\n\n```bash\ni  Starting emulators: [\"functions\"]\n✔  functions: Using node@6 from host.\n✔  functions: Emulator started at http://localhost:5001\ni  functions: Watching \"/Users/callm031/git/wr/notify-api/functions\" for Cloud Functions...\ni  functions: HTTP trigger initialized at http://localhost:5001/my-notify-api/us-central1/api\n```\n\nOpen a browser to the URL provided. There is no route listening there, so add `latest` to the URL, and you should be rewarded with a JSON object that looks like this...\n\n```json\n{\n  \"event\": {\n    \"id\": 50,\n    \"created\": \"2019-05-21T16:55:22.114Z\",\n    \"dialed\": \"911\",\n    \"caller\": {\n      \"id\": \"ff196571-00c3-421c-8d84-01d1964599a3\",\n      \"firstName\": \"Virgil\",\n      \"lastName\": \"Glover\",\n      \"phone\": \"1-850-512-1051 x5535\",\n      \"address\": {\n        \"street1\": \"4684 Fahey Highway\",\n        \"street2\": \"Apt. 131\",\n        \"city\": \"South Daytonfurt\",\n        \"state\": \"CT\",\n        \"zip\": \"54912\"\n      }\n    }\n  },\n  \"links\": {\n    \"acknowledgements\": \"/acknowledgements/50/1558457722114\",\n    \"self\": \"/event/50\",\n    \"next\": \"/event/49\"\n  }\n}\n```\n\n\nPress Ctrl-C to shut down the Firebase emulator.\n\n# Deploy to Firebase\n\nOnce you know it is working locally, you can deploy it to your Firebase project. Make sure you are in the root directory of the project.\n\n```bash\ncd ..\nfirebase deploy --only functions\n```\n\nAs with the emulator, you will see a lengthy and informative output from the deploy command, which will also include the public URL of the deployed API.\n\n```bash\nfirebase deploy --only functions\n\n=== Deploying to 'my-notify-api'...\n\ni  deploying functions\nRunning command: npm --prefix \"$RESOURCE_DIR\" run lint\n\n\u003e functions@ lint /Users/callm031/git/wr/notify-api/functions\n\u003e tslint --project tsconfig.json\n\nRunning command: npm --prefix \"$RESOURCE_DIR\" run build\n\n\u003e functions@ build /Users/callm031/git/wr/notify-api/functions\n\u003e tsc\n\n✔  functions: Finished running predeploy script.\ni  functions: ensuring necessary APIs are enabled...\n✔  functions: all necessary APIs are enabled\ni  functions: preparing functions directory for uploading...\n⚠  functions: Deploying functions to Node 6 runtime, which is deprecated. Node 8 is available and is the recommended runtime.\ni  functions: packaged functions (51.93 KB) for uploading\n✔  functions: functions folder uploaded successfully\ni  functions: creating Node.js 6 (Deprecated) function api(us-central1)...\n✔  functions[api(us-central1)]: Successful create operation. \nFunction URL (api): https://us-central1-my-notify-api.cloudfunctions.net/api\n\n✔  Deploy complete!\n```\n\nMake note of the URL provided, as you will need it in the next step. If you want to see it in action, as you did before, open a browser to that URL and again add `latest` to the URL, and you should be rewarded with the same JSON object as you saw when running it locally.\n\n# Modify Notify Demo App to Use New API\n\nNow it is time to open the Notify demo app project, which should already have if you are following along with the course. \n\nThis value needs to be copied to `src/app/events.service.ts`, line 10 (assuming you have gotten that far in the tutorial). In my version of the Notify app, this section of the file looks like this...\n\n```typescript\n@Injectable({\n  providedIn: 'root'\n})\nexport class EventsService {\n  private endpoint = 'https://us-central1-ps-notify-api.cloudfunctions.net/api';\n\n  constructor(private http: HttpClient) { }\n```\n\nReplace the value of `endpoint` with the value provided in the output of the `firebase deploy` command.\n\n# Run Notify and Enjoy\n\nRedeploy the Notify demo app to firebase, either locally, or to your Firebase application.\n\n```bash\nfirebase serve\n# or\nfirebase deploy\n```\n\nOpen a browser to Notify using the URL provided by the above command. You now have your own version of the API. And you probably understand why I did not want to include this in the course itself. \n\n## Note on API Limits\n\nEven with your own Spark hosting plan, you will probably run into API limits while developing. The good news is that you won't be competing with anyone else for those resources. When you do run into limits, your browser may complain about a CORS violation. I believe this to be a misleading error. Simply wait about 60 seconds for the API limit to reset, and try again. \n\nOf course, once you are using cached resources through the demo app's service worker, you will see this problem less often.\n\n## Other Hosting Solutions?\n\nI wonder sometimes whether or not hosting the web app elsewhere might be a better solution. My backup preference is to spin up a web application in Microsoft Azure, and I may do that one of these days. In the meantime, if anyone has other suggestions, please feel free to comment.\n\n----\n\nIf you find any errors in this post or have other feedback, please follow me and comment on Twitter. I'm [@walkingriver](https://twitter.com/walkingriver).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwalkingriver%2Fnotify-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwalkingriver%2Fnotify-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwalkingriver%2Fnotify-api/lists"}