Refactor Dockerfile to enhance mock API structure by consolidating and expanding mock database and API files. Updated mock implementations for auth, scripts, ratings, analytics, collections, and users to include additional functionalities and improve overall API consistency for frontend-only builds.
This commit is contained in:
67
Dockerfile
67
Dockerfile
@ -31,60 +31,31 @@ RUN rm -rf src/lib/db || true
|
|||||||
|
|
||||||
# Create mock API layer for frontend demo
|
# Create mock API layer for frontend demo
|
||||||
RUN mkdir -p src/lib/api src/lib/db
|
RUN mkdir -p src/lib/api src/lib/db
|
||||||
RUN echo "export const db = {}; export * from './mock';" > src/lib/db/index.ts
|
|
||||||
RUN echo "export const users = {}; export const scripts = {};" > src/lib/db/schema.ts
|
|
||||||
RUN echo "export * from './mock';" > src/lib/api/index.ts
|
|
||||||
|
|
||||||
# Create mock API files
|
# Create mock database files
|
||||||
RUN cat > src/lib/api/auth.ts << 'EOF'
|
RUN echo "export const db = {};" > src/lib/db/index.ts
|
||||||
export const authApi = {
|
RUN echo "export const users = {}; export const scripts = {}; export const ratings = {}; export const scriptVersions = {}; export const scriptAnalytics = {}; export const scriptCollections = {}; export const collectionScripts = {};" > src/lib/db/schema.ts
|
||||||
login: async () => ({ token: 'demo', user: { id: '1', username: 'demo' } }),
|
|
||||||
register: async () => ({ token: 'demo', user: { id: '1', username: 'demo' } }),
|
|
||||||
};
|
|
||||||
EOF
|
|
||||||
|
|
||||||
RUN cat > src/lib/api/scripts.ts << 'EOF'
|
# Create mock API index
|
||||||
export const scriptsApi = {
|
RUN echo "export const generateId = () => 'mock-id'; export class ApiError extends Error { constructor(message, status) { super(message); this.status = status; } }" > src/lib/api/index.ts
|
||||||
getScripts: async () => ({ scripts: [], total: 0 }),
|
|
||||||
getScript: async () => null,
|
|
||||||
createScript: async () => ({}),
|
|
||||||
updateScript: async () => ({}),
|
|
||||||
deleteScript: async () => ({}),
|
|
||||||
moderateScript: async () => ({}),
|
|
||||||
};
|
|
||||||
EOF
|
|
||||||
|
|
||||||
RUN cat > src/lib/api/ratings.ts << 'EOF'
|
# Create mock auth API
|
||||||
export const ratingsApi = {
|
RUN echo "export const authApi = { login: async () => ({ token: 'demo', user: { id: '1', username: 'demo' } }), register: async () => ({ token: 'demo', user: { id: '1', username: 'demo' } }), changePassword: async () => ({}), refreshToken: async () => ({ token: 'demo' }) };" > src/lib/api/auth.ts
|
||||||
submitRating: async () => ({}),
|
|
||||||
getUserRating: async () => null,
|
|
||||||
getScriptRatingStats: async () => ({ averageRating: 0, totalRatings: 0 }),
|
|
||||||
};
|
|
||||||
EOF
|
|
||||||
|
|
||||||
RUN cat > src/lib/api/analytics.ts << 'EOF'
|
# Create mock scripts API
|
||||||
export const analyticsApi = {
|
RUN echo "export const scriptsApi = { getScripts: async () => ({ scripts: [], total: 0 }), getScript: async () => null, createScript: async () => ({}), updateScript: async () => ({}), deleteScript: async () => ({}), moderateScript: async () => ({}) };" > src/lib/api/scripts.ts
|
||||||
trackEvent: async () => ({}),
|
|
||||||
getAnalytics: async () => ({ views: [], downloads: [] }),
|
|
||||||
};
|
|
||||||
EOF
|
|
||||||
|
|
||||||
RUN cat > src/lib/api/collections.ts << 'EOF'
|
# Create mock ratings API
|
||||||
export const collectionsApi = {
|
RUN echo "export const ratingsApi = { submitRating: async () => ({}), getUserRating: async () => null, getScriptRatingStats: async () => ({ averageRating: 0, totalRatings: 0, distribution: {} }) };" > src/lib/api/ratings.ts
|
||||||
getCollections: async () => [],
|
|
||||||
createCollection: async () => ({}),
|
|
||||||
updateCollection: async () => ({}),
|
|
||||||
deleteCollection: async () => ({}),
|
|
||||||
};
|
|
||||||
EOF
|
|
||||||
|
|
||||||
RUN cat > src/lib/api/users.ts << 'EOF'
|
# Create mock analytics API
|
||||||
export const usersApi = {
|
RUN echo "export const analyticsApi = { trackEvent: async () => ({}), getAnalytics: async () => ({ views: [], downloads: [], topScripts: [], userGrowth: [] }) };" > src/lib/api/analytics.ts
|
||||||
getUser: async () => null,
|
|
||||||
updateUser: async () => ({}),
|
# Create mock collections API
|
||||||
updateUserPermissions: async () => ({}),
|
RUN echo "export const collectionsApi = { getCollections: async () => [], createCollection: async () => ({}), updateCollection: async () => ({}), deleteCollection: async () => ({}), addScriptToCollection: async () => ({}), removeScriptFromCollection: async () => ({}) };" > src/lib/api/collections.ts
|
||||||
};
|
|
||||||
EOF
|
# Create mock users API
|
||||||
|
RUN echo "export const usersApi = { getUser: async () => null, updateUser: async () => ({}), updateUserPermissions: async () => ({}), getAllUsers: async () => ([]), searchUsers: async () => ([]) };" > src/lib/api/users.ts
|
||||||
|
|
||||||
# Build the application (frontend only with mocks)
|
# Build the application (frontend only with mocks)
|
||||||
RUN npm run build
|
RUN npm run build
|
||||||
|
Reference in New Issue
Block a user