mirror of
https://github.com/codex-team/codex.docs.git
synced 2025-07-19 21:29:41 +02:00
🤩MongoDB support 🤩 (#272)
* implement configuration through YAML * remove rcparser * use password from appConfig * update docker configs * fix dockerignore * implement mongodb driver * update eslint packages * fix bugs * refactor code for grouping by parent * fix yet another bug * use unique symbol to the EntityId type * fix more bugs * implement db converter * fix bug with parent selector * fix eslint * db-converter refactoring * create cli program for db-converter * add readme and gitignore * update development docs * update development docs and default config * add docs about converter * add src/test to docker ignore * move database code from utils * improve docs * eslint fix * add more docs * fix docs * remove env_file from docker-compose * implement duplicate detection in db-converter * use published version of the config-loader * fix bug * Update DEVELOPMENT.md Co-authored-by: Ilya Maroz <37909603+ilyamore88@users.noreply.github.com> * fix bugs * fix next/prev buttons * fix more bugs * fix sorting Co-authored-by: Ilya Maroz <37909603+ilyamore88@users.noreply.github.com>
This commit is contained in:
parent
13762096c4
commit
55b4b3ee61
72 changed files with 12614 additions and 665 deletions
|
@ -1,8 +1,8 @@
|
|||
import { loadConfig } from 'config-loader';
|
||||
import { loadConfig } from '@codex-team/config-loader';
|
||||
import * as process from 'process';
|
||||
import arg from 'arg';
|
||||
import path from 'path';
|
||||
import { z } from "zod";
|
||||
import { z } from 'zod';
|
||||
|
||||
/**
|
||||
* Configuration for Hawk errors catcher
|
||||
|
@ -10,19 +10,38 @@ import { z } from "zod";
|
|||
const HawkConfig = z.object({
|
||||
backendToken: z.string().optional(), // Hawk backend token
|
||||
frontendToken: z.string().optional(), // Hawk frontend token
|
||||
})
|
||||
});
|
||||
|
||||
/**
|
||||
* Config for local database driver
|
||||
*/
|
||||
const LocalDatabaseConfig = z.object({
|
||||
driver: z.literal('local'),
|
||||
local: z.object({
|
||||
path: z.string()
|
||||
})
|
||||
})
|
||||
path: z.string(), // path to the database directory
|
||||
}),
|
||||
});
|
||||
|
||||
/**
|
||||
* Config for MongoDB database driver
|
||||
*/
|
||||
const MongoDatabaseConfig = z.object({
|
||||
driver: z.literal('mongodb'),
|
||||
mongodb: z.object({
|
||||
uri: z.string(), // MongoDB connection URI
|
||||
}),
|
||||
});
|
||||
|
||||
/**
|
||||
* Config for authentication
|
||||
*/
|
||||
const AuthConfig = z.object({
|
||||
secret: z.string() // Secret for JWT
|
||||
})
|
||||
secret: z.string(), // Secret for JWT
|
||||
});
|
||||
|
||||
/**
|
||||
* Frontend configuration
|
||||
*/
|
||||
const FrontendConfig = z.object({
|
||||
title: z.string(), // Title for pages
|
||||
description: z.string(), // Description for pages
|
||||
|
@ -33,8 +52,9 @@ const FrontendConfig = z.object({
|
|||
serve: z.string().optional(), // Carbon serve url
|
||||
placement: z.string().optional(), // Carbon placement
|
||||
}),
|
||||
menu: z.array(z.union([z.string(), z.object({title: z.string(), uri: z.string()})])), // Menu for pages
|
||||
})
|
||||
menu: z.array(z.union([z.string(), z.object({ title: z.string(),
|
||||
uri: z.string() })])), // Menu for pages
|
||||
});
|
||||
|
||||
/**
|
||||
* Application configuration
|
||||
|
@ -48,8 +68,8 @@ const AppConfig = z.object({
|
|||
password: z.string(), // Password for admin panel
|
||||
frontend: FrontendConfig, // Frontend configuration
|
||||
auth: AuthConfig, // Auth configuration
|
||||
database: LocalDatabaseConfig, // Database configuration
|
||||
})
|
||||
database: z.union([LocalDatabaseConfig, MongoDatabaseConfig]), // Database configuration
|
||||
});
|
||||
|
||||
export type AppConfig = z.infer<typeof AppConfig>;
|
||||
|
||||
|
@ -59,7 +79,7 @@ const args = arg({ /* eslint-disable @typescript-eslint/naming-convention */
|
|||
});
|
||||
|
||||
const cwd = process.cwd();
|
||||
const paths = (args['--config'] || ['./app-config.yaml']).map((configPath) => {
|
||||
const paths = (args['--config'] || [ './app-config.yaml' ]).map((configPath) => {
|
||||
if (path.isAbsolute(configPath)) {
|
||||
return configPath;
|
||||
}
|
||||
|
@ -69,6 +89,6 @@ const paths = (args['--config'] || ['./app-config.yaml']).map((configPath) => {
|
|||
|
||||
const loadedConfig = loadConfig<AppConfig>(...paths);
|
||||
|
||||
const appConfig = AppConfig.parse(loadedConfig)
|
||||
const appConfig = AppConfig.parse(loadedConfig);
|
||||
|
||||
export default appConfig;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue