.travis.yml: fix docker push

pull/14/head
leonnicolas 4 years ago
commit 2b35ec0c2d
No known key found for this signature in database
GPG Key ID: 088D0743E2B65C07

@ -9,4 +9,4 @@ script:
- docker login -u="$DOCKER_USER" -p="$DOCKER_PW" https://flotte-docker-registry.spdns.org/
- docker build -t apollo-server .
- docker tag apollo-server flotte-docker-registry.spdns.org/apollo-server
- docker push flotte-docker-registry.spdns.org/apollo-server:latest
- docker push flotte-docker-registry.spdns.org/apollo-server:latest

@ -1,5 +1,8 @@
# API-server
Apollo server written in typescript that handles business logic.
[![Build Status](https://travis-ci.com/flotte-goes-smart/apollo-server.svg?token=YfRmpHAXqyUafCgSEexw&branch=main)](https://travis-ci.com/flotte-goes-smart/apollo-server)
## Assumptions
Userserver and postgres are running e.g. with Julius' Docker Compose.
## Usage

@ -48,6 +48,27 @@ export class CargoBikeAPI extends DataSource {
.getOne())?.cargoBike;
}
async lockCargoBike (id: number, req: any, dataSources: any) {
console.log("token:");
console.log(req.headers.authorization);
const token = req.headers.authorization?.replace('Bearer ', '');
console.log(token);
console.log(await dataSources.userAPI.getUserId(token));
const lock = await this.connection.getRepository(CargoBike)
.createQueryBuilder('cargoBike')
.select([
'cargoBike.lockedUntil',
'cargoBike.lockedBy'
])
.where('id = :id', {
id: id
})
.getOne();
//console.log(req);
console.log(lock);
return false;
}
/**
* Updates CargoBike and return updated cargoBike
* @param param0 cargoBike to be updated

@ -7,5 +7,6 @@ export enum Method {
GetRoles = 0x52_4f_4c_45,
GetRolePermissions = 0x50_45_52_4d,
CreateRole = 0x43_52_4f_4c,
CreatePermissions = 0x43_50_45_52
CreatePermissions = 0x43_50_45_52,
GetUserID = 0x55534552
}

@ -83,6 +83,15 @@ export class UserServerAPI extends DataSource {
return response.data;
}
/**
* Returns userId
* @param token
*/
async getUserId (token: String): Promise<number> {
const response = await this.send<any>(new RPCMessage(Method.GetUserID, { token }));
return response.data;
}
/**
* Returns all permissions of the user
* @param token

@ -142,7 +142,7 @@ export class CargoBike extends Bike {
lockedBy: number;
@Column({
type: 'date',
type: 'timestamp',
nullable: true
})
lockedUntil: Date;

@ -66,6 +66,14 @@ export default {
return new GraphQLError('Insufficient Permissions');
}
},
lockCargoBikeById: (_: any, { id }: { id: number }, { dataSources, req }:{dataSources: any, req: any }) => {
if (req.permissions.includes(Permission.WriteBike)) {
return dataSources.cargoBikeAPI.lockCargoBike(id, req, dataSources);
} else {
return new GraphQLError('Insufficient Permissions');
}
},
updateCargoBike: (_: any, { cargoBike }: { cargoBike: any }, { dataSources, req }:{dataSources: any, req: any }) => {
if (req.permissions.includes(Permission.WriteBike)) {
return dataSources.cargoBikeAPI.updateCargoBike({ cargoBike });

@ -710,6 +710,8 @@ type Query {
type Mutation {
"creates new cargoBike and returns cargobike with new ID"
createCargoBike(cargoBike: CargoBikeCreateInput!): CargoBike!
"lock cargoBike - not implemented"
lockCargoBikeById(id: ID!): Boolean!
"updates cargoBike of given ID with supplied fields and returns updated cargoBike"
updateCargoBike(cargoBike: CargoBikeUpdateInput!): CargoBike!
"creates new peace of unique Equipment"

Loading…
Cancel
Save