@hatchifyjs/koa
TypeScript icon, indicating that this package has built-in type declarations

1.3.66 • Public • Published

@hatchifyjs/koa

What is @hatchifyjs/koa?

@hatchifyjs/koa is a schema-driven library of middleware for your Hatchify app. By defining the schemas (AKA models) of your backend resources, @hatchifyjs/koa will provide you with a set of functions that you can use across your Koa app.

Example Usage

import { datetime, string, PartialSchema } from "@hatchifyjs/core"
import { hatchifyKoa } from "@hatchifyjs/koa"
import Koa from "koa"

const schemas = {
  Todo: {
    name: "Todo",
    attributes: {
      name: string(),
      dueDate: datetime(),
    },
  },
} satisfies Record<string, PartialSchema>

const app = new Koa()
const hatchedKoa = hatchifyKoa(schemas, {
  prefix: "/api",
  database: { uri: "sqlite://localhost/:memory" },
})

;(async () => {
  await hatchedKoa.modelSync({ alter: true })

  app.use(hatchedKoa.middleware.allModels.all)

  app.listen(3000, () => {
    console.log("Started on http://localhost:3000")
  })
})()

More Documentation

@hatchifyjs/koa Documentation

Readme

Keywords

none

Package Sidebar

Install

npm i @hatchifyjs/koa

Weekly Downloads

206

Version

1.3.66

License

MIT

Unpacked Size

471 kB

Total Files

37

Last publish

Collaborators

  • bitovi-os
  • christopherjbaker