Skip to content

Commit

Permalink
feat (user/term): term access
Browse files Browse the repository at this point in the history
  • Loading branch information
santanche committed Jan 30, 2022
1 parent c76546a commit a94a75f
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/adonisjs/app/Controllers/Http/v1/ArtifactController.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class ArtifactController {
this.validationOptions = {
size: '100mb',
types: ['image', 'video'],
extnames: ['png', 'jpg', 'jpeg', 'gif', 'mp4', 'avi', '.wmv']
extnames: ['png', 'jpg', 'jpeg', 'gif', 'svg', 'mp4', 'avi', 'wmv']
}

this.relativePath = '/resources/artifacts/'
Expand Down
26 changes: 26 additions & 0 deletions src/adonisjs/app/Controllers/Http/v1/TermController.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,32 @@ class TermController {
return response.status(500).json({ message: e.message })
}
}

/**
* Display a link between a term and a user.
* GET term/user/:id
*
* @param {object} ctx
* @param {Request} ctx.request
* @param {Response} ctx.response
* @param {View} ctx.view
*/
async showTermUser ({ params, request, response, view }) {
try {
const uterm = await Database
.select('*')
.from('users_terms')
.where('user_id', request.input('userId'))
.where('term_id', request.input('termId'))
if (uterm != null)
return response.json(uterm)
else
return response.status(500).json('user not found')
} catch (e) {
console.log(e)
return response.status(e.status).json({ message: e.message })
}
}
}

module.exports = TermController
1 change: 1 addition & 0 deletions src/adonisjs/start/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ Route.group(() => {
Route.group(() => {
Route.post( '', 'v1/TermController.store').middleware('auth')
Route.post( 'link/user', 'v1/TermController.linkUser')
Route.get( 'user', 'v1/TermController.showTermUser')
}).prefix('/api/v1/term')

/*
Expand Down

0 comments on commit a94a75f

Please sign in to comment.