Skip to main content

Built and signed on GitHub Actions

This package can be used to create a Shopware App Backend. It's build independent of any JavaScript framework. It relies on Fetch-standardized Request and Response objects. Our recommandation would be https://hono.dev

This package works with Cloudflare Workers, Node.js, Deno, Bun
This package works with Cloudflare Workers
This package works with Node.js
This package works with Deno
This package works with Bun
JSR Score
100%
Published
9 months ago (0.0.56)

App Server

This package can be used to create a Shopware App Backend. It's build independent of any JavaScript framework. It relies on Fetch-standardized Request and Response objects.

Standalone example with Bun

import { AppServer, InMemoryShopRepository } from '@friendsofshopware/app-server'
import { createNotificationResponse } from '@friendsofshopware/app-server/helper/app-actions'

const app = new AppServer({
    appName: 'MyApp',
    appSecret: 'my-secret',
    authorizeCallbackUrl: 'http://localhost:3000/authorize/callback',
}, new InMemoryShopRepository());

const server = Bun.serve({
    port: 3000,
    async fetch(request) {
        const { pathname } = new URL(request.url);
        if (pathname === '/authorize') {
            return app.registration.authorize(request);
        } else if (pathname === '/authorize/callback') {
            return app.registration.authorizeCallback(request);
        } else if (pathname === '/app/product') {
            const context = await app.contextResolver.fromSource(request);

            // do something with payload, and http client

            const notification = createNotificationResponse('success', 'Product created');

            // sign the response, with the shop secret
            await app.signer.signResponse(notification, context.shop.getShopSecret());

            return resp;
        }

        return new Response('Not found', { status: 404 });
    },
});

console.log(`Listening on localhost:${server.port}`);
Built and signed on
GitHub Actions
View transparency log

Add Package

deno add jsr:@friendsofshopware/app-server

Import symbol

import * as app_server from "@friendsofshopware/app-server";

---- OR ----

Import directly with a jsr specifier

import * as app_server from "jsr:@friendsofshopware/app-server";

Add Package

npx jsr add @friendsofshopware/app-server

Import symbol

import * as app_server from "@friendsofshopware/app-server";

Add Package

yarn dlx jsr add @friendsofshopware/app-server

Import symbol

import * as app_server from "@friendsofshopware/app-server";

Add Package

pnpm dlx jsr add @friendsofshopware/app-server

Import symbol

import * as app_server from "@friendsofshopware/app-server";

Add Package

bunx jsr add @friendsofshopware/app-server

Import symbol

import * as app_server from "@friendsofshopware/app-server";