Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions docs/documentation/api/Server.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,20 @@ A config object with the following options:
1. `games` (_array_): a list of game implementations
(each should be an object conforming to the [Game API](/api/Game.md)).

2. `db` (_object_): the [database connector](/storage).
2. `origins` (_array_): a list of allowed origins for CORS.
For instance, this could be [`https://example.com`], or in the case of our examples, [`http://localhost:3000`]

3. `db` (_object_): the [database connector](/storage).
If not provided, an in-memory implementation is used.

3. `transport` (_object_): the transport implementation.
4. `transport` (_object_): the transport implementation.
If not provided, socket.io is used.

4. `uuid` (_function_): an optional function that returns a unique identifier, used to create new game IDs and — if `generateCredentials` is not specified — player credentials. Defaults to [nanoid](https://www.npmjs.com/package/nanoid).
5. `uuid` (_function_): an optional function that returns a unique identifier, used to create new game IDs and — if `generateCredentials` is not specified — player credentials. Defaults to [nanoid](https://www.npmjs.com/package/nanoid).

5. `generateCredentials` (_function_): an optional function that returns player credentials to store in the game metadata and validate against. If not specified, the `uuid` function will be used.
6. `generateCredentials` (_function_): an optional function that returns player credentials to store in the game metadata and validate against. If not specified, the `uuid` function will be used.

6. `authenticateCredentials` (_function_): an optional function that tests if a player’s move is made with the correct credentials when using the default socket.io transport implementation.
7. `authenticateCredentials` (_function_): an optional function that tests if a player’s move is made with the correct credentials when using the default socket.io transport implementation.

#### Returns

Expand Down
2 changes: 1 addition & 1 deletion docs/documentation/multiplayer.md
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ boardgame.io server module and provide it with our `TicTacToe` game object.
const { Server } = require('boardgame.io/server');
const { TicTacToe } = require('./Game');

const server = Server({ games: [TicTacToe] });
const server = Server({ games: [TicTacToe], origins: ['http://localhost:300'] });

server.run(8000);
```
Expand Down
5 changes: 3 additions & 2 deletions examples/react-web/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import TicTacToe from './src/tic-tac-toe/game';
import Chess from './src/chess/game';

const PORT = process.env.PORT || 8000;
const server = Server({ games: [TicTacToe, Chess] });
const origins = [`http://localhost:${PORT}`];
const server = Server({ games: [TicTacToe, Chess], origins });
server.run(PORT, () => {
console.log(`Serving at: http://localhost:${PORT}/`);
console.log(`Serving at: ${origins[0]}`);
});
Loading