@diagramers/api
Version:
Diagramers API - A comprehensive Node.js API template with TypeScript, Firebase Functions, and Socket.io
188 lines (175 loc) • 3.66 kB
text/typescript
export interface DatabaseConfig {
host: string;
port: number;
username: string;
password: string;
database: string;
dialect: 'mysql' | 'postgres' | 'sqlite' | 'mariadb' | 'mongodb';
logging: boolean;
pool?: {
max: number;
min: number;
acquire: number;
idle: number;
};
// MongoDB specific options
mongodb?: {
useNewUrlParser?: boolean;
useUnifiedTopology?: boolean;
retryWrites?: boolean;
w?: string | number;
readPreference?: string;
maxPoolSize?: number;
minPoolSize?: number;
maxIdleTimeMS?: number;
serverSelectionTimeoutMS?: number;
socketTimeoutMS?: number;
connectTimeoutMS?: number;
};
}
export interface AuthConfig {
jwtSecret: string;
jwtExpiresIn: string;
refreshTokenExpiresIn: string;
providers: {
internal: boolean;
firebase: FirebaseAuthConfig;
oauth: OAuthConfig;
sms: SMSAuthConfig;
email: EmailAuthConfig;
};
}
export interface FirebaseAuthConfig {
enabled: boolean;
projectId: string;
privateKeyId: string;
privateKey: string;
clientEmail: string;
clientId: string;
authUri: string;
tokenUri: string;
authProviderX509CertUrl: string;
clientX509CertUrl: string;
}
export interface OAuthConfig {
enabled: boolean;
providers: {
google: OAuthProviderConfig;
github: OAuthProviderConfig;
facebook: OAuthProviderConfig;
};
}
export interface OAuthProviderConfig {
enabled: boolean;
clientId: string;
clientSecret: string;
callbackUrl: string;
scope: string[];
}
export interface SMSAuthConfig {
enabled: boolean;
provider: 'twilio' | 'aws-sns' | 'custom';
twilio?: {
accountSid: string;
authToken: string;
fromNumber: string;
};
aws?: {
accessKeyId: string;
secretAccessKey: string;
region: string;
};
custom?: {
endpoint: string;
apiKey: string;
};
}
export interface EmailAuthConfig {
enabled: boolean;
provider: 'nodemailer' | 'sendgrid' | 'aws-ses' | 'custom';
nodemailer?: {
host: string;
port: number;
secure: boolean;
auth: {
user: string;
pass: string;
};
};
sendgrid?: {
apiKey: string;
};
aws?: {
accessKeyId: string;
secretAccessKey: string;
region: string;
};
custom?: {
endpoint: string;
apiKey: string;
};
}
export interface NotificationConfig {
email: EmailConfig;
sms: SMSConfig;
push: PushConfig;
}
export interface EmailConfig {
enabled: boolean;
provider: 'nodemailer' | 'sendgrid' | 'aws-ses';
templates: {
path: string;
engine: 'handlebars' | 'ejs' | 'pug';
};
defaults: {
from: string;
replyTo: string;
};
}
export interface SMSConfig {
enabled: boolean;
provider: 'twilio' | 'aws-sns' | 'custom';
defaults: {
from: string;
};
}
export interface PushConfig {
enabled: boolean;
provider: 'firebase' | 'aws-sns' | 'custom';
}
export interface PluginConfig {
name: string;
version: string;
enabled: boolean;
config: Record<string, any>;
}
export interface AppConfig {
environment: 'development' | 'staging' | 'production' | 'uat';
port: number;
host: string;
cors: {
origin: string | string[];
credentials: boolean;
};
database: DatabaseConfig;
auth: AuthConfig;
notifications: NotificationConfig;
plugins: PluginConfig[];
logging: {
level: 'error' | 'warn' | 'info' | 'debug';
file?: string;
};
security: {
rateLimit: {
windowMs: number;
max: number;
};
helmet: boolean;
compression: boolean;
};
}
export interface ConfigValidationResult {
isValid: boolean;
errors: string[];
warnings: string[];
}