Add basic infos and login endpoint to docs

pull/32/head
HardiReady 2018-03-18 20:21:24 +01:00
parent 67abb1948b
commit 9dfbc74377
10 changed files with 132 additions and 4 deletions

11
api/apib/auth/login.apib Normal file
View File

@ -0,0 +1,11 @@
### Login - Generate Token [POST /authenticate]
Generate a token which can be used to make API requests.
+ Request Generate Token (application/json)
+ Attributes (Login)
+ Response 200 (application/json;charset=UTF-8)
+ Attributes (LoginResponse)

12
api/apib/auth/signup.apib Normal file
View File

@ -0,0 +1,12 @@
### Sign up - Create account [POST /authenticate/signup]
Create a new application user account.
+ Request Create Account (application/json)
+ Attributes (Registration)
+ Response 201 (application/json;charset=UTF-8)
+ Attributes (RegistrationResponse)

View File

@ -1 +0,0 @@
## Authentication

View File

@ -0,0 +1,10 @@
## Timezones & Date Format
**Date Format**
In general the API returns and expects dates & times in the ISO 8601 format including the timezone specification.
For example: `2017-02-27T17:05:06+01:00` for a time or `2017-02-27` for a date.
**Timezone**
The default timezone returned will be the server timezone: Europe/Berlin (UTC+1).

View File

@ -0,0 +1,41 @@
# Login (object)
User related entity for creating a token using application credentials
## Properties
+ username: `hardiready` (string, required) - username of the app-user
+ password: `password` (string, required) - password of the app-user
# LoginResponse (object)
Response object on successful token creation
## Properties
+ _id: `593d632772d35225232bcabb` (string, required) - the unique id of the app-user
+ username: `hardiready` (string, required) - the username of the app-user
+ permission: 1 - the permission level of the app-user (0 - user, 1 - sql, 2 - hl, 3 - maintainer, 4 - admin)
+ squad (Squad, required) - squad the app-user is member of
+ token: `eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiI1OTNkNWUzZjcyZDM1MjI1MjIyYmNhYmEiLCJpYXQiOjE1MjEzOTQ5NDYsImV4cCI6MTUyMzgxNDE0Nn0.vOAwA5--qrx8BglhyGZWVYx7LeuRKOHH0NQXmHFNhIQ` (string,required) - generated token
+ tokenExpireDate: `2018-04-15T17:42:25.050Z` (string,required) - expiration date of the token
# Registration (object)
User related entity for reflecting membership to another resource (groups, material databases)
## Properties
+ email: `darth.vader@starwars.com` (string, required) - email of the user
+ password: `password` (string, required) - password of the user
+ first_name: `Anakin` (string, required) - first name of the user
+ last_name: `Skywalker` (string, required) - last name of the user
+ role: `Fleet Commander` (string) - role of the user in his organization
+ organization: `Imperium` (string) - organization the user is member of
# RegistrationResponse (object)
Response object on successful user registration
## Properties
+ email: `darth.vader@starwars.com` (string) - email the new user has been created with
+ uuid: `123e4567-e89b-12d3-a456-426655440000` (string) - a unique key to the user which is to be used across 3rd party applications

View File

@ -0,0 +1,12 @@
# Squad (object)
Default API Squad entity
## Properties
+ _id: `591470249e9fae286e008e31` (string, required)
+ sortingNumber: 30 (number, required)
+ updatedAt: `2017-05-31T20:43:07.165Z` (string, required)
+ timestamp: `2017-05-11T14:07:32.471Z` (string, required)
+ name: `Alpha` (string, required)
+ fraction: `BLUFOR` (string, required)
+ __v: 2 (number, required)

View File

@ -0,0 +1,5 @@
# Data Structures
<!-- include(_auth.apib) -->
<!-- include(_squad.apib) -->

View File

@ -1,3 +1,41 @@
FORMAT: 1A
# Operation Pandora Trigger Command Center API Documentation # Operation Pandora Trigger Command Center API Documentation
<!-- include(base/authentication.apib) --> <!-- include(data_structures/index.apib) -->
# Group General Introduction
<!-- include(base/datetime.apib) -->
# Group Access
## Authentication
<!-- include(auth/signup.apib) -->
<!-- include(auth/login.apib) -->
# Group Account
# Group Awardings
# Group Campaigns
# Group Decorations
# Group Logs
# Group Overview
# Group Players
# Group Ranks
# Group Requests
# Group Squads
# Group Users
# Group Wars

View File

@ -12,7 +12,7 @@
"lint": "eslint '**/*.js'", "lint": "eslint '**/*.js'",
"test": "mocha --require ./test/config/spec_helper.js", "test": "mocha --require ./test/config/spec_helper.js",
"e2e": "NODE_ENV=test node server.js", "e2e": "NODE_ENV=test node server.js",
"api:docs": "$(npm bin)/aglio -i ./apib/documentation.apib -o ../public/api-docs.html" "api:docs": "$(npm bin)/aglio --theme-variables slate -i ./apib/documentation.apib -o ../public/api-docs.html"
}, },
"dependencies": { "dependencies": {
"async": "^2.5.0", "async": "^2.5.0",

View File

@ -1,6 +1,6 @@
{ {
"name": "opt-cc", "name": "opt-cc",
"version": "1.7.1", "version": "1.7.2",
"author": "Florian Hartwich <hardi@noarch.de>", "author": "Florian Hartwich <hardi@noarch.de>",
"private": true, "private": true,
"scripts": { "scripts": {