Skip to content

Commit f696a8f

Browse files
authored
Adding an entrypoint for firebase-admin-node (#216)
* Expose init function for admin SDK * Fixing issues with module.exports for @firebase/database * [AUTOMATED]: Prettier Code Styling * Refactor namespaces -> namespace
1 parent 9f4fb91 commit f696a8f

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

packages/database/index.node.ts

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,28 @@ import * as TEST_ACCESS from './src/api/test_access';
2525
import { isNodeSdk } from '@firebase/util';
2626
import './src/nodePatches';
2727

28+
/**
29+
* A one off register function which returns a database based on the app and
30+
* passed database URL.
31+
*
32+
* @param app A valid FirebaseApp-like object
33+
* @param url A valid Firebase databaseURL
34+
*/
35+
export function initStandalone(app, url) {
36+
return {
37+
instance: RepoManager.getInstance().databaseFromApp(app, url),
38+
namespace: {
39+
Reference,
40+
Query,
41+
Database,
42+
enableLogging,
43+
INTERNAL,
44+
ServerValue: Database.ServerValue,
45+
TEST_ACCESS
46+
}
47+
};
48+
}
49+
2850
export function registerDatabase(instance: FirebaseNamespace) {
2951
// Register the Database Service with the 'firebase' namespace.
3052
const namespace = instance.INTERNAL.registerService(
@@ -45,7 +67,7 @@ export function registerDatabase(instance: FirebaseNamespace) {
4567
);
4668

4769
if (isNodeSdk()) {
48-
module.exports = namespace;
70+
module.exports = Object.assign({}, namespace, { initStandalone });
4971
}
5072
}
5173

0 commit comments

Comments
 (0)