- Express server with CORS, JSON middleware - Auth middleware (Bearer token) - Document CRUD with markdown storage - Library CRUD with nested support - Tag indexing and search - Error handler middleware - Config from env vars - Init script for data structure
28 lines
822 B
JavaScript
28 lines
822 B
JavaScript
/**
|
|
* SimpleNote Web - Configuration
|
|
* Environment variables loader with defaults
|
|
*/
|
|
|
|
import dotenv from 'dotenv';
|
|
import { fileURLToPath } from 'url';
|
|
import { dirname, join, resolve } from 'path';
|
|
import { existsSync } from 'fs';
|
|
|
|
dotenv.config();
|
|
|
|
const __filename = fileURLToPath(import.meta.url);
|
|
const __dirname = dirname(__filename);
|
|
const projectRoot = resolve(__dirname, '../..');
|
|
|
|
export const config = {
|
|
port: parseInt(process.env.PORT || '3000', 10),
|
|
host: process.env.HOST || '0.0.0.0',
|
|
dataRoot: resolve(projectRoot, process.env.DATA_ROOT || './data'),
|
|
adminToken: process.env.ADMIN_TOKEN || 'snk_initial_admin_token_change_me',
|
|
logLevel: process.env.LOG_LEVEL || 'info',
|
|
corsOrigin: process.env.CORS_ORIGIN || '*',
|
|
apiPrefix: process.env.API_PREFIX || '/api/v1',
|
|
};
|
|
|
|
export default config;
|