mirror of
https://github.com/diced/zipline.git
synced 2025-04-11 23:31:17 -05:00
refactor(config): move into directory
This commit is contained in:
parent
d21e48a1a3
commit
739974bef4
6 changed files with 13 additions and 12 deletions
|
@ -19,15 +19,16 @@ const { rm } = require('fs/promises');
|
|||
'src/server/index.ts',
|
||||
'src/server/server.ts',
|
||||
'src/server/util.ts',
|
||||
'src/server/validateConfig.ts',
|
||||
'src/lib/logger.ts',
|
||||
'src/lib/readConfig.ts',
|
||||
'src/lib/config.ts',
|
||||
'src/lib/config/Config.ts',
|
||||
'src/lib/config/readConfig.ts',
|
||||
'src/lib/config/validateConfig.ts',
|
||||
'src/lib/datasources/Datasource.ts',
|
||||
'src/lib/datasources/index.ts',
|
||||
'src/lib/datasources/Local.ts',
|
||||
'src/lib/datasources/S3.ts',
|
||||
'src/lib/datasource.ts',
|
||||
'src/lib/config.ts',
|
||||
],
|
||||
format: 'cjs',
|
||||
resolveExtensions: ['.ts', '.js'],
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import readConfig from './readConfig';
|
||||
import validateConfig from '../server/validateConfig';
|
||||
import readConfig from './config/readConfig';
|
||||
import validateConfig from './config/validateConfig';
|
||||
|
||||
if (!global.config) global.config = validateConfig(readConfig());
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import { existsSync, readFileSync } from 'fs';
|
||||
import { join } from 'path';
|
||||
import parse from '@iarna/toml/parse-string';
|
||||
import Logger from './logger';
|
||||
import { Config } from './types';
|
||||
import Logger from '../logger';
|
||||
import { Config } from './Config';
|
||||
|
||||
const e = (val, type, fn) => ({ val, type, fn });
|
||||
|
||||
|
@ -17,10 +17,10 @@ const envValues = [
|
|||
|
||||
e('DATASOURCE_TYPE', 'string', (c, v) => c.datasource.type = v),
|
||||
e('DATASOURCE_LOCAL_DIRECTORY', 'string', (c, v) => c.datasource.local.directory = v),
|
||||
e('DATASOURCE_S3_ACCESS_KEY_ID', 'string', (c, v) => c.datasource.s3.access_key_id = v ),
|
||||
e('DATASOURCE_S3_ACCESS_KEY_ID', 'string', (c, v) => c.datasource.s3.access_key_id = v),
|
||||
e('DATASOURCE_S3_SECRET_ACCESS_KEY', 'string', (c, v) => c.datasource.s3.secret_access_key = v),
|
||||
e('DATASOURCE_S3_ENDPOINT', 'string', (c, v) => c.datasource.s3.endpoint = v ?? null),
|
||||
e('DATASOURCE_S3_FORCE_S3_PATH', 'string', (c, v) => c.datasource.s3.force_s3_path = v ?? false),
|
||||
e('DATASOURCE_S3_FORCE_S3_PATH', 'boolean', (c, v) => c.datasource.s3.force_s3_path = v ?? false),
|
||||
e('DATASOURCE_S3_BUCKET', 'string', (c, v) => c.datasource.s3.bucket = v),
|
||||
|
||||
e('UPLOADER_ROUTE', 'string', (c, v) => c.uploader.route = v),
|
||||
|
@ -42,7 +42,7 @@ export default function readConfig(): Config {
|
|||
return tryReadEnv();
|
||||
} else {
|
||||
if (process.env.ZIPLINE_DOCKER_BUILD) return;
|
||||
|
||||
|
||||
Logger.get('config').info('reading config file');
|
||||
const str = readFileSync(join(process.cwd(), 'config.toml'), 'utf8');
|
||||
const parsed = parse(str);
|
|
@ -1,4 +1,4 @@
|
|||
import { Config } from 'lib/types';
|
||||
import { Config } from 'lib/config/Config';
|
||||
import { object, bool, string, number, boolean, array } from 'yup';
|
||||
|
||||
const validator = object({
|
|
@ -1,7 +1,7 @@
|
|||
import { Datasource } from './';
|
||||
import AWS from 'aws-sdk';
|
||||
import { Readable } from 'stream';
|
||||
import { ConfigS3Datasource } from 'lib/types';
|
||||
import { ConfigS3Datasource } from 'lib/config/Config';
|
||||
|
||||
export class S3 extends Datasource {
|
||||
public name: string = 'S3';
|
||||
|
|
Loading…
Add table
Reference in a new issue