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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@yamakasinge/backend-core

v0.2.15

Published

Core library for building and serving backend workflows in WeWeb applications

Readme

WeWeb Backend Core

Core library for building and serving backend workflows in WeWeb applications. This package provides the foundation for creating configurable, secure API endpoints with flexible request handling and integration with external services.

Features

  • API route handling and serving with Hono
  • Dynamic workflow configuration and execution
  • Security configuration with public/private access rules
  • Advanced input validation and mapping
  • Integration with external services via pluggable integrations
  • Error handling and response formatting
  • CORS support

Installation

This package is part of the WeWeb Supabase Backend Builder and is designed to be used with Deno.

import type { BackendConfig } from '@yamakasinge/backend-core';
import { serve } from '@yamakasinge/backend-core';

Core Concepts

Backend Configuration

The BackendConfig interface defines the structure for configuring your backend:

interface BackendConfig {
  workflows: Workflow[]
  integrations: PluginIntegration[]
  production: boolean
  rolesConfig?: RolesConfig
}

Workflows

Workflows define API endpoints with their HTTP methods, security settings, input validation, and actions:

interface Workflow {
  path: string
  methods: HttpMethod[]
  inputsValidation?: {
    query?: Record<string, unknown>
    body?: Record<string, unknown>
  }
  security?: {
    accessRule: 'public' | 'private'
    accessRoles?: string[]
    accessRolesCondition?: 'OR' | 'AND'
  }
  workflow: WorkflowAction[]
}

Integrations

Integrations allow external services to be accessed through defined methods:

interface PluginIntegration {
  name: string
  slug: string
  methods: {
    [slug: string]: (...args: any[]) => MaybePromise<any>
  }
}

Input Mapping

The package includes a powerful input mapping system that allows you to transform and map request data (query parameters, body, headers) to action inputs:

// Example input mapping
const mapping = {
  userId: '$query.id',
  userName: '$body.user.name',
  apiKey: '$headers.x-api-key',
  staticValue: 'constant',
  nestedValue: {
    fromBody: '$body.nested.value',
  },
};

Basic Usage

import type { BackendConfig } from '@yamakasinge/backend-core';
import { serve } from '@yamakasinge/backend-core';

// Define your backend configuration
const config: BackendConfig = {
  workflows: [
    {
      path: '/hello',
      methods: ['GET'],
      security: {
        accessRule: 'public',
      },
      workflow: [
        {
          type: 'action',
          id: 'hello_action',
          actionId: 'example.say_hello',
          inputMapping: [],
        },
      ],
    },
  ],
  integrations: [
    {
      name: 'Example',
      slug: 'example',
      methods: {
        say_hello: () => {
          return { message: 'Hello, World!' };
        },
      },
    },
  ],
  production: false,
};

// Start the server
const server = serve(config);
console.log('Server running on http://localhost:8000');

Advanced Features

Input Validation

Define JSON Schema validation for request bodies and query parameters:

const config = {
  path: '/users',
  methods: ['POST'],
  inputsValidation: {
    body: {
      type: 'object',
      properties: {
        name: { type: 'string' },
        email: { type: 'string', format: 'email' },
      },
      required: ['name', 'email'],
    },
  },
  // ...
};

Security Rules

Configure endpoints with public or private access rules:

const config = {
  security: {
    accessRule: 'private',
    accessRoles: ['admin', 'editor'],
    accessRolesCondition: 'OR', // User needs to be either admin OR editor
  }
};

Multi-action Workflows

Chain multiple actions in a workflow and pass results between them:

const config = {
  workflow: [
    {
      type: 'action',
      id: 'first_action',
      actionId: 'example.getData',
      inputMapping: [{ param: '$query.id' }],
    },
    {
      type: 'action',
      id: 'second_action',
      actionId: 'example.processData',
      inputMapping: [{ data: '$results.first_action.value' }],
    },
  ],
};

Development

Testing

The package uses Behavior-Driven Development (BDD) for testing:

import { expect } from 'jsr:@std/expect';
import { describe, it } from 'jsr:@std/testing/bdd';

describe('Feature', () => {
  it('should work correctly', () => {
    // Test code
    expect(result).toBe(expectedValue);
  });
});

Run tests with:

deno test

Code Quality

Format and lint your code:

deno fmt
deno lint

API Reference

Main Exports

  • serve(config: BackendConfig): Deno.HttpServer - Starts the HTTP server with the provided configuration
  • BackendConfig - Type for the backend configuration
  • HttpMethod - Type for HTTP methods ("GET" | "POST" | "PUT" | "DELETE" | "PATCH")
  • PluginIntegration - Type for integration definitions
  • RequestContext - Type for the request context passed to actions
  • RolesConfig - Type for role-based access control configuration
  • Workflow - Type for workflow definitions
  • WorkflowAction - Type for actions within workflows