macchiato-framework / macchiato-framework/macchiato-core

Express Integration

Open
#5 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Clojure
Stars
385
Forks
33
PR merge metrics
No merged PRs in 30d

Description

I hacked Macchiato to work with the Express web framework, combining the two on the same server. It facilitates Express-based servers to be gradually converted to use Macchiato. And existing Express integrations such as Sente can immediately be used with Macchiato. This is the essential code:

(defn bidi-router [routes]                                                                                    
  (fn [req res]                                                                                                                  
    (if-let [route (some->> req :uri (bidi.bidi/match-route routes) :handler)]                                                   
      (route req res))))
                                                                                                                                 
(defn macchiato [http-router & [opts]]                                                                                           
  (let [route (macchiato.http/handler http-router opts)]                                                                         
    (fn [req res next]                                                                                                           
      (if-not (route req res)                                                                                                    
        (next)))))

Macchiato bidi routes can then be used with Express:

(doto (@express) 
    (.use "/" (macchiato (bidi-router routes))))

Perhaps it could be an optional module? I'd be glad to turn it into a PR.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the provided bidi-router and macchiato functions, then locate the repository's Node.js HTTP integration entry point. Done means Express can mount Macchiato routes and existing Express integrations can be used through the proposed optional module.

Written by the indexing model from the issue text.

Assessment

Tech stack
express, node.js
Domain
api, backend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.