feat(auth): move inversify express controllers to different structure (#610)

* wip: move valet token controller

* wip: move users controller

* wip: move admin controller

* wip: move subscription tokens controller

* wip: move subscription settings controller

* wip: move settings controller

* wip: move middleware

* wip: move session controller

* wip: move offline controller

* wip: move listed controller

* wip: move internal controller

* wip: move healthcheck controller

* wip: move features controller

* fix: bind inversify express controllers only for home server

* fix: inversify deps
This commit is contained in:
Karol Sójko 2023-05-17 11:54:18 +02:00 committed by GitHub
parent e748723209
commit fea58029b9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
45 changed files with 371 additions and 253 deletions

12
.pnp.cjs generated
View file

@ -4713,7 +4713,6 @@ const RAW_RUNTIME_STATE =
["@types/cors", "npm:2.8.13"],\
["@types/dotenv", "npm:8.2.0"],\
["@types/express", "npm:4.17.17"],\
["@types/inversify-express-utils", "npm:2.0.0"],\
["@types/jest", "npm:29.5.1"],\
["@types/newrelic", "npm:9.13.0"],\
["@typescript-eslint/eslint-plugin", "virtual:fd909b174d079e30b336c4ce72c38a88c1e447767b1a8dd7655e07719a1e31b97807f0931368724fc78897ff15e6a6d00b83316c0f76d11f85111f342e08bb79#npm:5.59.2"],\
@ -4897,7 +4896,6 @@ const RAW_RUNTIME_STATE =
["@types/cors", "npm:2.8.13"],\
["@types/dotenv", "npm:8.2.0"],\
["@types/express", "npm:4.17.17"],\
["@types/inversify-express-utils", "npm:2.0.0"],\
["@types/jest", "npm:29.5.1"],\
["@types/jsonwebtoken", "npm:9.0.2"],\
["@types/newrelic", "npm:9.13.0"],\
@ -5299,16 +5297,6 @@ const RAW_RUNTIME_STATE =
"linkType": "HARD"\
}]\
]],\
["@types/inversify-express-utils", [\
["npm:2.0.0", {\
"packageLocation": "./.yarn/cache/@types-inversify-express-utils-npm-2.0.0-e78182955d-9841bfddff.zip/node_modules/@types/inversify-express-utils/",\
"packageDependencies": [\
["@types/inversify-express-utils", "npm:2.0.0"],\
["inversify-express-utils", "npm:6.4.3"]\
],\
"linkType": "HARD"\
}]\
]],\
["@types/ioredis", [\
["npm:5.0.0", {\
"packageLocation": "./.yarn/cache/@types-ioredis-npm-5.0.0-6efa70abfa-439770c9da.zip/node_modules/@types/ioredis/",\

View file

@ -2,25 +2,24 @@ import 'reflect-metadata'
import 'newrelic'
import '../src/Controller/HealthCheckController'
import '../src/Controller/SessionController'
import '../src/Controller/UsersController'
import '../src/Controller/SettingsController'
import '../src/Controller/FeaturesController'
import '../src/Controller/AdminController'
import '../src/Controller/InternalController'
import '../src/Controller/SubscriptionTokensController'
import '../src/Controller/OfflineController'
import '../src/Controller/ValetTokenController'
import '../src/Controller/ListedController'
import '../src/Controller/SubscriptionSettingsController'
import '../src/Infra/InversifyExpressUtils/InversifyExpressAuthController'
import '../src/Infra/InversifyExpressUtils/InversifyExpressAuthenticatorsController'
import '../src/Infra/InversifyExpressUtils/InversifyExpressSessionsController'
import '../src/Infra/InversifyExpressUtils/InversifyExpressSubscriptionInvitesController'
import '../src/Infra/InversifyExpressUtils/InversifyExpressUserRequestsController'
import '../src/Infra/InversifyExpressUtils/InversifyExpressWebSocketsController'
import '../src/Infra/InversifyExpressUtils/InversifyExpressUsersController'
import '../src/Infra/InversifyExpressUtils/InversifyExpressValetTokenController'
import '../src/Infra/InversifyExpressUtils/InversifyExpressAdminController'
import '../src/Infra/InversifyExpressUtils/InversifyExpressSubscriptionTokensController'
import '../src/Infra/InversifyExpressUtils/InversifyExpressSubscriptionSettingsController'
import '../src/Infra/InversifyExpressUtils/InversifyExpressSettingsController'
import '../src/Infra/InversifyExpressUtils/InversifyExpressSessionController'
import '../src/Infra/InversifyExpressUtils/InversifyExpressOfflineController'
import '../src/Infra/InversifyExpressUtils/InversifyExpressListedController'
import '../src/Infra/InversifyExpressUtils/InversifyExpressInternalController'
import '../src/Infra/InversifyExpressUtils/InversifyExpressHealthCheckController'
import '../src/Infra/InversifyExpressUtils/InversifyExpressFeaturesController'
import * as cors from 'cors'
import { urlencoded, json, Request, Response, NextFunction } from 'express'

View file

@ -14,7 +14,6 @@ import { UAParser } from 'ua-parser-js'
import { Env } from './Env'
import TYPES from './Types'
import { AuthMiddleware } from '../Controller/AuthMiddleware'
import { AuthenticateUser } from '../Domain/UseCase/AuthenticateUser'
import { Repository } from 'typeorm'
import { AppDataSource } from './DataSource'
@ -24,7 +23,6 @@ import { SessionService } from '../Domain/Session/SessionService'
import { TypeORMSessionRepository } from '../Infra/TypeORM/TypeORMSessionRepository'
import { TypeORMUserRepository } from '../Infra/TypeORM/TypeORMUserRepository'
import { SessionProjector } from '../Projection/SessionProjector'
import { SessionMiddleware } from '../Controller/SessionMiddleware'
import { RefreshSessionToken } from '../Domain/UseCase/RefreshSessionToken'
import { KeyParamsFactory } from '../Domain/User/KeyParamsFactory'
import { SignIn } from '../Domain/UseCase/SignIn'
@ -36,8 +34,6 @@ import { AuthResponseFactory20200115 } from '../Domain/Auth/AuthResponseFactory2
import { AuthResponseFactoryResolver } from '../Domain/Auth/AuthResponseFactoryResolver'
import { ClearLoginAttempts } from '../Domain/UseCase/ClearLoginAttempts'
import { IncreaseLoginAttempts } from '../Domain/UseCase/IncreaseLoginAttempts'
import { LockMiddleware } from '../Controller/LockMiddleware'
import { AuthMiddlewareWithoutResponse } from '../Controller/AuthMiddlewareWithoutResponse'
import { GetUserKeyParams } from '../Domain/UseCase/GetUserKeyParams/GetUserKeyParams'
import { UpdateUser } from '../Domain/UseCase/UpdateUser'
import { RedisEphemeralSessionRepository } from '../Infra/Redis/RedisEphemeralSessionRepository'
@ -103,7 +99,6 @@ import { ChangeCredentials } from '../Domain/UseCase/ChangeCredentials/ChangeCre
import { SubscriptionReassignedEventHandler } from '../Domain/Handler/SubscriptionReassignedEventHandler'
import { UserSubscriptionRepositoryInterface } from '../Domain/Subscription/UserSubscriptionRepositoryInterface'
import { CreateSubscriptionToken } from '../Domain/UseCase/CreateSubscriptionToken/CreateSubscriptionToken'
import { ApiGatewayAuthMiddleware } from '../Controller/ApiGatewayAuthMiddleware'
import { SubscriptionTokenRepositoryInterface } from '../Domain/Subscription/SubscriptionTokenRepositoryInterface'
import { RedisSubscriptionTokenRepository } from '../Infra/Redis/RedisSubscriptionTokenRepository'
import { AuthenticateSubscriptionToken } from '../Domain/UseCase/AuthenticateSubscriptionToken/AuthenticateSubscriptionToken'
@ -116,7 +111,6 @@ import { TypeORMOfflineSettingRepository } from '../Infra/TypeORM/TypeORMOffline
import { OfflineUserSubscription } from '../Domain/Subscription/OfflineUserSubscription'
import { OfflineUserSubscriptionRepositoryInterface } from '../Domain/Subscription/OfflineUserSubscriptionRepositoryInterface'
import { TypeORMOfflineUserSubscriptionRepository } from '../Infra/TypeORM/TypeORMOfflineUserSubscriptionRepository'
import { OfflineUserAuthMiddleware } from '../Controller/OfflineUserAuthMiddleware'
import { OfflineSubscriptionTokenRepositoryInterface } from '../Domain/Auth/OfflineSubscriptionTokenRepositoryInterface'
import { RedisOfflineSubscriptionTokenRepository } from '../Infra/Redis/RedisOfflineSubscriptionTokenRepository'
import { CreateOfflineSubscriptionToken } from '../Domain/UseCase/CreateOfflineSubscriptionToken/CreateOfflineSubscriptionToken'
@ -124,7 +118,6 @@ import { AuthenticateOfflineSubscriptionToken } from '../Domain/UseCase/Authenti
import { SubscriptionCancelledEventHandler } from '../Domain/Handler/SubscriptionCancelledEventHandler'
import { ContentDecoder, ContentDecoderInterface, ProtocolVersion } from '@standardnotes/common'
import { GetUserOfflineSubscription } from '../Domain/UseCase/GetUserOfflineSubscription/GetUserOfflineSubscription'
import { ApiGatewayOfflineAuthMiddleware } from '../Controller/ApiGatewayOfflineAuthMiddleware'
import { UserEmailChangedEventHandler } from '../Domain/Handler/UserEmailChangedEventHandler'
import { SettingsAssociationServiceInterface } from '../Domain/Setting/SettingsAssociationServiceInterface'
import { SettingsAssociationService } from '../Domain/Setting/SettingsAssociationService'
@ -241,6 +234,24 @@ import { InversifyExpressSubscriptionInvitesController } from '../Infra/Inversif
import { InversifyExpressUserRequestsController } from '../Infra/InversifyExpressUtils/InversifyExpressUserRequestsController'
import { InversifyExpressWebSocketsController } from '../Infra/InversifyExpressUtils/InversifyExpressWebSocketsController'
import { InversifyExpressSessionsController } from '../Infra/InversifyExpressUtils/InversifyExpressSessionsController'
import { InversifyExpressValetTokenController } from '../Infra/InversifyExpressUtils/InversifyExpressValetTokenController'
import { InversifyExpressUsersController } from '../Infra/InversifyExpressUtils/InversifyExpressUsersController'
import { InversifyExpressAdminController } from '../Infra/InversifyExpressUtils/InversifyExpressAdminController'
import { InversifyExpressSubscriptionTokensController } from '../Infra/InversifyExpressUtils/InversifyExpressSubscriptionTokensController'
import { InversifyExpressSubscriptionSettingsController } from '../Infra/InversifyExpressUtils/InversifyExpressSubscriptionSettingsController'
import { InversifyExpressSettingsController } from '../Infra/InversifyExpressUtils/InversifyExpressSettingsController'
import { SessionMiddleware } from '../Infra/InversifyExpressUtils/Middleware/SessionMiddleware'
import { ApiGatewayAuthMiddleware } from '../Infra/InversifyExpressUtils/Middleware/ApiGatewayAuthMiddleware'
import { ApiGatewayOfflineAuthMiddleware } from '../Infra/InversifyExpressUtils/Middleware/ApiGatewayOfflineAuthMiddleware'
import { AuthMiddleware } from '../Infra/InversifyExpressUtils/Middleware/AuthMiddleware'
import { OfflineUserAuthMiddleware } from '../Infra/InversifyExpressUtils/Middleware/OfflineUserAuthMiddleware'
import { AuthMiddlewareWithoutResponse } from '../Infra/InversifyExpressUtils/Middleware/AuthMiddlewareWithoutResponse'
import { LockMiddleware } from '../Infra/InversifyExpressUtils/Middleware/LockMiddleware'
import { InversifyExpressSessionController } from '../Infra/InversifyExpressUtils/InversifyExpressSessionController'
import { InversifyExpressOfflineController } from '../Infra/InversifyExpressUtils/InversifyExpressOfflineController'
import { InversifyExpressListedController } from '../Infra/InversifyExpressUtils/InversifyExpressListedController'
import { InversifyExpressInternalController } from '../Infra/InversifyExpressUtils/InversifyExpressInternalController'
import { InversifyExpressFeaturesController } from '../Infra/InversifyExpressUtils/InversifyExpressFeaturesController'
// eslint-disable-next-line @typescript-eslint/no-var-requires
const newrelicFormatter = require('@newrelic/winston-enricher')
@ -1015,50 +1026,166 @@ export class ContainerConfigLoader {
)
// Inversify Controllers
container
.bind<InversifyExpressAuthenticatorsController>(TYPES.Auth_InversifyExpressAuthenticatorsController)
.toConstantValue(
new InversifyExpressAuthenticatorsController(
container.get(TYPES.Auth_AuthenticatorsController),
container.get(TYPES.Auth_ControllerContainer),
),
)
container
.bind<InversifyExpressSubscriptionInvitesController>(TYPES.Auth_InversifyExpressSubscriptionInvitesController)
.toConstantValue(
new InversifyExpressSubscriptionInvitesController(
container.get(TYPES.Auth_SubscriptionInvitesController),
container.get(TYPES.Auth_ControllerContainer),
),
)
container
.bind<InversifyExpressUserRequestsController>(TYPES.Auth_InversifyExpressUserRequestsController)
.toConstantValue(
new InversifyExpressUserRequestsController(
container.get(TYPES.Auth_UserRequestsController),
container.get(TYPES.Auth_ControllerContainer),
),
)
container
.bind<InversifyExpressWebSocketsController>(TYPES.Auth_InversifyExpressWebSocketsController)
.toConstantValue(
new InversifyExpressWebSocketsController(
container.get(TYPES.Auth_CreateCrossServiceToken),
container.get(TYPES.Auth_WebSocketConnectionTokenDecoder),
container.get(TYPES.Auth_ControllerContainer),
),
)
container
.bind<InversifyExpressSessionsController>(TYPES.Auth_SessionsController)
.toConstantValue(
new InversifyExpressSessionsController(
container.get(TYPES.Auth_GetActiveSessionsForUser),
container.get(TYPES.Auth_AuthenticateRequest),
container.get(TYPES.Auth_SessionProjector),
container.get(TYPES.Auth_CreateCrossServiceToken),
container.get(TYPES.Auth_ControllerContainer),
),
)
if (isConfiguredForHomeServer) {
container
.bind<InversifyExpressAuthenticatorsController>(TYPES.Auth_InversifyExpressAuthenticatorsController)
.toConstantValue(
new InversifyExpressAuthenticatorsController(
container.get(TYPES.Auth_AuthenticatorsController),
container.get(TYPES.Auth_ControllerContainer),
),
)
container
.bind<InversifyExpressSubscriptionInvitesController>(TYPES.Auth_InversifyExpressSubscriptionInvitesController)
.toConstantValue(
new InversifyExpressSubscriptionInvitesController(
container.get(TYPES.Auth_SubscriptionInvitesController),
container.get(TYPES.Auth_ControllerContainer),
),
)
container
.bind<InversifyExpressUserRequestsController>(TYPES.Auth_InversifyExpressUserRequestsController)
.toConstantValue(
new InversifyExpressUserRequestsController(
container.get(TYPES.Auth_UserRequestsController),
container.get(TYPES.Auth_ControllerContainer),
),
)
container
.bind<InversifyExpressWebSocketsController>(TYPES.Auth_InversifyExpressWebSocketsController)
.toConstantValue(
new InversifyExpressWebSocketsController(
container.get(TYPES.Auth_CreateCrossServiceToken),
container.get(TYPES.Auth_WebSocketConnectionTokenDecoder),
container.get(TYPES.Auth_ControllerContainer),
),
)
container
.bind<InversifyExpressSessionsController>(TYPES.Auth_SessionsController)
.toConstantValue(
new InversifyExpressSessionsController(
container.get(TYPES.Auth_GetActiveSessionsForUser),
container.get(TYPES.Auth_AuthenticateRequest),
container.get(TYPES.Auth_SessionProjector),
container.get(TYPES.Auth_CreateCrossServiceToken),
container.get(TYPES.Auth_ControllerContainer),
),
)
container
.bind<InversifyExpressValetTokenController>(TYPES.Auth_InversifyExpressValetTokenController)
.toConstantValue(
new InversifyExpressValetTokenController(
container.get(TYPES.Auth_CreateValetToken),
container.get(TYPES.Auth_ControllerContainer),
),
)
container
.bind<InversifyExpressUsersController>(TYPES.Auth_InversifyExpressUsersController)
.toConstantValue(
new InversifyExpressUsersController(
container.get(TYPES.Auth_UpdateUser),
container.get(TYPES.Auth_GetUserKeyParams),
container.get(TYPES.Auth_DeleteAccount),
container.get(TYPES.Auth_GetUserSubscription),
container.get(TYPES.Auth_ClearLoginAttempts),
container.get(TYPES.Auth_IncreaseLoginAttempts),
container.get(TYPES.Auth_ChangeCredentials),
container.get(TYPES.Auth_ControllerContainer),
),
)
container
.bind<InversifyExpressAdminController>(TYPES.Auth_InversifyExpressAdminController)
.toConstantValue(
new InversifyExpressAdminController(
container.get(TYPES.Auth_DeleteSetting),
container.get(TYPES.Auth_UserRepository),
container.get(TYPES.Auth_CreateSubscriptionToken),
container.get(TYPES.Auth_CreateOfflineSubscriptionToken),
container.get(TYPES.Auth_ControllerContainer),
),
)
container
.bind<InversifyExpressSubscriptionTokensController>(TYPES.Auth_InversifyExpressSubscriptionTokensController)
.toConstantValue(
new InversifyExpressSubscriptionTokensController(
container.get(TYPES.Auth_CreateSubscriptionToken),
container.get(TYPES.Auth_AuthenticateSubscriptionToken),
container.get(TYPES.Auth_SettingService),
container.get(TYPES.Auth_UserProjector),
container.get(TYPES.Auth_RoleProjector),
container.get(TYPES.Auth_CrossServiceTokenEncoder),
container.get(TYPES.Auth_AUTH_JWT_TTL),
container.get(TYPES.Auth_ControllerContainer),
),
)
container
.bind<InversifyExpressSubscriptionSettingsController>(TYPES.Auth_InversifyExpressSubscriptionSettingsController)
.toConstantValue(
new InversifyExpressSubscriptionSettingsController(
container.get(TYPES.Auth_GetSetting),
container.get(TYPES.Auth_ControllerContainer),
),
)
container
.bind<InversifyExpressSettingsController>(TYPES.Auth_InversifyExpressSettingsController)
.toConstantValue(
new InversifyExpressSettingsController(
container.get(TYPES.Auth_GetSettings),
container.get(TYPES.Auth_GetSetting),
container.get(TYPES.Auth_UpdateSetting),
container.get(TYPES.Auth_DeleteSetting),
container.get(TYPES.Auth_ControllerContainer),
),
)
container
.bind<InversifyExpressSessionController>(TYPES.Auth_InversifyExpressSessionController)
.toConstantValue(
new InversifyExpressSessionController(
container.get(TYPES.Auth_DeleteSessionForUser),
container.get(TYPES.Auth_DeletePreviousSessionsForUser),
container.get(TYPES.Auth_RefreshSessionToken),
container.get(TYPES.Auth_ControllerContainer),
),
)
container
.bind<InversifyExpressOfflineController>(TYPES.Auth_InversifyExpressOfflineController)
.toConstantValue(
new InversifyExpressOfflineController(
container.get(TYPES.Auth_GetUserFeatures),
container.get(TYPES.Auth_GetUserOfflineSubscription),
container.get(TYPES.Auth_CreateOfflineSubscriptionToken),
container.get(TYPES.Auth_AuthenticateOfflineSubscriptionToken),
container.get(TYPES.Auth_OfflineUserTokenEncoder),
container.get(TYPES.Auth_AUTH_JWT_TTL),
container.get(TYPES.Auth_Logger),
container.get(TYPES.Auth_ControllerContainer),
),
)
container
.bind<InversifyExpressListedController>(TYPES.Auth_InversifyExpressListedController)
.toConstantValue(
new InversifyExpressListedController(
container.get(TYPES.Auth_CreateListedAccount),
container.get(TYPES.Auth_ControllerContainer),
),
)
container
.bind<InversifyExpressInternalController>(TYPES.Auth_InversifyExpressInternalController)
.toConstantValue(
new InversifyExpressInternalController(
container.get(TYPES.Auth_GetUserFeatures),
container.get(TYPES.Auth_GetSetting),
),
)
container
.bind<InversifyExpressFeaturesController>(TYPES.Auth_InversifyExpressFeaturesController)
.toConstantValue(
new InversifyExpressFeaturesController(
container.get(TYPES.Auth_GetUserFeatures),
container.get(TYPES.Auth_ControllerContainer),
),
)
}
return container
}

View file

@ -223,6 +223,19 @@ const TYPES = {
Auth_InversifyExpressUserRequestsController: Symbol.for('Auth_InversifyExpressUserRequestsController'),
Auth_InversifyExpressWebSocketsController: Symbol.for('Auth_InversifyExpressWebSocketsController'),
Auth_SessionsController: Symbol.for('Auth_SessionsController'),
Auth_InversifyExpressValetTokenController: Symbol.for('Auth_InversifyExpressValetTokenController'),
Auth_InversifyExpressUsersController: Symbol.for('Auth_InversifyExpressUsersController'),
Auth_InversifyExpressAdminController: Symbol.for('Auth_InversifyExpressAdminController'),
Auth_InversifyExpressSubscriptionTokensController: Symbol.for('Auth_InversifyExpressSubscriptionTokensController'),
Auth_InversifyExpressSubscriptionSettingsController: Symbol.for(
'Auth_InversifyExpressSubscriptionSettingsController',
),
Auth_InversifyExpressSettingsController: Symbol.for('Auth_InversifyExpressSettingsController'),
Auth_InversifyExpressSessionController: Symbol.for('Auth_InversifyExpressSessionController'),
Auth_InversifyExpressOfflineController: Symbol.for('Auth_InversifyExpressOfflineController'),
Auth_InversifyExpressListedController: Symbol.for('Auth_InversifyExpressListedController'),
Auth_InversifyExpressInternalController: Symbol.for('Auth_InversifyExpressInternalController'),
Auth_InversifyExpressFeaturesController: Symbol.for('Auth_InversifyExpressFeaturesController'),
}
export default TYPES

View file

@ -1,16 +1,16 @@
import 'reflect-metadata'
import { AdminController } from './AdminController'
import { InversifyExpressAdminController } from './InversifyExpressAdminController'
import { results } from 'inversify-express-utils'
import { User } from '../Domain/User/User'
import { UserRepositoryInterface } from '../Domain/User/UserRepositoryInterface'
import { User } from '../../Domain/User/User'
import { UserRepositoryInterface } from '../../Domain/User/UserRepositoryInterface'
import * as express from 'express'
import { DeleteSetting } from '../Domain/UseCase/DeleteSetting/DeleteSetting'
import { CreateSubscriptionToken } from '../Domain/UseCase/CreateSubscriptionToken/CreateSubscriptionToken'
import { CreateOfflineSubscriptionToken } from '../Domain/UseCase/CreateOfflineSubscriptionToken/CreateOfflineSubscriptionToken'
import { DeleteSetting } from '../../Domain/UseCase/DeleteSetting/DeleteSetting'
import { CreateSubscriptionToken } from '../../Domain/UseCase/CreateSubscriptionToken/CreateSubscriptionToken'
import { CreateOfflineSubscriptionToken } from '../../Domain/UseCase/CreateOfflineSubscriptionToken/CreateOfflineSubscriptionToken'
import { ControllerContainerInterface } from '@standardnotes/domain-core'
describe('AdminController', () => {
describe('InversifyExpressAdminController', () => {
let deleteSetting: DeleteSetting
let userRepository: UserRepositoryInterface
let createSubscriptionToken: CreateSubscriptionToken
@ -20,7 +20,7 @@ describe('AdminController', () => {
let controllerContainer: ControllerContainerInterface
const createController = () =>
new AdminController(
new InversifyExpressAdminController(
deleteSetting,
userRepository,
createSubscriptionToken,

View file

@ -11,14 +11,14 @@ import {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
results,
} from 'inversify-express-utils'
import TYPES from '../Bootstrap/Types'
import { CreateOfflineSubscriptionToken } from '../Domain/UseCase/CreateOfflineSubscriptionToken/CreateOfflineSubscriptionToken'
import { CreateSubscriptionToken } from '../Domain/UseCase/CreateSubscriptionToken/CreateSubscriptionToken'
import { DeleteSetting } from '../Domain/UseCase/DeleteSetting/DeleteSetting'
import { UserRepositoryInterface } from '../Domain/User/UserRepositoryInterface'
import TYPES from '../../Bootstrap/Types'
import { CreateOfflineSubscriptionToken } from '../../Domain/UseCase/CreateOfflineSubscriptionToken/CreateOfflineSubscriptionToken'
import { CreateSubscriptionToken } from '../../Domain/UseCase/CreateSubscriptionToken/CreateSubscriptionToken'
import { DeleteSetting } from '../../Domain/UseCase/DeleteSetting/DeleteSetting'
import { UserRepositoryInterface } from '../../Domain/User/UserRepositoryInterface'
@controller('/admin')
export class AdminController extends BaseHttpController {
export class InversifyExpressAdminController extends BaseHttpController {
constructor(
@inject(TYPES.Auth_DeleteSetting) private doDeleteSetting: DeleteSetting,
@inject(TYPES.Auth_UserRepository) private userRepository: UserRepositoryInterface,

View file

@ -2,13 +2,13 @@ import 'reflect-metadata'
import * as express from 'express'
import { FeaturesController } from './FeaturesController'
import { InversifyExpressFeaturesController } from './InversifyExpressFeaturesController'
import { results } from 'inversify-express-utils'
import { User } from '../Domain/User/User'
import { GetUserFeatures } from '../Domain/UseCase/GetUserFeatures/GetUserFeatures'
import { User } from '../../Domain/User/User'
import { GetUserFeatures } from '../../Domain/UseCase/GetUserFeatures/GetUserFeatures'
import { ControllerContainerInterface } from '@standardnotes/domain-core'
describe('FeaturesController', () => {
describe('InversifyExpressFeaturesController', () => {
let getUserFeatures: GetUserFeatures
let request: express.Request
@ -16,7 +16,7 @@ describe('FeaturesController', () => {
let user: User
let controllerContainer: ControllerContainerInterface
const createController = () => new FeaturesController(getUserFeatures, controllerContainer)
const createController = () => new InversifyExpressFeaturesController(getUserFeatures, controllerContainer)
beforeEach(() => {
controllerContainer = {} as jest.Mocked<ControllerContainerInterface>

View file

@ -7,12 +7,12 @@ import {
// 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'
import TYPES from '../../Bootstrap/Types'
import { GetUserFeatures } from '../../Domain/UseCase/GetUserFeatures/GetUserFeatures'
import { ControllerContainerInterface } from '@standardnotes/domain-core'
@controller('/users/:userUuid/features')
export class FeaturesController extends BaseHttpController {
export class InversifyExpressFeaturesController extends BaseHttpController {
constructor(
@inject(TYPES.Auth_GetUserFeatures) private doGetUserFeatures: GetUserFeatures,
@inject(TYPES.Auth_ControllerContainer) private controllerContainer: ControllerContainerInterface,

View file

@ -1,7 +1,7 @@
import { controller, httpGet } from 'inversify-express-utils'
@controller('/healthcheck')
export class HealthCheckController {
export class InversifyExpressHealthCheckController {
@httpGet('/')
public async get(): Promise<string> {
return 'OK'

View file

@ -2,13 +2,13 @@ import 'reflect-metadata'
import * as express from 'express'
import { InternalController } from './InternalController'
import { InversifyExpressInternalController } from './InversifyExpressInternalController'
import { results } from 'inversify-express-utils'
import { User } from '../Domain/User/User'
import { GetUserFeatures } from '../Domain/UseCase/GetUserFeatures/GetUserFeatures'
import { GetSetting } from '../Domain/UseCase/GetSetting/GetSetting'
import { User } from '../../Domain/User/User'
import { GetUserFeatures } from '../../Domain/UseCase/GetUserFeatures/GetUserFeatures'
import { GetSetting } from '../../Domain/UseCase/GetSetting/GetSetting'
describe('InternalController', () => {
describe('InversifyExpressInternalController', () => {
let getUserFeatures: GetUserFeatures
let getSetting: GetSetting
@ -16,7 +16,7 @@ describe('InternalController', () => {
let response: express.Response
let user: User
const createController = () => new InternalController(getUserFeatures, getSetting)
const createController = () => new InversifyExpressInternalController(getUserFeatures, getSetting)
beforeEach(() => {
user = {} as jest.Mocked<User>

View file

@ -7,12 +7,12 @@ import {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
results,
} from 'inversify-express-utils'
import TYPES from '../Bootstrap/Types'
import { GetSetting } from '../Domain/UseCase/GetSetting/GetSetting'
import { GetUserFeatures } from '../Domain/UseCase/GetUserFeatures/GetUserFeatures'
import TYPES from '../../Bootstrap/Types'
import { GetSetting } from '../../Domain/UseCase/GetSetting/GetSetting'
import { GetUserFeatures } from '../../Domain/UseCase/GetUserFeatures/GetUserFeatures'
@controller('/internal')
export class InternalController extends BaseHttpController {
export class InversifyExpressInternalController extends BaseHttpController {
constructor(
@inject(TYPES.Auth_GetUserFeatures) private doGetUserFeatures: GetUserFeatures,
@inject(TYPES.Auth_GetSetting) private doGetSetting: GetSetting,

View file

@ -3,12 +3,12 @@ import 'reflect-metadata'
import * as express from 'express'
import { results } from 'inversify-express-utils'
import { ListedController } from './ListedController'
import { User } from '../Domain/User/User'
import { CreateListedAccount } from '../Domain/UseCase/CreateListedAccount/CreateListedAccount'
import { InversifyExpressListedController } from './InversifyExpressListedController'
import { User } from '../../Domain/User/User'
import { CreateListedAccount } from '../../Domain/UseCase/CreateListedAccount/CreateListedAccount'
import { ControllerContainerInterface } from '@standardnotes/domain-core'
describe('ListedController', () => {
describe('InversifyExpressListedController', () => {
let createListedAccount: CreateListedAccount
let request: express.Request
@ -16,7 +16,7 @@ describe('ListedController', () => {
let user: User
let controllerContainer: ControllerContainerInterface
const createController = () => new ListedController(createListedAccount, controllerContainer)
const createController = () => new InversifyExpressListedController(createListedAccount, controllerContainer)
beforeEach(() => {
controllerContainer = {} as jest.Mocked<ControllerContainerInterface>

View file

@ -2,13 +2,13 @@ import { inject } from 'inversify'
// eslint-disable-next-line @typescript-eslint/no-unused-vars
import { BaseHttpController, controller, httpPost, results } from 'inversify-express-utils'
import { Request, Response } from 'express'
import TYPES from '../Bootstrap/Types'
import { CreateListedAccount } from '../Domain/UseCase/CreateListedAccount/CreateListedAccount'
import TYPES from '../../Bootstrap/Types'
import { CreateListedAccount } from '../../Domain/UseCase/CreateListedAccount/CreateListedAccount'
import { ErrorTag } from '@standardnotes/responses'
import { ControllerContainerInterface } from '@standardnotes/domain-core'
@controller('/listed')
export class ListedController extends BaseHttpController {
export class InversifyExpressListedController extends BaseHttpController {
constructor(
@inject(TYPES.Auth_CreateListedAccount) private doCreateListedAccount: CreateListedAccount,
@inject(TYPES.Auth_ControllerContainer) private controllerContainer: ControllerContainerInterface,

View file

@ -2,21 +2,21 @@ import 'reflect-metadata'
import * as express from 'express'
import { OfflineController } from './OfflineController'
import { InversifyExpressOfflineController } from './InversifyExpressOfflineController'
import { results } from 'inversify-express-utils'
import { User } from '../Domain/User/User'
import { GetUserFeatures } from '../Domain/UseCase/GetUserFeatures/GetUserFeatures'
import { CreateOfflineSubscriptionToken } from '../Domain/UseCase/CreateOfflineSubscriptionToken/CreateOfflineSubscriptionToken'
import { CreateOfflineSubscriptionTokenResponse } from '../Domain/UseCase/CreateOfflineSubscriptionToken/CreateOfflineSubscriptionTokenResponse'
import { AuthenticateOfflineSubscriptionToken } from '../Domain/UseCase/AuthenticateOfflineSubscriptionToken/AuthenticateOfflineSubscriptionToken'
import { OfflineUserSubscription } from '../Domain/Subscription/OfflineUserSubscription'
import { GetUserOfflineSubscription } from '../Domain/UseCase/GetUserOfflineSubscription/GetUserOfflineSubscription'
import { User } from '../../Domain/User/User'
import { GetUserFeatures } from '../../Domain/UseCase/GetUserFeatures/GetUserFeatures'
import { CreateOfflineSubscriptionToken } from '../../Domain/UseCase/CreateOfflineSubscriptionToken/CreateOfflineSubscriptionToken'
import { CreateOfflineSubscriptionTokenResponse } from '../../Domain/UseCase/CreateOfflineSubscriptionToken/CreateOfflineSubscriptionTokenResponse'
import { AuthenticateOfflineSubscriptionToken } from '../../Domain/UseCase/AuthenticateOfflineSubscriptionToken/AuthenticateOfflineSubscriptionToken'
import { OfflineUserSubscription } from '../../Domain/Subscription/OfflineUserSubscription'
import { GetUserOfflineSubscription } from '../../Domain/UseCase/GetUserOfflineSubscription/GetUserOfflineSubscription'
import { OfflineUserTokenData, TokenEncoderInterface } from '@standardnotes/security'
import { SubscriptionName } from '@standardnotes/common'
import { Logger } from 'winston'
import { ControllerContainerInterface } from '@standardnotes/domain-core'
describe('OfflineController', () => {
describe('InversifyExpressOfflineController', () => {
let getUserFeatures: GetUserFeatures
let getUserOfflineSubscription: GetUserOfflineSubscription
let createOfflineSubscriptionToken: CreateOfflineSubscriptionToken
@ -32,7 +32,7 @@ describe('OfflineController', () => {
let controllerContainer: ControllerContainerInterface
const createController = () =>
new OfflineController(
new InversifyExpressOfflineController(
getUserFeatures,
getUserOfflineSubscription,
createOfflineSubscriptionToken,

View file

@ -8,17 +8,17 @@ import {
// 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'
import { AuthenticateOfflineSubscriptionToken } from '../Domain/UseCase/AuthenticateOfflineSubscriptionToken/AuthenticateOfflineSubscriptionToken'
import { CreateOfflineSubscriptionToken } from '../Domain/UseCase/CreateOfflineSubscriptionToken/CreateOfflineSubscriptionToken'
import { GetUserOfflineSubscription } from '../Domain/UseCase/GetUserOfflineSubscription/GetUserOfflineSubscription'
import { Logger } from 'winston'
import { OfflineUserTokenData, TokenEncoderInterface } from '@standardnotes/security'
import { ControllerContainerInterface } from '@standardnotes/domain-core'
import TYPES from '../../Bootstrap/Types'
import { AuthenticateOfflineSubscriptionToken } from '../../Domain/UseCase/AuthenticateOfflineSubscriptionToken/AuthenticateOfflineSubscriptionToken'
import { CreateOfflineSubscriptionToken } from '../../Domain/UseCase/CreateOfflineSubscriptionToken/CreateOfflineSubscriptionToken'
import { GetUserFeatures } from '../../Domain/UseCase/GetUserFeatures/GetUserFeatures'
import { GetUserOfflineSubscription } from '../../Domain/UseCase/GetUserOfflineSubscription/GetUserOfflineSubscription'
@controller('/offline')
export class OfflineController extends BaseHttpController {
export class InversifyExpressOfflineController extends BaseHttpController {
constructor(
@inject(TYPES.Auth_GetUserFeatures) private doGetUserFeatures: GetUserFeatures,
@inject(TYPES.Auth_GetUserOfflineSubscription) private getUserOfflineSubscription: GetUserOfflineSubscription,

View file

@ -2,14 +2,14 @@ import 'reflect-metadata'
import * as express from 'express'
import { SessionController } from './SessionController'
import { InversifyExpressSessionController } from './InversifyExpressSessionController'
import { results } from 'inversify-express-utils'
import { RefreshSessionToken } from '../Domain/UseCase/RefreshSessionToken'
import { DeletePreviousSessionsForUser } from '../Domain/UseCase/DeletePreviousSessionsForUser'
import { DeleteSessionForUser } from '../Domain/UseCase/DeleteSessionForUser'
import { ControllerContainerInterface } from '@standardnotes/domain-core'
import { DeletePreviousSessionsForUser } from '../../Domain/UseCase/DeletePreviousSessionsForUser'
import { DeleteSessionForUser } from '../../Domain/UseCase/DeleteSessionForUser'
import { RefreshSessionToken } from '../../Domain/UseCase/RefreshSessionToken'
describe('SessionController', () => {
describe('InversifyExpressSessionController', () => {
let deleteSessionForUser: DeleteSessionForUser
let deletePreviousSessionsForUser: DeletePreviousSessionsForUser
let refreshSessionToken: RefreshSessionToken
@ -18,7 +18,12 @@ describe('SessionController', () => {
let controllerContainer: ControllerContainerInterface
const createController = () =>
new SessionController(deleteSessionForUser, deletePreviousSessionsForUser, refreshSessionToken, controllerContainer)
new InversifyExpressSessionController(
deleteSessionForUser,
deletePreviousSessionsForUser,
refreshSessionToken,
controllerContainer,
)
beforeEach(() => {
controllerContainer = {} as jest.Mocked<ControllerContainerInterface>

View file

@ -9,14 +9,14 @@ import {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
results,
} from 'inversify-express-utils'
import TYPES from '../Bootstrap/Types'
import { DeletePreviousSessionsForUser } from '../Domain/UseCase/DeletePreviousSessionsForUser'
import { DeleteSessionForUser } from '../Domain/UseCase/DeleteSessionForUser'
import { RefreshSessionToken } from '../Domain/UseCase/RefreshSessionToken'
import TYPES from '../../Bootstrap/Types'
import { DeletePreviousSessionsForUser } from '../../Domain/UseCase/DeletePreviousSessionsForUser'
import { DeleteSessionForUser } from '../../Domain/UseCase/DeleteSessionForUser'
import { RefreshSessionToken } from '../../Domain/UseCase/RefreshSessionToken'
import { ControllerContainerInterface } from '@standardnotes/domain-core'
@controller('/session')
export class SessionController extends BaseHttpController {
export class InversifyExpressSessionController extends BaseHttpController {
constructor(
@inject(TYPES.Auth_DeleteSessionForUser) private deleteSessionForUser: DeleteSessionForUser,
@inject(TYPES.Auth_DeletePreviousSessionsForUser)

View file

@ -2,17 +2,17 @@ import 'reflect-metadata'
import * as express from 'express'
import { SettingsController } from './SettingsController'
import { InversifyExpressSettingsController } from './InversifyExpressSettingsController'
import { results } from 'inversify-express-utils'
import { User } from '../Domain/User/User'
import { GetSettings } from '../Domain/UseCase/GetSettings/GetSettings'
import { GetSetting } from '../Domain/UseCase/GetSetting/GetSetting'
import { UpdateSetting } from '../Domain/UseCase/UpdateSetting/UpdateSetting'
import { DeleteSetting } from '../Domain/UseCase/DeleteSetting/DeleteSetting'
import { EncryptionVersion } from '../Domain/Encryption/EncryptionVersion'
import { ControllerContainerInterface } from '@standardnotes/domain-core'
import { EncryptionVersion } from '../../Domain/Encryption/EncryptionVersion'
import { DeleteSetting } from '../../Domain/UseCase/DeleteSetting/DeleteSetting'
import { GetSetting } from '../../Domain/UseCase/GetSetting/GetSetting'
import { GetSettings } from '../../Domain/UseCase/GetSettings/GetSettings'
import { UpdateSetting } from '../../Domain/UseCase/UpdateSetting/UpdateSetting'
import { User } from '../../Domain/User/User'
describe('SettingsController', () => {
describe('InversifyExpressSettingsController', () => {
let deleteSetting: DeleteSetting
let getSettings: GetSettings
let getSetting: GetSetting
@ -24,7 +24,7 @@ describe('SettingsController', () => {
let controllerContainer: ControllerContainerInterface
const createController = () =>
new SettingsController(getSettings, getSetting, updateSetting, deleteSetting, controllerContainer)
new InversifyExpressSettingsController(getSettings, getSetting, updateSetting, deleteSetting, controllerContainer)
beforeEach(() => {
controllerContainer = {} as jest.Mocked<ControllerContainerInterface>

View file

@ -10,16 +10,16 @@ import {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
results,
} from 'inversify-express-utils'
import TYPES from '../Bootstrap/Types'
import { EncryptionVersion } from '../Domain/Encryption/EncryptionVersion'
import { DeleteSetting } from '../Domain/UseCase/DeleteSetting/DeleteSetting'
import { GetSetting } from '../Domain/UseCase/GetSetting/GetSetting'
import { GetSettings } from '../Domain/UseCase/GetSettings/GetSettings'
import { UpdateSetting } from '../Domain/UseCase/UpdateSetting/UpdateSetting'
import TYPES from '../../Bootstrap/Types'
import { EncryptionVersion } from '../../Domain/Encryption/EncryptionVersion'
import { DeleteSetting } from '../../Domain/UseCase/DeleteSetting/DeleteSetting'
import { GetSetting } from '../../Domain/UseCase/GetSetting/GetSetting'
import { GetSettings } from '../../Domain/UseCase/GetSettings/GetSettings'
import { UpdateSetting } from '../../Domain/UseCase/UpdateSetting/UpdateSetting'
import { ControllerContainerInterface } from '@standardnotes/domain-core'
@controller('/users/:userUuid')
export class SettingsController extends BaseHttpController {
export class InversifyExpressSettingsController extends BaseHttpController {
constructor(
@inject(TYPES.Auth_GetSettings) private doGetSettings: GetSettings,
@inject(TYPES.Auth_GetSetting) private doGetSetting: GetSetting,

View file

@ -3,12 +3,12 @@ import 'reflect-metadata'
import * as express from 'express'
import { results } from 'inversify-express-utils'
import { User } from '../Domain/User/User'
import { SubscriptionSettingsController } from './SubscriptionSettingsController'
import { GetSetting } from '../Domain/UseCase/GetSetting/GetSetting'
import { InversifyExpressSubscriptionSettingsController } from './InversifyExpressSubscriptionSettingsController'
import { ControllerContainerInterface } from '@standardnotes/domain-core'
import { User } from '../../Domain/User/User'
import { GetSetting } from '../../Domain/UseCase/GetSetting/GetSetting'
describe('SubscriptionSettingsController', () => {
describe('InversifyExpressSubscriptionSettingsController', () => {
let getSetting: GetSetting
let request: express.Request
@ -16,7 +16,7 @@ describe('SubscriptionSettingsController', () => {
let user: User
let controllerContainer: ControllerContainerInterface
const createController = () => new SubscriptionSettingsController(getSetting, controllerContainer)
const createController = () => new InversifyExpressSubscriptionSettingsController(getSetting, controllerContainer)
beforeEach(() => {
controllerContainer = {} as jest.Mocked<ControllerContainerInterface>

View file

@ -7,12 +7,12 @@ import {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
results,
} from 'inversify-express-utils'
import TYPES from '../Bootstrap/Types'
import { GetSetting } from '../Domain/UseCase/GetSetting/GetSetting'
import TYPES from '../../Bootstrap/Types'
import { GetSetting } from '../../Domain/UseCase/GetSetting/GetSetting'
import { ControllerContainerInterface } from '@standardnotes/domain-core'
@controller('/users/:userUuid')
export class SubscriptionSettingsController extends BaseHttpController {
export class InversifyExpressSubscriptionSettingsController extends BaseHttpController {
constructor(
@inject(TYPES.Auth_GetSetting) private doGetSetting: GetSetting,
@inject(TYPES.Auth_ControllerContainer) private controllerContainer: ControllerContainerInterface,

View file

@ -3,19 +3,19 @@ import 'reflect-metadata'
import * as express from 'express'
import { results } from 'inversify-express-utils'
import { SubscriptionTokensController } from './SubscriptionTokensController'
import { User } from '../Domain/User/User'
import { CreateSubscriptionToken } from '../Domain/UseCase/CreateSubscriptionToken/CreateSubscriptionToken'
import { CreateSubscriptionTokenResponse } from '../Domain/UseCase/CreateSubscriptionToken/CreateSubscriptionTokenResponse'
import { AuthenticateSubscriptionToken } from '../Domain/UseCase/AuthenticateSubscriptionToken/AuthenticateSubscriptionToken'
import { ProjectorInterface } from '../Projection/ProjectorInterface'
import { Role } from '../Domain/Role/Role'
import { SettingServiceInterface } from '../Domain/Setting/SettingServiceInterface'
import { Setting } from '../Domain/Setting/Setting'
import { InversifyExpressSubscriptionTokensController } from './InversifyExpressSubscriptionTokensController'
import { CrossServiceTokenData, TokenEncoderInterface } from '@standardnotes/security'
import { ControllerContainerInterface } from '@standardnotes/domain-core'
import { Setting } from '../../Domain/Setting/Setting'
import { SettingServiceInterface } from '../../Domain/Setting/SettingServiceInterface'
import { AuthenticateSubscriptionToken } from '../../Domain/UseCase/AuthenticateSubscriptionToken/AuthenticateSubscriptionToken'
import { CreateSubscriptionToken } from '../../Domain/UseCase/CreateSubscriptionToken/CreateSubscriptionToken'
import { CreateSubscriptionTokenResponse } from '../../Domain/UseCase/CreateSubscriptionToken/CreateSubscriptionTokenResponse'
import { ProjectorInterface } from '../../Projection/ProjectorInterface'
import { User } from '../../Domain/User/User'
import { Role } from '../../Domain/Role/Role'
describe('SubscriptionTokensController', () => {
describe('InversifyExpressSubscriptionTokensController', () => {
let createSubscriptionToken: CreateSubscriptionToken
let authenticateToken: AuthenticateSubscriptionToken
const jwtTTL = 60
@ -33,7 +33,7 @@ describe('SubscriptionTokensController', () => {
let controllerContainer: ControllerContainerInterface
const createController = () =>
new SubscriptionTokensController(
new InversifyExpressSubscriptionTokensController(
createSubscriptionToken,
authenticateToken,
settingService,

View file

@ -11,17 +11,17 @@ import {
results,
} from 'inversify-express-utils'
import TYPES from '../Bootstrap/Types'
import { Role } from '../Domain/Role/Role'
import { SettingServiceInterface } from '../Domain/Setting/SettingServiceInterface'
import { AuthenticateSubscriptionToken } from '../Domain/UseCase/AuthenticateSubscriptionToken/AuthenticateSubscriptionToken'
import { CreateSubscriptionToken } from '../Domain/UseCase/CreateSubscriptionToken/CreateSubscriptionToken'
import { User } from '../Domain/User/User'
import { ProjectorInterface } from '../Projection/ProjectorInterface'
import TYPES from '../../Bootstrap/Types'
import { Role } from '../../Domain/Role/Role'
import { SettingServiceInterface } from '../../Domain/Setting/SettingServiceInterface'
import { AuthenticateSubscriptionToken } from '../../Domain/UseCase/AuthenticateSubscriptionToken/AuthenticateSubscriptionToken'
import { CreateSubscriptionToken } from '../../Domain/UseCase/CreateSubscriptionToken/CreateSubscriptionToken'
import { User } from '../../Domain/User/User'
import { ProjectorInterface } from '../../Projection/ProjectorInterface'
import { ControllerContainerInterface } from '@standardnotes/domain-core'
@controller('/subscription-tokens')
export class SubscriptionTokensController extends BaseHttpController {
export class InversifyExpressSubscriptionTokensController extends BaseHttpController {
constructor(
@inject(TYPES.Auth_CreateSubscriptionToken) private createSubscriptionToken: CreateSubscriptionToken,
@inject(TYPES.Auth_AuthenticateSubscriptionToken) private authenticateToken: AuthenticateSubscriptionToken,

View file

@ -2,20 +2,20 @@ import 'reflect-metadata'
import * as express from 'express'
import { UsersController } from './UsersController'
import { InversifyExpressUsersController } from './InversifyExpressUsersController'
import { results } from 'inversify-express-utils'
import { User } from '../Domain/User/User'
import { UpdateUser } from '../Domain/UseCase/UpdateUser'
import { GetUserKeyParams } from '../Domain/UseCase/GetUserKeyParams/GetUserKeyParams'
import { DeleteAccount } from '../Domain/UseCase/DeleteAccount/DeleteAccount'
import { GetUserSubscription } from '../Domain/UseCase/GetUserSubscription/GetUserSubscription'
import { ClearLoginAttempts } from '../Domain/UseCase/ClearLoginAttempts'
import { IncreaseLoginAttempts } from '../Domain/UseCase/IncreaseLoginAttempts'
import { ChangeCredentials } from '../Domain/UseCase/ChangeCredentials/ChangeCredentials'
import { InviteToSharedSubscription } from '../Domain/UseCase/InviteToSharedSubscription/InviteToSharedSubscription'
import { ControllerContainerInterface } from '@standardnotes/domain-core'
import { DeleteAccount } from '../../Domain/UseCase/DeleteAccount/DeleteAccount'
import { ChangeCredentials } from '../../Domain/UseCase/ChangeCredentials/ChangeCredentials'
import { ClearLoginAttempts } from '../../Domain/UseCase/ClearLoginAttempts'
import { GetUserKeyParams } from '../../Domain/UseCase/GetUserKeyParams/GetUserKeyParams'
import { GetUserSubscription } from '../../Domain/UseCase/GetUserSubscription/GetUserSubscription'
import { IncreaseLoginAttempts } from '../../Domain/UseCase/IncreaseLoginAttempts'
import { InviteToSharedSubscription } from '../../Domain/UseCase/InviteToSharedSubscription/InviteToSharedSubscription'
import { UpdateUser } from '../../Domain/UseCase/UpdateUser'
import { User } from '../../Domain/User/User'
describe('UsersController', () => {
describe('InversifyExpressUsersController', () => {
let updateUser: UpdateUser
let deleteAccount: DeleteAccount
let getUserKeyParams: GetUserKeyParams
@ -31,7 +31,7 @@ describe('UsersController', () => {
let controllerContainer: ControllerContainerInterface
const createController = () =>
new UsersController(
new InversifyExpressUsersController(
updateUser,
getUserKeyParams,
deleteAccount,

View file

@ -11,18 +11,18 @@ import {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
results,
} from 'inversify-express-utils'
import TYPES from '../Bootstrap/Types'
import { DeleteAccount } from '../Domain/UseCase/DeleteAccount/DeleteAccount'
import { GetUserKeyParams } from '../Domain/UseCase/GetUserKeyParams/GetUserKeyParams'
import { UpdateUser } from '../Domain/UseCase/UpdateUser'
import { GetUserSubscription } from '../Domain/UseCase/GetUserSubscription/GetUserSubscription'
import { ClearLoginAttempts } from '../Domain/UseCase/ClearLoginAttempts'
import { IncreaseLoginAttempts } from '../Domain/UseCase/IncreaseLoginAttempts'
import { ChangeCredentials } from '../Domain/UseCase/ChangeCredentials/ChangeCredentials'
import TYPES from '../../Bootstrap/Types'
import { DeleteAccount } from '../../Domain/UseCase/DeleteAccount/DeleteAccount'
import { GetUserKeyParams } from '../../Domain/UseCase/GetUserKeyParams/GetUserKeyParams'
import { UpdateUser } from '../../Domain/UseCase/UpdateUser'
import { GetUserSubscription } from '../../Domain/UseCase/GetUserSubscription/GetUserSubscription'
import { ClearLoginAttempts } from '../../Domain/UseCase/ClearLoginAttempts'
import { IncreaseLoginAttempts } from '../../Domain/UseCase/IncreaseLoginAttempts'
import { ChangeCredentials } from '../../Domain/UseCase/ChangeCredentials/ChangeCredentials'
import { ControllerContainerInterface } from '@standardnotes/domain-core'
@controller('/users')
export class UsersController extends BaseHttpController {
export class InversifyExpressUsersController extends BaseHttpController {
constructor(
@inject(TYPES.Auth_UpdateUser) private updateUser: UpdateUser,
@inject(TYPES.Auth_GetUserKeyParams) private getUserKeyParams: GetUserKeyParams,

View file

@ -2,17 +2,17 @@ import 'reflect-metadata'
import { Request, Response } from 'express'
import { results } from 'inversify-express-utils'
import { ValetTokenController } from './ValetTokenController'
import { CreateValetToken } from '../Domain/UseCase/CreateValetToken/CreateValetToken'
import { InversifyExpressValetTokenController } from './InversifyExpressValetTokenController'
import { CreateValetToken } from '../../Domain/UseCase/CreateValetToken/CreateValetToken'
import { ControllerContainerInterface } from '@standardnotes/domain-core'
describe('ValetTokenController', () => {
describe('InversifyExpressValetTokenController', () => {
let createValetToken: CreateValetToken
let request: Request
let response: Response
let controllerContainer: ControllerContainerInterface
const createController = () => new ValetTokenController(createValetToken, controllerContainer)
const createController = () => new InversifyExpressValetTokenController(createValetToken, controllerContainer)
beforeEach(() => {
controllerContainer = {} as jest.Mocked<ControllerContainerInterface>

View file

@ -10,12 +10,11 @@ import {
import { CreateValetTokenPayload, ErrorTag } from '@standardnotes/responses'
import { ValetTokenOperation } from '@standardnotes/security'
import { ControllerContainerInterface, Uuid } from '@standardnotes/domain-core'
import TYPES from '../Bootstrap/Types'
import { CreateValetToken } from '../Domain/UseCase/CreateValetToken/CreateValetToken'
import TYPES from '../../Bootstrap/Types'
import { CreateValetToken } from '../../Domain/UseCase/CreateValetToken/CreateValetToken'
@controller('/valet-tokens', TYPES.Auth_ApiGatewayAuthMiddleware)
export class ValetTokenController extends BaseHttpController {
export class InversifyExpressValetTokenController extends BaseHttpController {
constructor(
@inject(TYPES.Auth_CreateValetToken) private createValetKey: CreateValetToken,
@inject(TYPES.Auth_ControllerContainer) private controllerContainer: ControllerContainerInterface,

View file

@ -3,7 +3,7 @@ import { NextFunction, Request, Response } from 'express'
import { inject, injectable } from 'inversify'
import { BaseMiddleware } from 'inversify-express-utils'
import { Logger } from 'winston'
import TYPES from '../Bootstrap/Types'
import TYPES from '../../../Bootstrap/Types'
@injectable()
export class ApiGatewayAuthMiddleware extends BaseMiddleware {

View file

@ -3,7 +3,7 @@ import { NextFunction, Request, Response } from 'express'
import { inject, injectable } from 'inversify'
import { BaseMiddleware } from 'inversify-express-utils'
import { Logger } from 'winston'
import TYPES from '../Bootstrap/Types'
import TYPES from '../../../Bootstrap/Types'
@injectable()
export class ApiGatewayOfflineAuthMiddleware extends BaseMiddleware {

View file

@ -2,9 +2,9 @@ import 'reflect-metadata'
import { AuthMiddleware } from './AuthMiddleware'
import { NextFunction, Request, Response } from 'express'
import { User } from '../Domain/User/User'
import { AuthenticateRequest } from '../Domain/UseCase/AuthenticateRequest'
import { Session } from '../Domain/Session/Session'
import { User } from '../../../Domain/User/User'
import { AuthenticateRequest } from '../../../Domain/UseCase/AuthenticateRequest'
import { Session } from '../../../Domain/Session/Session'
import { Logger } from 'winston'
describe('AuthMiddleware', () => {

View file

@ -2,8 +2,8 @@ import { NextFunction, Request, Response } from 'express'
import { inject, injectable } from 'inversify'
import { BaseMiddleware } from 'inversify-express-utils'
import { Logger } from 'winston'
import TYPES from '../Bootstrap/Types'
import { AuthenticateRequest } from '../Domain/UseCase/AuthenticateRequest'
import TYPES from '../../../Bootstrap/Types'
import { AuthenticateRequest } from '../../../Domain/UseCase/AuthenticateRequest'
@injectable()
export class AuthMiddleware extends BaseMiddleware {

View file

@ -2,9 +2,9 @@ import 'reflect-metadata'
import { AuthMiddlewareWithoutResponse } from './AuthMiddlewareWithoutResponse'
import { NextFunction, Request, Response } from 'express'
import { User } from '../Domain/User/User'
import { AuthenticateRequest } from '../Domain/UseCase/AuthenticateRequest'
import { Session } from '../Domain/Session/Session'
import { User } from '../../../Domain/User/User'
import { AuthenticateRequest } from '../../../Domain/UseCase/AuthenticateRequest'
import { Session } from '../../../Domain/Session/Session'
describe('AuthMiddlewareWithoutResponse', () => {
let authenticateRequest: AuthenticateRequest

View file

@ -1,8 +1,8 @@
import { NextFunction, Request, Response } from 'express'
import { inject, injectable } from 'inversify'
import { BaseMiddleware } from 'inversify-express-utils'
import TYPES from '../Bootstrap/Types'
import { AuthenticateRequest } from '../Domain/UseCase/AuthenticateRequest'
import TYPES from '../../../Bootstrap/Types'
import { AuthenticateRequest } from '../../../Domain/UseCase/AuthenticateRequest'
@injectable()
export class AuthMiddlewareWithoutResponse extends BaseMiddleware {

View file

@ -2,9 +2,9 @@ import 'reflect-metadata'
import { LockMiddleware } from './LockMiddleware'
import { NextFunction, Request, Response } from 'express'
import { User } from '../Domain/User/User'
import { UserRepositoryInterface } from '../Domain/User/UserRepositoryInterface'
import { LockRepositoryInterface } from '../Domain/User/LockRepositoryInterface'
import { User } from '../../../Domain/User/User'
import { UserRepositoryInterface } from '../../../Domain/User/UserRepositoryInterface'
import { LockRepositoryInterface } from '../../../Domain/User/LockRepositoryInterface'
describe('LockMiddleware', () => {
let userRepository: UserRepositoryInterface

View file

@ -2,10 +2,10 @@ import { Username } from '@standardnotes/domain-core'
import { NextFunction, Request, Response } from 'express'
import { inject, injectable } from 'inversify'
import { BaseMiddleware } from 'inversify-express-utils'
import TYPES from '../Bootstrap/Types'
import { LockRepositoryInterface } from '../Domain/User/LockRepositoryInterface'
import TYPES from '../../../Bootstrap/Types'
import { LockRepositoryInterface } from '../../../Domain/User/LockRepositoryInterface'
import { UserRepositoryInterface } from '../Domain/User/UserRepositoryInterface'
import { UserRepositoryInterface } from '../../../Domain/User/UserRepositoryInterface'
@injectable()
export class LockMiddleware extends BaseMiddleware {

View file

@ -3,8 +3,8 @@ import 'reflect-metadata'
import { OfflineUserAuthMiddleware } from './OfflineUserAuthMiddleware'
import { NextFunction, Request, Response } from 'express'
import { Logger } from 'winston'
import { OfflineSettingRepositoryInterface } from '../Domain/Setting/OfflineSettingRepositoryInterface'
import { OfflineSetting } from '../Domain/Setting/OfflineSetting'
import { OfflineSettingRepositoryInterface } from '../../../Domain/Setting/OfflineSettingRepositoryInterface'
import { OfflineSetting } from '../../../Domain/Setting/OfflineSetting'
describe('OfflineUserAuthMiddleware', () => {
let offlineSettingRepository: OfflineSettingRepositoryInterface

View file

@ -2,9 +2,9 @@ import { NextFunction, Request, Response } from 'express'
import { inject, injectable } from 'inversify'
import { BaseMiddleware } from 'inversify-express-utils'
import { Logger } from 'winston'
import TYPES from '../Bootstrap/Types'
import { OfflineSettingName } from '../Domain/Setting/OfflineSettingName'
import { OfflineSettingRepositoryInterface } from '../Domain/Setting/OfflineSettingRepositoryInterface'
import TYPES from '../../../Bootstrap/Types'
import { OfflineSettingName } from '../../../Domain/Setting/OfflineSettingName'
import { OfflineSettingRepositoryInterface } from '../../../Domain/Setting/OfflineSettingRepositoryInterface'
@injectable()
export class OfflineUserAuthMiddleware extends BaseMiddleware {

View file

@ -50,7 +50,6 @@
"@types/cors": "^2.8.9",
"@types/dotenv": "^8.2.0",
"@types/express": "^4.17.14",
"@types/inversify-express-utils": "^2.0.0",
"@types/jest": "^29.5.1",
"@types/newrelic": "^9.13.0",
"@typescript-eslint/eslint-plugin": "^5.59.2",

View file

@ -61,7 +61,6 @@
"@types/cors": "^2.8.9",
"@types/dotenv": "^8.2.0",
"@types/express": "^4.17.14",
"@types/inversify-express-utils": "^2.0.0",
"@types/jest": "^29.5.1",
"@types/jsonwebtoken": "^9.0.1",
"@types/newrelic": "^9.13.0",

View file

@ -4330,7 +4330,6 @@ __metadata:
"@types/cors": "npm:^2.8.9"
"@types/dotenv": "npm:^8.2.0"
"@types/express": "npm:^4.17.14"
"@types/inversify-express-utils": "npm:^2.0.0"
"@types/jest": "npm:^29.5.1"
"@types/newrelic": "npm:^9.13.0"
"@typescript-eslint/eslint-plugin": "npm:^5.59.2"
@ -4504,7 +4503,6 @@ __metadata:
"@types/cors": "npm:^2.8.9"
"@types/dotenv": "npm:^8.2.0"
"@types/express": "npm:^4.17.14"
"@types/inversify-express-utils": "npm:^2.0.0"
"@types/jest": "npm:^29.5.1"
"@types/jsonwebtoken": "npm:^9.0.1"
"@types/newrelic": "npm:^9.13.0"
@ -4864,15 +4862,6 @@ __metadata:
languageName: node
linkType: hard
"@types/inversify-express-utils@npm:^2.0.0":
version: 2.0.0
resolution: "@types/inversify-express-utils@npm:2.0.0"
dependencies:
inversify-express-utils: "npm:*"
checksum: 9841bfddffc915cd79fb3434dfc992827d2cf18870ea628562d27307dde39f7d623cce820a478e82f6addee264e3a2a71df760f0c5815dcb567827491b81a0e9
languageName: node
linkType: hard
"@types/ioredis@npm:^5.0.0":
version: 5.0.0
resolution: "@types/ioredis@npm:5.0.0"
@ -8724,7 +8713,7 @@ __metadata:
languageName: node
linkType: hard
"inversify-express-utils@npm:*, inversify-express-utils@npm:^6.4.3":
"inversify-express-utils@npm:^6.4.3":
version: 6.4.3
resolution: "inversify-express-utils@npm:6.4.3"
dependencies: