• Blog
  • Docs
  • Pricing
  • We’re hiring!
Log inSign up
devto

devto

adportal

Unlisted
Like
adportal
Home
Code
13
api
5
controllers
2
models
2
public
6
services
5
utils
2
views
2
README.md
REFACTORING.md
devto-stylesheet-README.md
C
devto-stylesheet-fetcher.ts
H
devto-stylesheet-provider.ts
H
index.ts
Branches
2
Pull requests
Remixes
History
Environment variables
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.
Sign up now
Code
/
REFACTORING.md
Code
/
REFACTORING.md
Search
5/8/2025
Viewing readonly version of main branch: v296
View latest version
REFACTORING.md

DEV Partner Portal Refactoring

This document outlines the refactoring changes made to improve the structure and maintainability of the DEV Partner Portal application.

API Structure Improvements

Before

Previously, all routers were mounted at the root path ("/"), which led to potential route conflicts and made the API structure less clear:

// Old approach in api/index.ts apiRouter.route("/", submissionsRouter); apiRouter.route("/", imagesRouter); apiRouter.route("/", uploadcareHelperRouter); apiRouter.route("/", testDevtoStylesRouter);

After

The API routing has been refactored to use proper path prefixes for better organization:

// New approach in api/index.ts apiRouter.route("/submissions", submissionsRouter); apiRouter.route("/images", imagesRouter); apiRouter.route("/uploadcare", uploadcareHelperRouter); apiRouter.route("/test", testDevtoStylesRouter);

A root path handler was added to maintain backward compatibility with existing URLs.

JavaScript Modularization

Before

The client-side JavaScript files (continue.js and landing.js) were large monolithic files with multiple responsibilities, making them difficult to maintain and debug.

After

The JavaScript has been refactored into smaller, more focused modules:

  1. uploadcare-manager.js: Handles all Uploadcare-related functionality
  2. gallery-renderer.js: Handles rendering the image gallery UI
  3. form-handler.js: Handles form submission and validation

This modular approach improves:

  • Code organization and readability
  • Testability
  • Maintainability
  • Reusability

Route Structure Improvements

Before

Routes were defined with inconsistent naming and structure:

// Old approach submissionsRouter.post("/request-magic-link", requestMagicLink); imagesRouter.post("/register-image", registerImage); imagesRouter.get("/list-images", listImages); imagesRouter.delete("/image", deleteImageById);

After

Routes now follow a more RESTful convention:

// New approach submissionsRouter.post("/magic-link", requestMagicLink); imagesRouter.post("/register", registerImage); imagesRouter.get("/list", listImages); imagesRouter.delete("/:id", deleteImageById);

ES Modules Support

The client-side JavaScript now uses ES modules for better code organization and dependency management:

<script src="/public/js/continue.js" type="module"></script>

Benefits of the Refactoring

  1. Improved Code Organization: Clear separation of concerns with modular code
  2. Better Maintainability: Smaller, focused files are easier to understand and modify
  3. Enhanced Scalability: The new structure makes it easier to add new features
  4. Clearer API Structure: RESTful routes with proper path prefixes
  5. Reduced Duplication: Common functionality is now in shared modules
  6. Better Error Handling: Consistent error handling across modules

Future Improvements

  1. Controller Separation: Further separate controllers into presentation and business logic
  2. TypeScript Types: Add more comprehensive TypeScript types for better type safety
  3. Testing: Add unit and integration tests for the refactored code
  4. Documentation: Add JSDoc comments to all functions and modules
  5. Performance Optimization: Implement lazy loading for the image gallery
FeaturesVersion controlCode intelligenceCLIMCP
Use cases
TeamsAI agentsSlackGTM
DocsShowcaseTemplatesNewestTrendingAPI examplesNPM packages
PricingNewsletterBlogAboutCareers
We’re hiring!
Brandhi@val.townStatus
X (Twitter)
Discord community
GitHub discussions
YouTube channel
Bluesky
Open Source Pledge
Terms of usePrivacy policyAbuse contact
Β© 2025 Val Town, Inc.