fix: resolve TypeScript errors in editor routes and git service imports
This commit is contained in:
@@ -25,7 +25,8 @@ router.get("/tree/:repo", async (req, res) => {
|
||||
|
||||
router.get("/file/:repo/*path", async (req, res) => {
|
||||
try {
|
||||
const content = await readFile(req.params.repo, req.params.path);
|
||||
const filePath = Array.isArray(req.params.path) ? req.params.path.join("/") : req.params.path;
|
||||
const content = await readFile(req.params.repo, filePath);
|
||||
res.json({ content });
|
||||
} catch (err: unknown) {
|
||||
const message = err instanceof Error ? err.message : "Unknown error";
|
||||
@@ -35,7 +36,8 @@ router.get("/file/:repo/*path", async (req, res) => {
|
||||
|
||||
router.put("/file/:repo/*path", async (req, res) => {
|
||||
try {
|
||||
await writeFile(req.params.repo, req.params.path, req.body.content);
|
||||
const filePath = Array.isArray(req.params.path) ? req.params.path.join("/") : req.params.path;
|
||||
await writeFile(req.params.repo, filePath, req.body.content);
|
||||
res.json({ ok: true });
|
||||
} catch (err: unknown) {
|
||||
const message = err instanceof Error ? err.message : "Unknown error";
|
||||
@@ -45,7 +47,8 @@ router.put("/file/:repo/*path", async (req, res) => {
|
||||
|
||||
router.delete("/file/:repo/*path", async (req, res) => {
|
||||
try {
|
||||
await deleteFile(req.params.repo, req.params.path);
|
||||
const filePath = Array.isArray(req.params.path) ? req.params.path.join("/") : req.params.path;
|
||||
await deleteFile(req.params.repo, filePath);
|
||||
res.json({ ok: true });
|
||||
} catch (err: unknown) {
|
||||
const message = err instanceof Error ? err.message : "Unknown error";
|
||||
|
||||
@@ -143,7 +143,7 @@ router.get("/:repo/diff/*path", async (req, res) => {
|
||||
res.status(400).json({ error: `Unknown repo: ${repoName}` });
|
||||
return;
|
||||
}
|
||||
const filePath = req.params.path;
|
||||
const filePath = Array.isArray(req.params.path) ? req.params.path.join("/") : req.params.path;
|
||||
const repoPath = getRepoPath(repoName);
|
||||
const diff = await getDiff(repoPath, filePath);
|
||||
res.json({ diff });
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import simpleGit, { SimpleGit } from "simple-git";
|
||||
import { simpleGit, SimpleGit } from "simple-git";
|
||||
import fs from "fs/promises";
|
||||
import { REPOS, GIT_PROVIDER_URL, type RepoName } from "../config/repos.js";
|
||||
import { getRepoPath, readConfig } from "./workspace.service.js";
|
||||
|
||||
Reference in New Issue
Block a user