Skip to content

Commit

Permalink
update and release
Browse files Browse the repository at this point in the history
  • Loading branch information
mathias committed Jan 10, 2024
1 parent 310c13e commit b8db26d
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 20 deletions.
20 changes: 20 additions & 0 deletions app/Controllers/Http/UserController.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'
import User from 'App/Models/User'
import Drive from '@ioc:Adonis/Core/Drive'
import Group from 'App/Models/Group'

export default class UserController {
public async index(HttpContextContract: HttpContextContract) {
Expand All @@ -15,4 +16,23 @@ export default class UserController {
}
return HttpContextContract.response.unauthorized()
}

public async groupUsers(HttpContextContract: HttpContextContract) {
let groupId = HttpContextContract.params.id
console.log(groupId)
if (Number(groupId)) {
console.log('test')
const group = await Group.findOrFail(Number(groupId))
console.log('test')
let users = await group
.related('users')
.query()
.select('users.id', 'users.username', 'users.avatar_url')
for (let user of users) {
user.avatarUrl = await Drive.getSignedUrl(user.avatarUrl)
}
return HttpContextContract.response.send(JSON.stringify(users))
}
return HttpContextContract.response.badRequest()
}
}
40 changes: 20 additions & 20 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,26 @@ services:
ports:
- 5432:5432

pycount-backend:
image: pycount-backend:dev
container_name: pycount-backend
restart: always
depends_on:
- postgres
build:
context: .
target: dependencies
ports:
- ${PORT}:${PORT}
- 9229:9229
env_file:
- .env
environment:
- PG_HOST=postgres
- REDIS_HOST=redis
volumes:
- ./:/home/node/app
command: dumb-init node ace serve --watch --node-args="--inspect=0.0.0.0"
# pycount-backend:
# image: pycount-backend:dev
# container_name: pycount-backend
# restart: always
# depends_on:
# - postgres
# build:
# context: .
# target: dependencies
# ports:
# - ${PORT}:${PORT}
# - 9229:9229
# env_file:
# - .env
# environment:
# - PG_HOST=postgres
# - REDIS_HOST=redis
# volumes:
# - ./:/home/node/app
# command: dumb-init node ace serve --watch --node-args="--inspect=0.0.0.0"

volumes:
postgres_volume:
1 change: 1 addition & 0 deletions start/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ Route.group(() => {

Route.group(() => {
Route.get('/', 'UserController.index')
Route.get('/:id', 'UserController.groupUsers')
}).prefix('/users')
})
.prefix('/api')
Expand Down

0 comments on commit b8db26d

Please sign in to comment.