]>
git.cworth.org Git - empires-server/log
Carl Worth [Mon, 4 May 2020 00:34:23 +0000 (17:34 -0700)]
Perform broadcasts of deregister and capture events
Allowing clients to track this state
Carl Worth [Sun, 3 May 2020 22:05:23 +0000 (15:05 -0700)]
Add an API for server-sent events at `/events`
So far there are two event types being sent here:
players: An event reporting the complete list of registered players
player-register: An event reporting a new player has registered
I'm not 100% sure these are all formatted correctly yet. I'll need to
implement a client to listen to these events and then check that.
Carl Worth [Sun, 3 May 2020 22:03:56 +0000 (15:03 -0700)]
Add some linting fixes
Specifically some missing semicolons and a missing const.
It's funny that I didn't realize that emacs was doing live linting of
JavaScript all along here, (and highlighting all problems with various
colors and underlining).
Carl Worth [Sun, 3 May 2020 02:28:12 +0000 (19:28 -0700)]
Use the cors package to set a permissive CORS header
Specifically, with this change the server will emit a header of:
Access-Control-Allow-Origin: *
allowing requests to come from anywhere (for now).
This was necessary in the testing that Kevin is currently doing (where
he his hosting his test front-end spearately from the server).
Carl Worth [Sun, 3 May 2020 02:26:43 +0000 (19:26 -0700)]
Add a dependency on the cors package
This commit was constructed with "npm install cors"
Carl Worth [Sun, 3 May 2020 02:24:34 +0000 (19:24 -0700)]
Add simple testing for the entire API
This is more "exercising" than testing, (it doesn't currently verify
the results), but I've verified the server isn't hitting any syntax
errors (with fairly decent code coverage I think) and I've manually
inspected the results to ensure they look correct.
Carl Worth [Sun, 3 May 2020 02:23:37 +0000 (19:23 -0700)]
Implement the rest of the API
This is up to date with commit
0411bdc5c4dbad187f7e25fa1fb40a23c3e0e940 of the empires-api as found
at: https://git.cworth.org/git/empires-api
Carl Worth [Sat, 2 May 2020 23:53:13 +0000 (16:53 -0700)]
Add an ID value to each player
This is a first baby step toward implementing the more complete API
for the game which we defined today, and which can be found here:
https://git.cworth.org/git/empires-api
In this commit we also introduce a 'Game' class to encapsulate all
data necessary for the game, (so the 'players' array we had before,
but also the 'next_player_id' which we need now).
Carl Worth [Sun, 26 Apr 2020 22:29:52 +0000 (15:29 -0700)]
fixup errant newline
Carl Worth [Sun, 26 Apr 2020 22:29:07 +0000 (15:29 -0700)]
Be a bit more berbose in variable names.
Preferring actual words "request" and "response" instead of
abbreviations "req" and "res".
Carl Worth [Sun, 26 Apr 2020 22:25:14 +0000 (15:25 -0700)]
Make the server store a list of players
Expecting both "name" and "character" on each post to the /register
API. Also add a /players API to list the players registered so far.
Carl Worth [Sun, 26 Apr 2020 22:15:53 +0000 (15:15 -0700)]
Extend our simple web API with a new /register endpoint
Which uses body-parser and simply prints out the body of the request.
This can now be tested with curl by something as simple as:
curl -i -X POST -H "Content-Type: application/json" -d '{"foo": "bar"}' localhost:3000/register
Carl Worth [Sun, 26 Apr 2020 22:07:24 +0000 (15:07 -0700)]
Add dependency on body-parser package
This was done with:
npm install --save body-parser
Carl Worth [Sun, 26 Apr 2020 22:06:56 +0000 (15:06 -0700)]
stash: add gitignore (for 'Add dependency for express')
Carl Worth [Sun, 26 Apr 2020 21:55:34 +0000 (14:55 -0700)]
Add Hello World node app
This is similar to what is documented here:
https://medium.com/@adnanrahic/hello-world-app-with-node-js-and-express-
c1eb7cfa8a30
but with some more modern content as recommended by Richard.
This can be run with:
node server
in the current directory, (and then pointing a user agent at localhost:3000).
Carl Worth [Sun, 26 Apr 2020 21:51:05 +0000 (14:51 -0700)]
Add resolved dependencies in package-lock.json file
The entire contents of this file were generated by the:
npm install --save express
command from the previous commit.
Carl Worth [Sun, 26 Apr 2020 21:49:31 +0000 (14:49 -0700)]
Add dependency for express package
This was generated with:
npm install --save express
(This command also generated resolved dependencies in the
package-lock.json file but I'm not commiting that in this commit.)
Carl Worth [Sun, 26 Apr 2020 21:46:22 +0000 (14:46 -0700)]
Add new package.json for the families app
This was generated with "npm init" (and accepting all defaults).