Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions apps/backend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,9 @@ The server will start on port 3000 by default (configurable via environment vari
| Endpoint | Method | Description | Request Body | Response |
|----------|--------|-------------|--------------|----------|
| `/api/compile` | POST | Compiles Rust code to WASM | `{ code: string }` | `{ success: boolean, output: string, error?: string }` |
| `/api/test` | POST | Runs tests for Rust code | `{ code: string }` | `{ success: boolean, output: string, error?: string }` |
| `/api/health` | GET | Server health check | None | `{ status: "ok" }` |
| `/api/test` | POST | Runs tests for Rust code | `{ code: string }` | `{ success: boolean, output: string, error?: string }` |
| `/api/test-filemanager` | POST | Test fileManager utilities | `{ baseName?: string, rustCode?: string }` | `{ success: boolean, sanitizedName: string, tempDir: string, message: string }` |

## Security Measures

Expand Down Expand Up @@ -130,7 +131,7 @@ backend/
│ │ ├── compile.controller.ts
│ │ └── test.controller.ts
│ ├── utils/
│ │ ├── file.utils.ts
│ │ ├── fileManager.ts
│ │ └── process.utils.ts
│ ├── services/
│ │ ├── compilation.service.ts
Expand Down
3 changes: 3 additions & 0 deletions apps/backend/bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion apps/backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"private": true,
"scripts": {
"dev": "bun run --watch src/index.ts",
"build": "bun build src/index.ts --outdir ./dist",
"build": "bun build src/index.ts --outdir ./dist --target node",
"lint": "bun eslint src/**/*.ts",
"format": "bun prettier --write 'src/**/*.ts'"
},
Expand Down
42 changes: 42 additions & 0 deletions apps/backend/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,48 @@
import express from 'express';
import { setupProject, getSanitizedDirName, createRustProject } from './utils/fileManager';

const app = express();
app.use(express.json());

app.get('/', (_, res) =>
res.send('Hello from Backend!' + '<br>' + 'The best online soroban compiler is coming...')
);

// Test endpoint for fileManager functionality
app.post('/api/test-filemanager', async (req, res) => {
try {
const {
baseName = 'test-project',
rustCode = 'pub fn hello() -> &\'static str { "Hello, Soroban!" }',
} = req.body;

// Test sanitization
const sanitized = getSanitizedDirName(baseName);

// Test project setup
const project = await setupProject({ baseName });

// Test Rust project creation
await createRustProject(project.tempDir, rustCode);

// Success response
const response = {
success: true,
sanitizedName: sanitized,
tempDir: project.tempDir,
message: 'FileManager test completed successfully - Rust project created and cleaned up',
};

// Cleanup
await project.cleanup();

res.json(response);
} catch (error) {
res.status(500).json({
success: false,
error: error instanceof Error ? error.message : 'Unknown error',
});
}
});

app.listen(3000, () => console.log('Server on http://localhost:3000'));
Loading