Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes #311 #315

Open
wants to merge 9 commits into
base: react-native-app-prototype
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 18 additions & 0 deletions backend-api/api/controllers/teams.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
'use strict';
const senecaRequestMw = require('../../modules/swagger-setup/middleware/seneca');

module.exports = {
getAllTeams: senecaRequestMw(
'role:db,cmd:getAllTeams',
req => ({
CC: req.swagger.params.country.value,
search: req.swagger.params.search.value,
}),
),
getTeam: senecaRequestMw(
'role:db,cmd:getTeam',
req => ({
id: req.swagger.params.id.value,
}),
)
};
6 changes: 6 additions & 0 deletions backend-api/api/controllers/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ module.exports = {
update: req.swagger.params.update.value,
}),
),
modifyUserTeam: senecaRequestMw(
'role:db,cmd:modifyOwnUserProfile',
req => ({
update: req.swagger.params.update.value,
}),
),
modifyUserProfilePrivacy: senecaRequestMw(
'role:db,cmd:modifyOwnProfilePrivacy',
req => ({
Expand Down
95 changes: 95 additions & 0 deletions backend-api/api/v1.0.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,22 @@ paths:
"default":
$ref: "#/responses/ErrorSet"
#-----------------------------------------------------------------------------
/me/team:
x-swagger-router-controller: users
put:
description: Join user to team.
operationId: modifyUserTeam
x-security: [bearer]
parameters:
- $ref: "#/parameters/ModifyTeam"
responses:
"200":
description: Account information.
schema:
$ref: "#/definitions/Account"
"default":
$ref: "#/responses/ErrorSet"
#-----------------------------------------------------------------------------
/auth/external:
x-swagger-router-controller: users
post:
Expand Down Expand Up @@ -404,6 +420,34 @@ paths:
"default":
$ref: "#/responses/ErrorSet"
#-----------------------------------------------------------------------------
/teams:
x-swagger-router-controller: teams
get:
description: List all teams.
operationId: getAllTeams
parameters:
- $ref: "#/parameters/Country"
- $ref: "#/parameters/Search"
responses:
"200":
$ref: "#/responses/Teams"
"default":
$ref: "#/responses/ErrorSet"
/teams/{id}:
x-swagger-router-controller: teams
get:
description: Fetch complete info about a specific team.
operationId: getTeam
parameters:
- $ref: "#/parameters/UUID"
responses:
"200":
description: Full team information.
schema:
$ref: "#/definitions/Team"
"default":
$ref: "#/responses/ErrorSet"
#-----------------------------------------------------------------------------
/areas/user:
x-swagger-router-controller: areas
get:
Expand Down Expand Up @@ -773,6 +817,14 @@ parameters:
minLength: 3
maxLength: 10
#-----------------------------------------------------------------------------
Search:
name: search
in: query
required: false
type: string
minLength: 3
maxLength: 60
#-----------------------------------------------------------------------------
Country:
name: country
in: query
Expand Down Expand Up @@ -802,6 +854,17 @@ parameters:
value:
type: boolean
#-----------------------------------------------------------------------------
ModifyTeam:
name: update
in: body
required: true
schema:
type: object
required: [team]
properties:
team:
$ref: "#/definitions/UUID"
#-----------------------------------------------------------------------------
ModifyTrashpoint:
name: trashpoint
in: body
Expand Down Expand Up @@ -979,6 +1042,12 @@ responses:
description: List of trashpoints for area leader consumption.
schema:
$ref: "#/definitions/PaginatedAreaTrashpoints"
Teams:
description: List of teams.
schema:
type: array
items:
$ref: "#/definitions/Team"
StorageAuth:
description: A short-term authorization allowing access to storage operations.
schema:
Expand Down Expand Up @@ -1028,6 +1097,28 @@ definitions:
description: Area can be optionally be assigned to a user.
$ref: "#/definitions/UUID"
#-----------------------------------------------------------------------------
# Team properties.
#-----------------------------------------------------------------------------
Team:
type: object
required: [id, name]
properties:
id:
description: A unique code of team
type: string
name:
description: A name of team
type: string
teamDescription:
description: Desctiption of team
type: string
trashpoints:
description: How many trashpoints have this team
type: integer
users:
description: How many users have this team
type: integer
#-----------------------------------------------------------------------------
# Account properties.
#-----------------------------------------------------------------------------
Account:
Expand All @@ -1053,6 +1144,10 @@ definitions:
type: boolean
public:
type: boolean
team:
type:
- string
- 'null'
AccountPlusAreas:
allOf:
- "$ref": "#/definitions/Account"
Expand Down
1 change: 1 addition & 0 deletions backend-db/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ service.use('./plugins/trashpoints');
service.use('./plugins/images');
service.use('./plugins/areas');
service.use('./plugins/events');
service.use('./plugins/teams');
1 change: 1 addition & 0 deletions backend-db/modules/db/couchdb/adapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const TYPE_TO_DB_MAP = {
'Account': 'accounts',
'Session': 'sessions',
'Area': 'areas',
'Team': 'teams',
'Event': 'events'
};

Expand Down