You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Oct 23, 2024. It is now read-only.
There is no next method and middleware is discouraged. In synvox/router, the req object is a vanilla http.IncomingMessage object. There is no req.body, req.params, req.query, etc. Instead try this:
importmicrofrom"micro";importRouter,{params,query}from"@synvox/router";constapp=Router();app.get("/:name",req=>{const{ name }=params(req);const{ sort }=query(req);// do something with `name` and `sort`return{ok: true};});micro(app).listen(3000);
You may also write your own hooks using createHook:
importmicrofrom"micro";importRouter,{params,body,createHook}from"@synvox/router";constuseUser=createHook(asyncreq=>{consttoken=req.headers.token;constuser=token ? awaitUsers.get(token) : null;returnuser;});constapp=Router();app.get("/",asyncreq=>{constuser=awaituseUser(req);// do something with `user`return{ok: true};});micro(app).listen(3000);
About
A tiny routing library to complement micro inspired by the good and bad parts of express.js.