{"id":13850173,"url":"https://github.com/appleby/elm-firebase-crud","last_synced_at":"2025-07-12T21:33:17.138Z","repository":{"id":79482720,"uuid":"90323646","full_name":"appleby/elm-firebase-crud","owner":"appleby","description":"Example of a toy elm CRUD app with firebase used for backend","archived":true,"fork":false,"pushed_at":"2019-01-07T01:25:31.000Z","size":91,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-08-05T20:31:54.033Z","etag":null,"topics":["elm","firebase"],"latest_commit_sha":null,"homepage":null,"language":"Elm","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/appleby.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}},"created_at":"2017-05-05T01:12:38.000Z","updated_at":"2023-01-28T19:21:37.000Z","dependencies_parsed_at":"2024-01-18T09:57:50.622Z","dependency_job_id":"dd8146d6-2e51-4461-bece-40a46362aa44","html_url":"https://github.com/appleby/elm-firebase-crud","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/appleby%2Felm-firebase-crud","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/appleby%2Felm-firebase-crud/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/appleby%2Felm-firebase-crud/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/appleby%2Felm-firebase-crud/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/appleby","download_url":"https://codeload.github.com/appleby/elm-firebase-crud/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225839485,"owners_count":17532305,"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":["elm","firebase"],"created_at":"2024-08-04T20:01:00.633Z","updated_at":"2024-11-22T03:30:49.527Z","avatar_url":"https://github.com/appleby.png","language":"Elm","funding_links":[],"categories":["Elm"],"sub_categories":[],"readme":"# This repo is no more! It has been archived.\n\n# Overview\n\nThis repo contains an example [Elm](http://elm-lang.org/) todo-list application using [firebase](https://firebase.google.com/) for the backend. There is a live demo running at [https://elm-crud.firebaseapp.com](https://elm-crud.firebaseapp.com). The app doesn't do anything useful; It was just an excuse to try out Elm and firebase. You can log in anonymously by clicking the **Sign In** link in the navbar. After login, the task list is populated with some example data. All user accounts and data are automatically wiped 30 minutes after login.\n\nThe Elm code in this app communicates with the firebase client api via [Elm's javascript Ports](https://guide.elm-lang.org/interop/javascript.html). There is a nice-looking [elmfire] package for interacting with firebase, but, at the time of writing, it's in the process of being updated to work with Elm v0.18.\n\n# Elm version\n\nThis demo application targets Elm v0.18. I have no plans to upgrade it to Elm v0.19 or above.\n\n# Dev setup\n\n## Clone and install npm dependencies\n\n``` shell\ngit clone https://github.com/appleby/elm-firebase-crud.git\ncd elm-firebase-crud\nsudo npm install -g firebase-tools\nnpm install\ncd functions; npm install; cd ..\n```\n\n## Init firebase\n\nCreate a new firebase project in the [firebase console][fbconsole], then login to firebase and select your project.\n\n``` shell\nfirebase login\nfirebase use --add\n```\n\nFor more info on how to create a new project, see the [firebase web setup docs][fbsetup].\n\n## Install `firebase-app-config.json`\n\nNext, save the firebase web configuration to `secrets/firebase-app-config.json`. This file is not really a \"secret\" since it's meant to be distributed with your app, but it's convenient to stick it in the `secrets` directory, which is included in `.gitignore`.\n\n``` shell\nmkdir secrets\nfirebase setup:web \u003e secrets/firebase-app-config.json\nchmod 600 secrets/firebase-app-config.json\n```\n\nNow edit the file `secrets/firebase-app-config.json`. Remove everything except the actual config object, making it a valid JSON file. The file should look something like this:\n\n      {\n        \"apiKey\": \"\u003cYOUR-API-KEY\u003e\",\n        \"databaseURL\": \"https://\u003cYOUR-PROJECT\u003e.firebaseio.com\",\n        \"storageBucket\": \"\u003cYOUR-PROJECT\u003e.appspot.com\",\n        \"authDomain\": \"\u003cYOUR-PROJECT\u003e.firebaseapp.com\",\n        \"messagingSenderId\": \"\u003cYOUR-MSG-ID\u003e\",\n        \"projectId\": \"\u003cYOUR-PROJECT\u003e\"\n      }\n\n## Enable anonymous auth\n\nThis app uses the firebase anonymous auth provider. In the [firebase console][fbconsole], click on **Authentication** then **SIGN-IN METHOD** and enable the Anonymous provider.\n\n## Test via localhost\n\nFirst, deploy the firebase rules and cloud functions; then start the dev server.\n\n``` shell\nfirebase deploy --only database,functions\nnpm run serve\n```\n\nThe site should now be running at http://localhost:3000/.\n\n## Deploy to firebase hosting\n\nYou can also deploy the site to firebase's hosting if you want it to be publicly accessible.\n\n``` shell\nnpm run build\nfirebase deploy\n```\n\nThe site should now be running at `https://\u003cYOUR-PROJECT\u003e.firebaseapp.com`.\n\n## Cloud functions\n\nThis firebase project contains the following cloud functions:\n\n| function name      | Triggered by   | description                                                                                                                                    |\n|--------------------|----------------|------------------------------------------------------------------------------------------------------------------------------------------------|\n| populateUserData   | account create | Populate the user's task list with example data on first login.                                                                                |\n| cleanupUserData    | account delete | Delete all user data from the database on user account deletion.                                                                               |\n| deleteUserAccounts | https          | Delete all user accounts with last login time \u003e 30 minutes ago. Intended to be triggered from the third-party cron service, like [cron-job.org][cronjoborg]. |\n\n### Enable running the `deleteUserAccounts` cloud function\n\nThe `deleteUserAccounts` cloud function is triggered via https, and will delete any user accounts with last login time \u003e 30 minutes ago. This function is intended to be run from a third-party cron service like [cron-job.org][cronjoborg]. There is no need to set this up if you don't intend to keep a publicly-accessible demo running.\n\nIn order to run the `deleteUserAccounts` cloud function, you first need to configure the cron.key via the [firebase functions config env](https://firebase.google.com/docs/functions/config-env).\n\n``` shell\nnpm install crypto\ncronkey=\"$(node -e \"console.log(require('crypto').randomBytes(20).toString('hex'))\")\"\nfirebase functions:config:set cron.key=\"$cronkey\"\nfirebase deploy --only functions\n```\n\nThe `firebase deploy` command should print the url to hit for the `deleteUserAccounts` functions. It will look something like:\n\n    https://us-central1-\u003cYOUR-PROJECT\u003e.cloudfunctions.net/deleteUserAccounts\n\nYou can test that the function is working via `curl`, like so. Note the required `?key=` query parameter:\n\n``` shell\ncurl https://us-central1-\u003cYOUR-PROJECT\u003e.cloudfunctions.net/deleteUserAccounts?key=\"$cronkey\"\n```\n\nAnd check that there were no errors in the firebase logs.\n\n``` shell\nfirebase functions:log\n```\n\n## Maintenance scripts\n\nIn the `scripts` directory, there is a `remove-db.js` script that will prompt before removing all data from the firebase database. To enable running the `remove-db.js` maintenance script, you first need to download a private key for the admin sdk service-account.\n\n1. Navigate to the [Service Accounts](https://console.firebase.google.com/project/_/settings/serviceaccounts/adminsdk) tab of you project's settings page.\n2. Select your project.\n3. Click the **Generate New Private Key** button.\n4. Save the private file to `secrets/firebase-adminsdk-service-account-private-key.json`\n5. `chmod 600 secrets/firebase-adminsdk-service-account-private-key.json`\n\nSee the [firebase admin setup docs](https://firebase.google.com/docs/admin/setup#add_firebase_to_your_app) for more detailed instructions on setting up admin sdk access.\n\nOnce you've downloaded the admin sdk private key, you can run `npm run remove-db` or, equivalently, `node ./scripts/remove-db.js` to completely wipe the firebase database configured as the `databaseUrl` property in `secrets/firebase-app-config.json`.\n\n\n\n[fbsetup]: https://firebase.google.com/docs/web/setup\n[fbconsole]: https://console.firebase.google.com/\n[elmfire]: https://github.com/ThomasWeiser/elmfire\n[cronjoborg]: https://cron-job.org\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fappleby%2Felm-firebase-crud","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fappleby%2Felm-firebase-crud","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fappleby%2Felm-firebase-crud/lists"}