-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(webapp): migrate server project to server.ts
- Loading branch information
Showing
62 changed files
with
494 additions
and
304 deletions.
There are no files selected for viewing
Binary file added
BIN
+34.1 KB
.yarn/cache/@cspotcode-source-map-support-npm-0.8.1-964f2de99d-5718f26708.zip
Binary file not shown.
Binary file added
BIN
+27.5 KB
.yarn/cache/@jridgewell-trace-mapping-npm-0.3.9-91625cd7fb-d89597752f.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+2.56 KB
.yarn/cache/@types-strip-json-comments-npm-0.0.30-4d685379c3-829ddd3896.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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
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
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
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,43 @@ | ||
import { Server, Origins } from "boardgame.io/server"; | ||
import next from 'next'; | ||
import url from "url"; | ||
import { OpenStarTerVillage } from "./game"; | ||
|
||
async function serve() { | ||
const port = Number(process.env.PORT) || 8000; | ||
const apiPort = Number(process.env.API_PORT) || 8080; | ||
const dev = process.env.NODE_ENV !== 'production'; | ||
const app = next({ dev }); | ||
const handle = app.getRequestHandler(); | ||
|
||
const server = Server({ | ||
games: [OpenStarTerVillage], | ||
origins: [ | ||
// Allow localhost to connect, except when NODE_ENV is 'production'. | ||
Origins.LOCALHOST_IN_DEVELOPMENT, | ||
], | ||
}); | ||
const mainServerConfig = { | ||
port, | ||
callback: () => console.log(`Main server running on port ${port}...`), | ||
}; | ||
const lobbyConfig = { | ||
apiPort, | ||
apiCallback: () => console.log(`Lobby api running on port ${apiPort}`), | ||
}; | ||
|
||
await app.prepare(); | ||
server.run({ | ||
...mainServerConfig, | ||
lobbyConfig, | ||
}, () => { | ||
server.app.use(async (ctx, next) => { | ||
const parsedUrl = url.parse(ctx.req.url!, true); | ||
await handle(ctx.req, ctx.res, parsedUrl); | ||
ctx.respond = false; | ||
await next(); | ||
}); | ||
}); | ||
} | ||
|
||
serve(); |
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,15 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "ES2017", | ||
"module": "commonjs", | ||
"lib": ["ES2017"], | ||
"outDir": "./dist", | ||
"strict": true, | ||
"moduleResolution": "node", | ||
"resolveJsonModule": true, | ||
"esModuleInterop": true, | ||
"skipLibCheck": true, | ||
}, | ||
"include": ["./src/server.ts", "./src/game/**/*.ts"], | ||
"exclude": ["node_modules"] | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.