]> git.cworth.org Git - empires-server/log
empires-server
4 years agoAdd an ID value to each player
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).

4 years agofixup errant newline
Carl Worth [Sun, 26 Apr 2020 22:29:52 +0000 (15:29 -0700)]
fixup errant newline

4 years agoBe a bit more berbose in variable names.
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".

4 years agoMake the server store a list of players
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.

4 years agoExtend our simple web API with a new /register endpoint
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

4 years agoAdd dependency on body-parser package
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

4 years agostash: add gitignore (for 'Add dependency for express')
Carl Worth [Sun, 26 Apr 2020 22:06:56 +0000 (15:06 -0700)]
stash: add gitignore (for 'Add dependency for express')

4 years agoAdd Hello World node app
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).

4 years agoAdd resolved dependencies in package-lock.json file
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.

4 years agoAdd dependency for express package
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.)

4 years agoAdd new package.json for the families app
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).