diff --git a/package-lock.json b/package-lock.json index 69e8aae..765e2b9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8319,16 +8319,16 @@ } }, "node_modules/react-syntax-highlighter": { - "version": "15.6.1", - "resolved": "https://registry.npmjs.org/react-syntax-highlighter/-/react-syntax-highlighter-15.6.1.tgz", - "integrity": "sha512-OqJ2/vL7lEeV5zTJyG7kmARppUjiB9h9udl4qHQjjgEos66z00Ia0OckwYfRxCSFrW8RJIBnsBwQsHZbVPspqg==", + "version": "15.6.3", + "resolved": "https://registry.npmjs.org/react-syntax-highlighter/-/react-syntax-highlighter-15.6.3.tgz", + "integrity": "sha512-HebdyA9r20hgmA0q8RyRJ4c/vB4E6KL2HeWb5MNjU3iJEiT2w9jfU2RJsmI6f3Cy3SGE5tm0AIkBzM/E7e9/lQ==", "license": "MIT", "dependencies": { "@babel/runtime": "^7.3.1", "highlight.js": "^10.4.1", "highlightjs-vue": "^1.0.0", "lowlight": "^1.17.0", - "prismjs": "^1.27.0", + "prismjs": "^1.30.0", "refractor": "^3.6.0" }, "peerDependencies": { diff --git a/src/hooks/useScripts.ts b/src/hooks/useScripts.ts index b8cd0a3..5ab58c3 100644 --- a/src/hooks/useScripts.ts +++ b/src/hooks/useScripts.ts @@ -56,7 +56,7 @@ export function useCreateScript() { return useMutation({ mutationFn: ({ data, userId }: { data: scriptsApi.CreateScriptData; userId: string }) => - scriptsApi.createScript(data, userId), + scriptsApi.createScript({...data, authorId: userId, authorName: data.authorName || 'User'}, userId), onSuccess: () => { queryClient.invalidateQueries({ queryKey: scriptKeys.lists() }); showSuccess('Script created successfully!'); diff --git a/src/lib/api/scripts.ts b/src/lib/api/scripts.ts index f4c3ded..f4a5648 100644 --- a/src/lib/api/scripts.ts +++ b/src/lib/api/scripts.ts @@ -39,7 +39,7 @@ export interface ScriptFilters { } // Create a new script -export async function createScript(data: CreateScriptData) { +export async function createScript(data: CreateScriptData, userId?: string) { try { const scriptId = generateId(); const now = new Date(); diff --git a/src/server.ts b/src/server.ts index c021afb..a8b6170 100644 --- a/src/server.ts +++ b/src/server.ts @@ -74,7 +74,12 @@ app.post('/api/scripts', async (req: Request, res: Response) => { if (!userId) { return res.status(401).json({ error: 'Unauthorized' }); } - const result = await createScript(req.body, userId); + // Make sure userId is included in the request body + const scriptData = { + ...req.body, + authorId: userId + }; + const result = await createScript(scriptData, userId); res.json(result); } catch (error) { console.error('Create script error:', error); diff --git a/tsconfig.json b/tsconfig.json index f6b9fb2..7d2efef 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -15,10 +15,10 @@ "jsx": "react-jsx", /* Linting */ - "strict": false, - "noImplicitAny": false, - "noUnusedLocals": false, - "noUnusedParameters": false, + "strict": true, + "noImplicitAny": true, + "noUnusedLocals": true, + "noUnusedParameters": true, "noFallthroughCasesInSwitch": true, /* Path mapping */