mirror of
https://github.com/standardnotes/server
synced 2026-09-29 03:13:35 -04:00
44 lines
1.1 KiB
TypeScript
44 lines
1.1 KiB
TypeScript
import { Request, Response } from 'express'
|
|
import { inject } from 'inversify'
|
|
import {
|
|
BaseHttpController,
|
|
controller,
|
|
httpGet,
|
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
results,
|
|
} from 'inversify-express-utils'
|
|
import TYPES from '../Bootstrap/Types'
|
|
import { GetUserFeatures } from '../Domain/UseCase/GetUserFeatures/GetUserFeatures'
|
|
|
|
@controller('/users/:userUuid/features')
|
|
export class FeaturesController extends BaseHttpController {
|
|
constructor(@inject(TYPES.GetUserFeatures) private doGetUserFeatures: GetUserFeatures) {
|
|
super()
|
|
}
|
|
|
|
@httpGet('/', TYPES.ApiGatewayAuthMiddleware)
|
|
async getFeatures(request: Request, response: Response): Promise<results.JsonResult> {
|
|
if (request.params.userUuid !== response.locals.user.uuid) {
|
|
return this.json(
|
|
{
|
|
error: {
|
|
message: 'Operation not allowed.',
|
|
},
|
|
},
|
|
401,
|
|
)
|
|
}
|
|
|
|
const result = await this.doGetUserFeatures.execute({
|
|
userUuid: request.params.userUuid,
|
|
offline: false,
|
|
})
|
|
|
|
if (result.success) {
|
|
return this.json(result)
|
|
}
|
|
|
|
return this.json(result, 400)
|
|
}
|
|
}
|