A web-based html, css, javascript and json data with realtime preview developed in node.js and express.
- Real-time code editing with preview
- Separation of html, css, javascript
- Supports the use of templates through data tags and json data source.
- Project saving and loading
- Image and file uploads
- Static file serving
- Modern MVC architecture
- Node.js (v14 or higher)
- npm (Node Package Manager)
- Clone the repository:
git clone <repository-url>
cd web-code-editor- Install dependencies:
npm install- Start the server:
# Development mode with auto-reload
npm run dev
# Production mode
npm startThe server will start on http://localhost:3200
web-code-editor/
├── public/ # Static frontend files
│ ├── index.html # Main HTML file
│ ├── script.js # Frontend JavaScript
│ └── styles.css # CSS styles
├── src/ # Backend source code
│ ├── models/ # Data models
│ ├── controllers/ # Request handlers
│ ├── routes/ # API routes
│ ├── middleware/ # Custom middleware
│ └── services/ # Business logic services
├── uploads/ # Project storage directory
├── server.js # Main application file
└── package.json # Project configuration
- Endpoint:
GET /api/projects - Description: Retrieves a list of all saved projects
- Response:
[ "project1.json", "project2.json" ]
- Endpoint:
POST /api/save - Description: Saves a project to the server
- Request Body:
{ "filename": "myproject", "content": { // Project content } } - Response:
{ "success": true }
- Endpoint:
GET /api/load/:filename - Description: Loads a specific project
- Parameters:
filename: Name of the project file to load
- Response: Project content in JSON format
- Endpoint:
POST /api/upload - Description: Uploads a file to the server
- Request: Multipart form data with file
- Response:
{ "filename": "uploaded-file-name" }
All API endpoints return appropriate HTTP status codes:
200 OK: Successful operation400 Bad Request: Invalid input404 Not Found: Resource not found500 Internal Server Error: Server error
Error response format:
{
"error": "Error message description"
}npm run devThis starts the server with nodemon for auto-reloading during development.
The application uses the following environment variables:
PORT: Server port (default: 3200)NODE_ENV: Environment mode ('development' or 'production')
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.