-
Notifications
You must be signed in to change notification settings - Fork 702
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move mongodb and firebase deps to devDependencies
- Loading branch information
1 parent
9fa814c
commit 6a8b657
Showing
4 changed files
with
283 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
# Storage | ||
|
||
The framework comes bundled with various connectors to different backends | ||
depending on how you want to persist your game state. | ||
|
||
### MongoDB | ||
|
||
First, install the `mongodb` package: | ||
|
||
``` | ||
npm install --save mongodb | ||
``` | ||
|
||
Then modify your server spec to indicate that you want to connect to Mongo: | ||
|
||
```js | ||
const { Server, Mongo } = require('boardgame.io/server'); | ||
const { TicTacToe } = require('./game'); | ||
|
||
const server = Server({ | ||
games: [TicTacToe], | ||
|
||
db: new Mongo({ | ||
url: 'mongodb://...', | ||
dbname: 'bgio', | ||
}), | ||
}); | ||
|
||
server.run(8000); | ||
``` | ||
|
||
!> You can get a free Mongo instance at places like [mLab](https://mlab.com/). | ||
|
||
### Firebase | ||
|
||
First, install the necessary packages: | ||
|
||
``` | ||
npm install --save firebase | ||
``` | ||
|
||
Then modify your server spec to indicate that you want to connect to Firebase: | ||
|
||
```js | ||
const { Server, Firebase } = require('boardgame.io/server'); | ||
const { TicTacToe } = require('./game'); | ||
|
||
const server = Server({ | ||
games: [TicTacToe], | ||
|
||
db: new Firebase({ | ||
config: { | ||
apiKey: '...', | ||
authDomain: '...', | ||
databaseURL: '...', | ||
projectID: '...', | ||
}, | ||
dbname: 'bgio', | ||
}), | ||
}); | ||
|
||
server.run(8000); | ||
``` |
Oops, something went wrong.