1.0.3 • Published 8 years ago

lk-collection-convexpress v1.0.3

Weekly downloads
2
License
Apache-2.0
Repository
github
Last release
8 years ago

npm version Build Status codecov.io Dependency Status devDependency Status

lk-collection-convexpress

Convexpress routes implementing collections in the lk-architecture.

Usage

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);