Skip to content

Commit 64fb40a

Browse files
committed
Drop session decorators
1 parent 9d5a7fa commit 64fb40a

File tree

3 files changed

+1
-42
lines changed

3 files changed

+1
-42
lines changed

src/common/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export * from './secured-mapper';
4949
export * from './sensitivity.enum';
5050
export * from './trace-layer';
5151
export * from './util';
52-
export { type Session, LoggedInSession, AnonSession } from './session';
52+
export { type Session } from './session';
5353
export * from './types';
5454
export * from './validators';
5555
export * from './name-field';

src/common/session.ts

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,4 @@
1-
import {
2-
Injectable,
3-
Param,
4-
type PipeTransform,
5-
type Type,
6-
} from '@nestjs/common';
7-
import { CONTROLLER_WATERMARK } from '@nestjs/common/constants.js';
8-
import { Context } from '@nestjs/graphql';
91
import { type DateTime } from 'luxon';
10-
import { Identity } from '~/core/authentication';
112
import { type ScopedRole } from '../components/authorization/dto';
123
import { type ID } from './id-field';
134

@@ -30,33 +21,3 @@ export interface Session {
3021
roles: readonly ScopedRole[];
3122
};
3223
}
33-
34-
@Injectable()
35-
export class SessionPipe implements PipeTransform {
36-
constructor(private readonly identity: Identity) {}
37-
38-
transform() {
39-
return this.identity.currentMaybe;
40-
}
41-
}
42-
43-
/** @deprecated */
44-
export const LoggedInSession = () => AnonSession();
45-
46-
/** @deprecated */
47-
export const AnonSession =
48-
(...pipes: Array<Type<PipeTransform> | PipeTransform>): ParameterDecorator =>
49-
(...args) => {
50-
Context(SessionPipe, ...pipes)(...args);
51-
process.nextTick(() => {
52-
// Only set this metadata if it's a controller method.
53-
// Waiting for the next tick as class decorators execute after methods.
54-
if (Reflect.getMetadata(CONTROLLER_WATERMARK, args[0].constructor)) {
55-
Param(SessionPipe, ...pipes)(...args);
56-
SessionWatermark(...args);
57-
}
58-
});
59-
};
60-
61-
const SessionWatermark: ParameterDecorator = (target, key) =>
62-
Reflect.defineMetadata('SESSION_WATERMARK', true, target.constructor, key!);

src/components/authentication/authentication.module.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { forwardRef, Global, Module } from '@nestjs/common';
22
import { APP_INTERCEPTOR } from '@nestjs/core';
3-
import { SessionPipe } from '~/common/session';
43
import { splitDb } from '~/core';
54
import { Identity } from '~/core/authentication';
65
import { AuthorizationModule } from '../authorization/authorization.module';
@@ -43,7 +42,6 @@ import { SessionResolver } from './session.resolver';
4342
SessionInterceptor,
4443
{ provide: APP_INTERCEPTOR, useExisting: SessionInterceptor },
4544
{ provide: SessionHost, useClass: SessionHostImpl },
46-
SessionPipe,
4745
],
4846
exports: [
4947
Identity,

0 commit comments

Comments
 (0)