Skip to content

CapixCapabilities, not routes.

Write what your server can do. The framework handles how it's exposed.

The problem with Express ​

js
// This bug is silent, common, and hard to debug
app.get('/user/:id', async (req, res) => {
  const user = await db.find(req.params.id); // throws if db is down
  res.json(user);                            // never reached — client hangs
});

The Capix way ​

ts
const getUser = capability(
  z.object({ id: z.string() }),
  async ({ id }) => {
    const user = await db.find(id); // throws → client gets a clean 500
    if (!user) throw errors.NotFound({ resource: 'user', id }); // → 404
    return user; // returning is responding
  },
  'query',
).guard(mustBeUser); // guards run before the resolver, every time

Get started in 5 minutes →

Released under the MIT License.