/** * API Versioning Utility * Provides API version information and management */ const { config } = require('../config/env.config'); const API_VERSION = { currentVersion: 'v1', supportedVersions: ['v1'], deprecatedVersions: [], apiPrefix: '/api', }; /** * Get API version information */ const getApiInfo = () => { return { currentVersion: API_VERSION.currentVersion, supportedVersions: API_VERSION.supportedVersions, deprecatedVersions: API_VERSION.deprecatedVersions, environment: config.nodeEnv, documentation: `${config.server.publicUrl}/api/docs`, }; }; /** * Check if API version is supported */ const isVersionSupported = (version) => { return API_VERSION.supportedVersions.includes(version); }; /** * Check if API version is deprecated */ const isVersionDeprecated = (version) => { return API_VERSION.deprecatedVersions.includes(version); }; /** * Get versioned route path */ const getVersionedPath = (path, version = API_VERSION.currentVersion) => { return `${API_VERSION.apiPrefix}/${version}${path}`; }; module.exports = { API_VERSION, getApiInfo, isVersionSupported, isVersionDeprecated, getVersionedPath, };