some tweaks, split redis from session
This commit is contained in:
parent
b62208ba47
commit
2305b97364
@ -4,7 +4,7 @@ import { Controller, Get, Redirect } from '@nestjs/common';
|
||||
export class AppController {
|
||||
@Get()
|
||||
@Redirect('/account/general')
|
||||
getHello() {
|
||||
trueURLRedirect() {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,4 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
|
||||
@Injectable()
|
||||
export class AppService {
|
||||
getHello(): string {
|
||||
return 'Hello World!';
|
||||
}
|
||||
}
|
||||
export class AppService {}
|
||||
|
@ -32,7 +32,7 @@ export class AuditAdminController {
|
||||
@Get('')
|
||||
@Scopes('management')
|
||||
@Privileges('admin', 'admin:audit')
|
||||
async userList(@Query() search: AuditSearchClause & PageOptions) {
|
||||
async auditList(@Query() search: AuditSearchClause & PageOptions) {
|
||||
const resultCount = await this._audit.searchForAuditCount(search);
|
||||
|
||||
const pagination = this._paginate.paginate(search, resultCount);
|
||||
|
10
src/modules/redis/redis.module.ts
Normal file
10
src/modules/redis/redis.module.ts
Normal file
@ -0,0 +1,10 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { ConfigurationModule } from '../config/config.module';
|
||||
import { redisProviders } from './redis.providers';
|
||||
|
||||
@Module({
|
||||
imports: [ConfigurationModule],
|
||||
providers: [...redisProviders],
|
||||
exports: [...redisProviders],
|
||||
})
|
||||
export class RedisModule {}
|
25
src/modules/redis/redis.providers.ts
Normal file
25
src/modules/redis/redis.providers.ts
Normal file
@ -0,0 +1,25 @@
|
||||
import { FactoryProvider } from '@nestjs/common';
|
||||
import { ConfigurationService } from '../config/config.service';
|
||||
import * as redis from 'redis';
|
||||
|
||||
export type Redis = ReturnType<typeof redis.createClient>;
|
||||
|
||||
export const redisProviders = [
|
||||
{
|
||||
provide: 'REDIS_CLIENT',
|
||||
useFactory: async (config: ConfigurationService): Promise<Redis> => {
|
||||
const redisClient = redis.createClient({
|
||||
url:
|
||||
process.env.REDIS_URL ||
|
||||
config.get<string>('app.redis_url') ||
|
||||
'redis://localhost:6379',
|
||||
legacyMode: true,
|
||||
});
|
||||
|
||||
await redisClient.connect();
|
||||
|
||||
return redisClient;
|
||||
},
|
||||
inject: [ConfigurationService],
|
||||
} as FactoryProvider<Redis>,
|
||||
];
|
@ -1,10 +1,11 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { ConfigurationModule } from 'src/modules/config/config.module';
|
||||
import { RedisModule } from 'src/modules/redis/redis.module';
|
||||
import { sessionProviders } from './session.providers';
|
||||
|
||||
@Module({
|
||||
providers: [...sessionProviders],
|
||||
exports: [...sessionProviders],
|
||||
imports: [ConfigurationModule],
|
||||
imports: [ConfigurationModule, RedisModule],
|
||||
})
|
||||
export class SessionModule {}
|
||||
|
@ -3,29 +3,17 @@ import { ConfigurationService } from 'src/modules/config/config.service';
|
||||
|
||||
import * as session from 'express-session';
|
||||
import * as connectRedis from 'connect-redis';
|
||||
import * as redis from 'redis';
|
||||
import { RequestHandler } from 'express';
|
||||
import type { RequestHandler } from 'express';
|
||||
import type { Redis } from 'src/modules/redis/redis.providers';
|
||||
|
||||
const RedisStore = connectRedis(session);
|
||||
|
||||
export const sessionProviders = [
|
||||
{
|
||||
provide: 'SESSION_STORE',
|
||||
useFactory: async (
|
||||
config: ConfigurationService,
|
||||
): Promise<connectRedis.RedisStore> => {
|
||||
const RedisStore = connectRedis(session);
|
||||
const redisClient = redis.createClient({
|
||||
url:
|
||||
process.env.REDIS_URL ||
|
||||
config.get<string>('app.redis_url') ||
|
||||
'redis://localhost:6379',
|
||||
legacyMode: true,
|
||||
});
|
||||
|
||||
await redisClient.connect();
|
||||
|
||||
return new RedisStore({ client: redisClient });
|
||||
},
|
||||
inject: [ConfigurationService],
|
||||
useFactory: async (redis: Redis): Promise<connectRedis.RedisStore> =>
|
||||
new RedisStore({ client: redis }),
|
||||
inject: ['REDIS_CLIENT'],
|
||||
} as FactoryProvider<connectRedis.RedisStore>,
|
||||
{
|
||||
provide: 'SESSION',
|
||||
|
@ -39,7 +39,9 @@ Contact: mailto:evert@lunasqu.ee
|
||||
userinfo_endpoint: `${base}/api/user`,
|
||||
introspection_endpoint: `${base}/oauth2/introspect`,
|
||||
response_types_supported: ['code', 'id_token'],
|
||||
id_token_signing_alg_values_supported: [this.config.get('jwt.algorithm')],
|
||||
id_token_signing_alg_values_supported: [
|
||||
this.config.get<string>('jwt.algorithm'),
|
||||
],
|
||||
subject_types_supported: ['public'],
|
||||
scopes_supported: ['openid', 'profile', 'picture', 'email'],
|
||||
claims_supported: [
|
||||
@ -51,7 +53,6 @@ Contact: mailto:evert@lunasqu.ee
|
||||
'name',
|
||||
'preferred_username',
|
||||
'nickname',
|
||||
'profile',
|
||||
'picture',
|
||||
'updated_at',
|
||||
'email',
|
||||
|
Reference in New Issue
Block a user