Convexpress routes implementing collections in the lk-architecture.
import express from "express";
import convexpress from "convexpress";
import collection from "lk-collection-convexpress";
import getDispatch from "lk-dispatch";
const posts = collection({
name: "posts",
schema: {
type: "object",
properties: {/* ... */}
},
authorize: {
insert: () => ({authorized: true}),
replace: () => ({authorized: true}),
remove: () => ({authorized: true})
},
dispatchEvent: getDispatch(/* ... */),
findElement: () => ({}),
});
const convrouter = convexpress({/* ... */})
.serveSwagger()
.convroute(posts.insert)
.convroute(posts.replace)
.convroute(posts.remove);
express()
.use(convrouter)
.listen(3000);