File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ An object that contains:
22221 . run (_ function_ ): A function to run the server.
2323 Signature: (port, callback) => {}
24242 . app (_ object_ ): The Koa app.
25+ 3 . db (_ object_ ): The ` db ` implementation.
2526
2627### Usage
2728
Original file line number Diff line number Diff line change @@ -74,7 +74,7 @@ you can use to attach other handlers etc.
7474
7575``` js
7676const KoaStatic = require (' koa-static' );
77- const Server = require (' boardgame.io/server' );
77+ const Server = require (' boardgame.io/server' ). Server ;
7878const TicTacToe = require (' ./tic-tac-toe' );
7979
8080const server = Server ({ games: [TicTacToe] });
@@ -93,3 +93,26 @@ Client({
9393 multiplayer: { server: ' hostname:port' },
9494});
9595```
96+
97+ #### Database
98+
99+ The default storage implementation is an in-memory map. However,
100+ you can provide your own adapter to connect to any backend, or
101+ use the bundled MongoDB connector.
102+
103+ ``` js
104+ const { Server , Mongo } = require (' boardgame.io/server' );
105+ const TicTacToe = require (' ./tic-tac-toe' );
106+
107+ const server = Server ({
108+ games: [TicTacToe],
109+ db: new Mongo ({
110+ url: ' mongodb://...' ,
111+ dbname: ' bgio' ,
112+ }),
113+ });
114+
115+ server .run (8000 );
116+ ```
117+
118+ !> You can get a free MongoDB instance at places like mlab.com.
Original file line number Diff line number Diff line change 77 */
88
99import { Server } from '../src/server/index.js' ;
10+ import { Mongo } from '../src/server/db.js' ;
1011
11- export { Server } ;
12+ export { Server , Mongo } ;
You can’t perform that action at this time.
0 commit comments