From 2964838d9b356e659880ef21d41693f59a92a599 Mon Sep 17 00:00:00 2001 From: Benjtalkshow Date: Thu, 7 Aug 2025 01:10:33 +0100 Subject: [PATCH 1/4] fix: run lint --- apps/backend/src/index.ts | 56 ++++++++++++++------------- apps/backend/src/utils/fileManager.ts | 48 +++++++++++------------ 2 files changed, 54 insertions(+), 50 deletions(-) diff --git a/apps/backend/src/index.ts b/apps/backend/src/index.ts index 3726eac..f9a6a04 100644 --- a/apps/backend/src/index.ts +++ b/apps/backend/src/index.ts @@ -4,30 +4,34 @@ import cors from 'cors'; const app = express(); -app.use(helmet({ - contentSecurityPolicy: { - directives: { - defaultSrc: ["'self'"], - styleSrc: ["'self'", "'unsafe-inline'"], - scriptSrc: ["'self'"], - imgSrc: ["'self'", "data:", "https:"], +app.use( + helmet({ + contentSecurityPolicy: { + directives: { + defaultSrc: ["'self'"], + styleSrc: ["'self'", "'unsafe-inline'"], + scriptSrc: ["'self'"], + imgSrc: ["'self'", 'data:', 'https:'], + }, }, - }, - crossOriginEmbedderPolicy: false, - hsts: { - maxAge: 31536000, - includeSubDomains: true, - preload: true - } -})); - -app.use(cors({ - origin: 'http://localhost:4200', - credentials: true, - methods: ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS'], - allowedHeaders: ['Content-Type', 'Authorization', 'Accept'], - optionsSuccessStatus: 200 -})); + crossOriginEmbedderPolicy: false, + hsts: { + maxAge: 31536000, + includeSubDomains: true, + preload: true, + }, + }) +); + +app.use( + cors({ + origin: 'http://localhost:4200', + credentials: true, + methods: ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS'], + allowedHeaders: ['Content-Type', 'Authorization', 'Accept'], + optionsSuccessStatus: 200, + }) +); app.use(express.json()); app.use(express.urlencoded({ extended: true })); @@ -39,18 +43,18 @@ app.get('/', (_, res) => app.use((err: Error, req: express.Request, res: express.Response, next: express.NextFunction) => { res.status(500).json({ error: 'Internal Server Error', - message: process.env.NODE_ENV === 'development' ? err.message : 'Something went wrong' + message: process.env.NODE_ENV === 'development' ? err.message : 'Something went wrong', }); }); app.use((req, res) => { res.status(404).json({ error: 'Not Found', - message: `Route ${req.originalUrl} not found` + message: `Route ${req.originalUrl} not found`, }); }); app.listen(3000, () => { console.log('Server on http://localhost:3000'); console.log('CORS restricted to http://localhost:4200'); -}); \ No newline at end of file +}); diff --git a/apps/backend/src/utils/fileManager.ts b/apps/backend/src/utils/fileManager.ts index 220dce9..7b003b1 100644 --- a/apps/backend/src/utils/fileManager.ts +++ b/apps/backend/src/utils/fileManager.ts @@ -16,10 +16,10 @@ soroban-sdk = "21.2.0" `; export const fileManager = { - async setupProject(): Promise { - const tempDir = path.join(__dirname, '../../temp', `project_${Date.now()}`); + async setupProject(): Promise { + const tempDir = path.join(__dirname, '../../temp', `project_${Date.now()}`); - const rustCode = `#![no_std] + const rustCode = `#![no_std] use soroban_sdk::{contractimpl, Env}; pub struct Contract; @@ -31,27 +31,27 @@ impl Contract { } }`; - try { - await fs.mkdir(tempDir, { recursive: true }); - const srcDir = path.join(tempDir, 'src'); - await fs.mkdir(srcDir); - await fs.writeFile(path.join(tempDir, 'Cargo.toml'), DEFAULT_CARGO_TOML); - await fs.writeFile(path.join(srcDir, 'lib.rs'), rustCode); - return tempDir; - } catch (error) { - throw new Error(`Setup failed: ${error instanceof Error ? error.message : String(error)}`); - } - }, - - async cleanupProject(projectPath?: string): Promise { - const tempDir = projectPath || path.join(__dirname, '../../temp'); - - try { - await fs.rm(tempDir, { recursive: true, force: true }); - } catch (error) { - throw new Error(`Cleanup failed: ${error instanceof Error ? error.message : String(error)}`); - } + try { + await fs.mkdir(tempDir, { recursive: true }); + const srcDir = path.join(tempDir, 'src'); + await fs.mkdir(srcDir); + await fs.writeFile(path.join(tempDir, 'Cargo.toml'), DEFAULT_CARGO_TOML); + await fs.writeFile(path.join(srcDir, 'lib.rs'), rustCode); + return tempDir; + } catch (error) { + throw new Error(`Setup failed: ${error instanceof Error ? error.message : String(error)}`); } + }, + + async cleanupProject(projectPath?: string): Promise { + const tempDir = projectPath || path.join(__dirname, '../../temp'); + + try { + await fs.rm(tempDir, { recursive: true, force: true }); + } catch (error) { + throw new Error(`Cleanup failed: ${error instanceof Error ? error.message : String(error)}`); + } + }, }; -export type FileManager = typeof fileManager; \ No newline at end of file +export type FileManager = typeof fileManager; From 3011f619b6a757019e1fe116214c480a985844a2 Mon Sep 17 00:00:00 2001 From: Benjtalkshow Date: Fri, 8 Aug 2025 15:06:41 +0100 Subject: [PATCH 2/4] fix lint --- apps/backend/src/utils/fileManager.ts | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/apps/backend/src/utils/fileManager.ts b/apps/backend/src/utils/fileManager.ts index e009c67..8051604 100644 --- a/apps/backend/src/utils/fileManager.ts +++ b/apps/backend/src/utils/fileManager.ts @@ -102,11 +102,7 @@ export function getSanitizedDirName(baseName: string): string { * Creates a unique, sanitized temporary directory for Rust project compilation */ export async function setupProject(options: ProjectSetupOptions = {}): Promise { - const { - baseName = 'project', - tempRoot = tmpdir(), - rustCode = DEFAULT_RUST_CODE - } = options; + const { baseName = 'project', tempRoot = tmpdir(), rustCode = DEFAULT_RUST_CODE } = options; // Create a unique identifier to prevent collisions const timestamp = Date.now(); @@ -222,4 +218,4 @@ export const fileManager = { }, }; -export type FileManager = typeof fileManager; \ No newline at end of file +export type FileManager = typeof fileManager; From b06e55c598de29331a040fd2a9c3af18b19fee14 Mon Sep 17 00:00:00 2001 From: Benjtalkshow Date: Sat, 9 Aug 2025 02:52:59 +0100 Subject: [PATCH 3/4] fix lint and conflict --- apps/backend/src/utils/fileManager.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/apps/backend/src/utils/fileManager.ts b/apps/backend/src/utils/fileManager.ts index 3268452..0372a0d 100644 --- a/apps/backend/src/utils/fileManager.ts +++ b/apps/backend/src/utils/fileManager.ts @@ -28,6 +28,8 @@ export interface ProjectSetupOptions { /** * Default Rust contract template + * This is a simple Soroban contract that greets a user by name. + * It can be customized by passing a different `rustCode` in the options. */ const DEFAULT_RUST_CODE = `#![no_std] use soroban_sdk::{contractimpl, Env}; From 90e5551db3e1df1dc4e9b68f131d8f734c3808c7 Mon Sep 17 00:00:00 2001 From: Benjtalkshow Date: Sat, 9 Aug 2025 02:55:52 +0100 Subject: [PATCH 4/4] fix lint and conflict --- apps/backend/src/utils/fileManager.ts | 28 --------------------------- 1 file changed, 28 deletions(-) diff --git a/apps/backend/src/utils/fileManager.ts b/apps/backend/src/utils/fileManager.ts index 0372a0d..d356b22 100644 --- a/apps/backend/src/utils/fileManager.ts +++ b/apps/backend/src/utils/fileManager.ts @@ -187,34 +187,6 @@ export async function createRustProject(tempDir: string, rustCode: string): Prom try { // Create Cargo.toml for Soroban contract - const cargoToml = `[package] -name = "temp-contract" -version = "0.1.0" -edition = "2021" - -[lib] -crate-type = ["cdylib"] - -[dependencies] -soroban-sdk = "21" - -[dev-dependencies] -soroban-sdk = { version = "21", features = ["testutils"] } - -[profile.release] -opt-level = "z" -overflow-checks = true -debug = 0 -strip = "symbols" -debug-assertions = false -panic = "abort" -codegen-units = 1 -lto = true - -[profile.release-with-logs] -inherits = "release" -debug-assertions = true -`; // Create src directory const srcDir = join(tempDir, 'src');