{"id":13550731,"url":"https://github.com/urish/firebase-server","last_synced_at":"2025-04-03T00:34:45.012Z","repository":{"id":20433046,"uuid":"23709739","full_name":"urish/firebase-server","owner":"urish","description":"Firebase Realtime Database Server Implementation","archived":true,"fork":false,"pushed_at":"2021-05-10T08:18:15.000Z","size":663,"stargazers_count":676,"open_issues_count":0,"forks_count":95,"subscribers_count":26,"default_branch":"master","last_synced_at":"2024-05-10T03:43:20.314Z","etag":null,"topics":["database","firebase","firebase-database","firebase-server","javascript","server-socket","testing-tools","typescript"],"latest_commit_sha":null,"homepage":"","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/urish.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-09-05T16:18:55.000Z","updated_at":"2024-01-23T07:42:59.000Z","dependencies_parsed_at":"2022-07-26T09:17:46.986Z","dependency_job_id":null,"html_url":"https://github.com/urish/firebase-server","commit_stats":null,"previous_names":[],"tags_count":30,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/urish%2Ffirebase-server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/urish%2Ffirebase-server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/urish%2Ffirebase-server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/urish%2Ffirebase-server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/urish","download_url":"https://codeload.github.com/urish/firebase-server/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246916735,"owners_count":20854511,"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":["database","firebase","firebase-database","firebase-server","javascript","server-socket","testing-tools","typescript"],"created_at":"2024-08-01T12:01:36.768Z","updated_at":"2025-04-03T00:34:39.994Z","avatar_url":"https://github.com/urish.png","language":"TypeScript","readme":"# Project Deprecated!\n\n\u003e This project has reached its end-of-life, and will no longer be maintained. For information about the official alternative from the Firebase team, have a look at the [Firebase Local Emulators Migration Guide](docs/firebase-emulators.md).\n\nMoving forward, new features will not be added, and only security-related bugfixes will be released. \n\nfirebase-server\n===============\n\nFirebase Web Socket Protocol Server. Useful for emulating the Firebase server in tests.\n\nCopyright (C) 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, Uri Shaked and contributors\n\n[![Build Status](https://travis-ci.org/urish/firebase-server.png?branch=master)](https://travis-ci.org/urish/firebase-server)\n[![Coverage Status](https://coveralls.io/repos/urish/firebase-server/badge.png)](https://coveralls.io/r/urish/firebase-server)\n[![npm version](https://badge.fury.io/js/firebase-server.png)](https://badge.fury.io/js/firebase-server)\n\nInstallation\n------------\n\nYou can install firebase-server through npm:\n\n`npm install --save-dev firebase-server`\n\nor yarn:\n\n`yarn add -D firebase-server`\n\nUsage examples\n-------------\n\n```js\nconst FirebaseServer = require('firebase-server');\n\nnew FirebaseServer(5000, 'localhost', {\n  states: {\n    CA: 'California',\n    AL: 'Alabama',\n    KY: 'Kentucky'\n  }\n});\n```\n\nAfter running this server, you can create a Firebase client instance that connects to it:\n\n```js\nimport * as firebase from 'firebase/app';\nimport 'firebase/database';\n\nconst app = firebase.initializeApp({\n  databaseURL: `ws://localhost:5000`,\n});\n\napp.database().ref().on('value', (snap) =\u003e {\n  console.log('Got value: ', snap.val());\n});\n```\n\n### Setup with global test hooks\n\nIn the case of Mocha, you'd do something like the example below.\n\n```js\n// =\u003e e.g. global-test-hooks.js\nconst FirebaseServer = require(\"firebase-server\");\n\nlet firebaseServer;\n\nbefore(() =\u003e {\n   firebaseServer = new FirebaseServer(5000, \"localhost\");\n});\n\nafter(async () =\u003e {\n   await firebaseServer.close();\n});\n```\n\n```\n// =\u003e require the file with the --file flag\nmocha --file /path/to/global-test-hooks.js\n```\n\n### Command Line Interface\n\nThis package installs a CLI script called `firebase-server`.\nIt can be installed locally or globally. If installed locally, use the\nfollowing path to start the server: `./node_modules/.bin/firebase-server`\n\nThe following command will start a firebase server on port 5555:\n\n\tfirebase-server -p 5555\n\n... and with a specified bind IP address:\n\n\tfirebase-server -p 5555 -a 0.0.0.0\n\nTo bootstrap the server with some data you can use the `-d,--data` or the `-f,--file` option.\n_Note: The file option will override the data option._\n\n\tfirebase-server -d '{\"foo\": \"bar\"}'\n\n\tfirebase-server -f ./path/to/data.json\n\nTo load [Firebase Security rules](https://firebase.google.com/docs/database/security/) upon startup you can use the `-r,--rules` option.\n\n\tfirebase-server -r ./path/to/rules.json\n\nYou can also specify a shared client auth token secret with the `-s` argument:\n\n\tfirebase-server -s some-shared-secret\n\nTo enable REST API, run:\n\n\tfirebase-server -e\n\n_Note: currently REST API does not implement authentication or\nauthorization._\n\nTo daemonize the server process, use:\n\n\tfirebase-server -b\n\nTo write the PID to a file, use:\n\n\tfirebase-server --pid /var/run/firebase-server.pid\n\n_Note: PID file can be written with or without daemonization, and is NOT\nwritten by default when daemonizing.\n\nFor more information, run:\n\n\tfirebase-server -h\n\n### FirebaseServer methods\n\nThe constructor signature is `FirebaseServer(portOrOptions, name, data)` where\n`portOrOptions` is either a port number or a\n[`WebSocket.Server`](https://github.com/websockets/ws/blob/master/doc/ws.md#new-websocketserveroptions-callback)\noptions object with either `port` or `server` set. `name` is optional and is\njust used to report the server name to clients. `data` is the initial contents\nof the database.\n\nIf you want the server to pick a free port for you, simply use the value `0` for the port. You can then get the\nassigned port number by calling the `getPort()` method on the returned server object.\n\nFirebaseServer instances have the following API:\n\n* `close(): Promise` - Stops the server (closes the server socket)\n* `getValue()` - Returns a promise that will be resolved with the current data on the server\n* `exportData()` - Returns a promise that will be resolved with the current data on the server, including priority values.\n\tThis is similar to [DataSnapshot.exportVal()](https://www.firebase.com/docs/web/api/datasnapshot/exportval.html).\n* `address()` - Returns the address the server is listening on\n* `port(): number` - Returns the port number the server is listening on\n* `setRules(rules)` - Sets the security rules for the server. Uses the [targaryen](https://github.com/goldibex/targaryen)\n\tlibrary for rule validation.\n* `setAuthSecret(secret)` - Sets the shared secret used for validating [Custom Authentication Tokens](https://www.firebase.com/docs/web/guide/login/custom.html).\n* `setTime(timestamp)` - Sets the server time. The server time is returned by [ServerValue.TIMESTAMP](https://www.firebase.com/docs/web/api/servervalue/timestamp.html)\n    and is also used for checking the validity of Custom Authentication Tokens.\n\n### Debug logging\n\nThis project uses the excellent [`debug`](https://www.npmjs.com/package/debug) module for logging.\nIt is configured by setting an environment variable:\n\n```sh\n$ DEBUG=* mocha                                # log everything\n$ DEBUG=firebase-server* mocha                 # log everything from firebase-server\n$ DEBUG=firebase-server:token-generator mocha  # log output from specific submodule\n```\n\nAdvanced options are available from the [`debug docs`](https://www.npmjs.com/package/debug)\n\nLicense\n----\n\nReleased under the terms of MIT License:\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n'Software'), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","funding_links":[],"categories":["TypeScript","Projects by main language"],"sub_categories":["Old Projects"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Furish%2Ffirebase-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Furish%2Ffirebase-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Furish%2Ffirebase-server/lists"}