dbaas

Database as a service. Expose db to REST and GraphQL.
649
Install
npm install dbaas
Latest Version:0.7.1
Vue:3
License:GPL-3.0-only
Last Updated:Mar 7, 2023
Links: npm
Maintainer: callmelann

DBaaS

Database as a service. Expose db to REST and GraphQL.

Provide wrapper, tooling and configuration to ease Node.js development with auto generated API for database and highly customizable extensions.

Simply create table and column to generate the API and add custom extension whenever required.

Features

  • Common configuration like tsconfig, gulpfile and eslintrc
  • Fully TypeScript support for custom extensions
  • Auto restart for every file save
  • Graceful shutdown and close database connection

Installation

npm i -S dbaas
yarn add dbaas

Usage

Declare models

interface Post {
  id: number
  title: string
  content: string
}
declare module "dbaas" {
  interface Models {
    posts: Post
    // add all models here
  }
}

Create custom endpoints

src/extensions/endpoints/post/index.ts
import { RegisterEndpoint } from "dbaas"

const registerEndpoint: RegisterEndpoint = (router, ctx) => {
  /** GET /post/ */
  router.get("/", (_, res) => {
    res.send("ok")
  })
}
export default registerEndpoint

Create action and filter hooks

src/extensions/hooks/post/index.ts
import { RegisterHook } from "dbaas"

const registerHook: RegisterHook = function ({ filter, action }, ctx) {
  // The `posts` string below is type checked so no mistake and better suggestions
  filter("posts.items.update", async (input) => {
    // prevent from update fields when status changed to review
    return input
  })
  action("posts.items.update", async (input) => {
    // or capture dateApproved when status change to approved
  })
}
export default registerHook

Extend gulpfile

gulpfile.js
const defaultGulpFile = require("./node_modules/dbaas/dist/gulpfile.js")
module.exports = {
  ...defaultGulpFile,
}

Then simply run like this yarn gulp start

Creating API

Create table and column from database first. All REST and GraphQL API auto generated from the table and column.

Follow the example.env and create .env that will be loaded by dotenv to connect to the database.

Future projects

  • Custom workflow for hooks and automation

Related Packages

stepci

Automated API Testing and Quality Assurance

140,730 1,872
vuepress-api-playground

The VuePress API Playground is a Vue.js component for showcasing and testing API...

1,650 4
vue-restify

rest API requests

1,112 0
@ts-rest/vue-query

vue-query client integration for @ts-rest

28,810 3,343
@villus/batch

Batch queries plugin for villus graphql client

39,951 808

Version History

Version Released Vue License
0.7.1 3.2.22 GPL-3.0-only
0.7.0 3.2.22 GPL-3.0-only
0.6.3 3.2.22 GPL-3.0-only
0.6.2 3.2.22 GPL-3.0-only
0.6.1 3.2.22 GPL-3.0-only