An API for a game I'm making (or was).
Node.js, Express, RethinkDB, and Typescript, yahoo!
Feel free to learn.
Install node v6, start up a rethinkdb server with default ports/etc.
npm install
the project.
npm start
or tsc && node dist/server.js
, if you have typescript
installed globally
Register:
POST 127.0.0.1:8079/api/users/register
Body: (application/json):
{
"id": "",
"username": "johntest",
"password": "asdf"
}
Log in:
POST 127.0.0.1:8079/api/users/login
Headers: Authorization: Basic johntest:asdf
It should return a token in the body.
Test the token:
GET 127.0.0.1:8079/api/users/self
Headers: Authorization: Bearer <your-token-here>
It should return:
{
"id": "your-id-here",
"username": "johntest"
}
There are also other GET's for /api/teams
and /api/teams/id
which are open without a
token. To POST or PUT a team, you have to be authenticated (i.e. use a token).
soli deo gloria