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 {
|
export class AppController {
|
||||||
@Get()
|
@Get()
|
||||||
@Redirect('/account/general')
|
@Redirect('/account/general')
|
||||||
getHello() {
|
trueURLRedirect() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,4 @@
|
|||||||
import { Injectable } from '@nestjs/common';
|
import { Injectable } from '@nestjs/common';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class AppService {
|
export class AppService {}
|
||||||
getHello(): string {
|
|
||||||
return 'Hello World!';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -32,7 +32,7 @@ export class AuditAdminController {
|
|||||||
@Get('')
|
@Get('')
|
||||||
@Scopes('management')
|
@Scopes('management')
|
||||||
@Privileges('admin', 'admin:audit')
|
@Privileges('admin', 'admin:audit')
|
||||||
async userList(@Query() search: AuditSearchClause & PageOptions) {
|
async auditList(@Query() search: AuditSearchClause & PageOptions) {
|
||||||
const resultCount = await this._audit.searchForAuditCount(search);
|
const resultCount = await this._audit.searchForAuditCount(search);
|
||||||
|
|
||||||
const pagination = this._paginate.paginate(search, resultCount);
|
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 { Module } from '@nestjs/common';
|
||||||
import { ConfigurationModule } from 'src/modules/config/config.module';
|
import { ConfigurationModule } from 'src/modules/config/config.module';
|
||||||
|
import { RedisModule } from 'src/modules/redis/redis.module';
|
||||||
import { sessionProviders } from './session.providers';
|
import { sessionProviders } from './session.providers';
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
providers: [...sessionProviders],
|
providers: [...sessionProviders],
|
||||||
exports: [...sessionProviders],
|
exports: [...sessionProviders],
|
||||||
imports: [ConfigurationModule],
|
imports: [ConfigurationModule, RedisModule],
|
||||||
})
|
})
|
||||||
export class SessionModule {}
|
export class SessionModule {}
|
||||||
|
@ -3,29 +3,17 @@ import { ConfigurationService } from 'src/modules/config/config.service';
|
|||||||
|
|
||||||
import * as session from 'express-session';
|
import * as session from 'express-session';
|
||||||
import * as connectRedis from 'connect-redis';
|
import * as connectRedis from 'connect-redis';
|
||||||
import * as redis from 'redis';
|
import type { RequestHandler } from 'express';
|
||||||
import { RequestHandler } from 'express';
|
import type { Redis } from 'src/modules/redis/redis.providers';
|
||||||
|
|
||||||
|
const RedisStore = connectRedis(session);
|
||||||
|
|
||||||
export const sessionProviders = [
|
export const sessionProviders = [
|
||||||
{
|
{
|
||||||
provide: 'SESSION_STORE',
|
provide: 'SESSION_STORE',
|
||||||
useFactory: async (
|
useFactory: async (redis: Redis): Promise<connectRedis.RedisStore> =>
|
||||||
config: ConfigurationService,
|
new RedisStore({ client: redis }),
|
||||||
): Promise<connectRedis.RedisStore> => {
|
inject: ['REDIS_CLIENT'],
|
||||||
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],
|
|
||||||
} as FactoryProvider<connectRedis.RedisStore>,
|
} as FactoryProvider<connectRedis.RedisStore>,
|
||||||
{
|
{
|
||||||
provide: 'SESSION',
|
provide: 'SESSION',
|
||||||
|
@ -39,7 +39,9 @@ Contact: mailto:evert@lunasqu.ee
|
|||||||
userinfo_endpoint: `${base}/api/user`,
|
userinfo_endpoint: `${base}/api/user`,
|
||||||
introspection_endpoint: `${base}/oauth2/introspect`,
|
introspection_endpoint: `${base}/oauth2/introspect`,
|
||||||
response_types_supported: ['code', 'id_token'],
|
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'],
|
subject_types_supported: ['public'],
|
||||||
scopes_supported: ['openid', 'profile', 'picture', 'email'],
|
scopes_supported: ['openid', 'profile', 'picture', 'email'],
|
||||||
claims_supported: [
|
claims_supported: [
|
||||||
@ -51,7 +53,6 @@ Contact: mailto:evert@lunasqu.ee
|
|||||||
'name',
|
'name',
|
||||||
'preferred_username',
|
'preferred_username',
|
||||||
'nickname',
|
'nickname',
|
||||||
'profile',
|
|
||||||
'picture',
|
'picture',
|
||||||
'updated_at',
|
'updated_at',
|
||||||
'email',
|
'email',
|
||||||
|
Reference in New Issue
Block a user