npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

dbaas

v0.7.1

Published

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

Downloads

38

Readme

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