sanket3280/code-execution
0
1/**2 * API Versioning Utility3 * Provides API version information and management4 */5 6const { config } = require('../config/env.config');7 8const API_VERSION = {9 currentVersion: 'v1',10 supportedVersions: ['v1'],11 deprecatedVersions: [],12 apiPrefix: '/api',13};14 15/**16 * Get API version information17 */18const getApiInfo = () => {19 return {20 currentVersion: API_VERSION.currentVersion,21 supportedVersions: API_VERSION.supportedVersions,22 deprecatedVersions: API_VERSION.deprecatedVersions,23 environment: config.nodeEnv,24 documentation: `${config.server.publicUrl}/api/docs`,25 };26};27 28/**29 * Check if API version is supported30 */31const isVersionSupported = (version) => {32 return API_VERSION.supportedVersions.includes(version);33};34 35/**36 * Check if API version is deprecated37 */38const isVersionDeprecated = (version) => {39 return API_VERSION.deprecatedVersions.includes(version);40};41 42/**43 * Get versioned route path44 */45const getVersionedPath = (path, version = API_VERSION.currentVersion) => {46 return `${API_VERSION.apiPrefix}/${version}${path}`;47};48 49module.exports = {50 API_VERSION,51 getApiInfo,52 isVersionSupported,53 isVersionDeprecated,54 getVersionedPath,55};56 