-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Base authorization request evaluation flow
This commit encompasses significant groundwork to ensure everything functions correctly. Key highlights include: - Integration of BullMQ for managing queues using Redis. - Implementation of the initial database schema. I've opted to use JSON for the request, as it simplifies extending from the AuthZ node without modifying the Orchestration. This choice may affect searchability and is not final. - Inclusion of an example of an end-to-end test that involves the database and queue, complete with state cleaning during teardown. - Development of DTOs for the public interface, integrated with Swagger for documentation. - Refactor organization to reflect the modular monolith agreed on RFC 006 [1]. - Type gymnastics from domain to DTO is not great. The discrimination property for the request outside it is making things painful. [1] https://www.notion.so/narvalxyz/RFC-006-Moving-to-a-modular-monolith-f1ba845081e04b1790065cecc47dc5ba
- Loading branch information
1 parent
8477ae2
commit ffbf03a
Showing
40 changed files
with
1,604 additions
and
308 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
apps/documentation/docs/tutorial-basics/debugging-redis-with-redis-insight.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Debugging Redis with Redis Insight | ||
|
||
Redis Insight is a graphical user interface for Redis. It is available as a | ||
Docker image, and can be used to inspect the contents of your Redis database. | ||
|
||
```bash | ||
docker run -v redisinsight:/db \ | ||
--publish 8001:8001 \ | ||
redislabs/redisinsight:latest | ||
``` | ||
|
||
You can then access Redis Insight at http://localhost:8001. | ||
|
||
> [!IMPORTANT] | ||
> When adding a new connection, use the hostname of the host machine, not | ||
> `localhost`. | ||
> If you're on macOS, use `host.docker.internal`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,8 @@ | ||
NODE_ENV=development | ||
|
||
PORT=3005 | ||
|
||
ORCHESTRATION_DATABASE_URL="postgresql://postgres:postgres@localhost:5432/orchestration?schema=public" | ||
|
||
REDIS_HOST=localhost | ||
REDIS_PORT=6379 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,40 @@ | ||
import { z } from 'zod' | ||
|
||
const ConfigSchema = z.object({ | ||
export enum Env { | ||
DEVELOPMENT = 'development', | ||
TEST = 'test' | ||
} | ||
|
||
const configSchema = z.object({ | ||
env: z.nativeEnum(Env), | ||
port: z.coerce.number(), | ||
database: z.object({ | ||
url: z.string().startsWith('postgresql://') | ||
}), | ||
redis: z.object({ | ||
host: z.string().min(0), | ||
port: z.coerce.number() | ||
}) | ||
}) | ||
|
||
export type Config = z.infer<typeof ConfigSchema> | ||
export type Config = z.infer<typeof configSchema> | ||
|
||
export const load = (): Config => { | ||
const result = ConfigSchema.safeParse({ | ||
const result = configSchema.safeParse({ | ||
env: process.env.NODE_ENV, | ||
port: process.env.PORT, | ||
database: { | ||
url: process.env.ORCHESTRATION_DATABASE_URL | ||
}, | ||
redis: { | ||
host: process.env.REDIS_HOST, | ||
port: process.env.REDIS_PORT | ||
} | ||
}) | ||
|
||
if (result.success) { | ||
return result.data | ||
} | ||
|
||
throw new Error(`Invalid application configuration: ${result.error.message}`) | ||
throw new Error(`Invalid Orchestration configuration: ${result.error.message}`) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export const QUEUE_PREFIX = 'orchestration' | ||
export const AUTHORIZATION_REQUEST_PROCESSING_QUEUE = 'authorization-request:processing' | ||
|
||
export const REQUEST_HEADER_ORG_ID = 'x-org-id' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
import { PolicyEngineModule } from '@app/orchestration/policy-engine/policy-engine.module' | ||
import { TransactionEngineModule } from '@narval/transaction-engine-module' | ||
import { Module } from '@nestjs/common' | ||
import { ConfigModule } from '@nestjs/config' | ||
import { load } from './orchestration.config' | ||
import { QueueModule } from './shared/module/queue/queue.module' | ||
|
||
@Module({ | ||
imports: [ | ||
ConfigModule.forRoot({ | ||
load: [load], | ||
isGlobal: true | ||
}), | ||
PolicyEngineModule, | ||
TransactionEngineModule | ||
QueueModule.forRoot(), | ||
PolicyEngineModule | ||
] | ||
}) | ||
export class OrchestrationModule {} |
This file was deleted.
Oops, something went wrong.
11 changes: 0 additions & 11 deletions
11
apps/orchestration/src/persistence/schema/migrations/20240103105012_init/migration.sql
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.