feat: 使用 @nestjs-lib/auth 鉴权。
This commit is contained in:
@@ -19,7 +19,7 @@ import { ParseBodyMiddleware } from './commons/middleware/parse-body.middleware'
|
||||
import { LoggerModule } from 'nestjs-pino';
|
||||
import { EtcdModule } from 'nestjs-etcd';
|
||||
import pinoPretty from 'pino-pretty';
|
||||
import { AccountMiddleware } from './commons/middleware/account.middleware';
|
||||
import { fromPairs, map, pipe, toPairs } from 'ramda';
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
@@ -64,6 +64,22 @@ import { AccountMiddleware } from './commons/middleware/account.middleware';
|
||||
playground: true,
|
||||
autoSchemaFile: true,
|
||||
installSubscriptionHandlers: true,
|
||||
context: ({ req, connection, ...args }) => {
|
||||
return connection ? { req: connection.context } : { req };
|
||||
},
|
||||
subscriptions: {
|
||||
onConnect: (connectionParams: Record<string, string>) => {
|
||||
const connectionParamsWithLowerKeys = pipe(
|
||||
toPairs,
|
||||
map(([key, value]) => [key.toLowerCase(), value]),
|
||||
fromPairs,
|
||||
)(connectionParams);
|
||||
|
||||
return {
|
||||
headers: connectionParamsWithLowerKeys,
|
||||
};
|
||||
},
|
||||
},
|
||||
}),
|
||||
inject: [ConfigService],
|
||||
}),
|
||||
@@ -100,8 +116,6 @@ export class AppModule implements NestModule {
|
||||
.apply(RawBodyMiddleware)
|
||||
.forRoutes(GiteaWebhooksController)
|
||||
.apply(ParseBodyMiddleware)
|
||||
.forRoutes('*')
|
||||
.apply(AccountMiddleware)
|
||||
.forRoutes('*');
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user