ItzNotABug / appexpress

An express.js like framework for Appwrite Functions, enabling super-easy navigation!
Apache License 2.0
43 stars 4 forks source link

Feature: Add `Router` Support #2

Closed ItzNotABug closed 5 months ago

ItzNotABug commented 5 months ago
  1. This PR adds the ability to use a Router, something like -

    const appExpress = new AppExpress();
    const router = new AppExpress.Router();
    
    router.get('/sub', (...) {});
    router.post('/sub', (...) {});
    router.patch('/sub', (...) {});
    
    appExpress.use('/', router);
  2. Additional changes include perf. side improvements by replacing Array implementations with Map for fast access.

  3. Implement tests, add a GitHub Workflow for PRs for the same

  4. Middleware registry is now via appExpress.middleware(...) and not appExpress.use(...)

  5. Middlewares now run before finding any routes and can also return responses now

ItzNotABug commented 5 months ago

I think we should keep the AppExpressResponse in the middleware handler.

This will be helpful for supporting external middlewares.

ItzNotABug commented 5 months ago

Tests run fine -

Screenshot 2024-04-24 at 4 36 24 PM
ItzNotABug commented 5 months ago

LGTM, can be merged. Live Action @ https://appexpressdev.appwrite.global.