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

appstore-backend-api

v1.0.1

Published

Lightweight packaging of selected API services from the appstore backend so other Node.js/Express apps can consume them.

Readme

appstore-backend-api

Lightweight packaging of selected API services from the appstore backend so other Node.js/Express apps can consume them.

Installation

npm install appstore-backend-api

For local testing use npm pack and install the generated .tgz in a consumer project.

Configuration

The package reads database configuration from environment variables provided by the consuming application. Do NOT commit secrets.

Required environment variables:

  • DB_USER
  • DB_PASSWORD
  • DB_DB
  • DB_HOST
  • DIALECT (e.g., postgres)

Set them in the consuming application's environment before requiring the package.

Usage

Service usage (programmatic):

const { productService, categoryService } = require('appstore-backend-api');

// Read-only examples
(async () => {
  const products = await productService.getProducts();
  const single = await productService.getProductById(1);
  const published = await productService.getPublishedProducts({ limit: 10 });
  console.log(products.length, single && single.id, published.length);
})();

Express integration (router):

const express = require('express');
const { apiRouter } = require('appstore-backend-api');

const app = express();
app.use('/api', apiRouter);

app.listen(3000);

Example: multipart/form-data product create (curl)

Protect write routes and ensure DB and MinIO env variables are set in the consuming app.

curl -X POST \
  -H "Authorization: Bearer $API_KEY" \
  -F "category_id=1" \
  -F "app_name=My App" \
  -F "app_version=1.2.3" \
  -F "uploaded_by=tester" \
  -F "build_type=debug" \
  -F "logo=@/path/to/logo.png" \
  -F "upload_apk=@/path/to/app.apk" \
  -F "app_images=@/path/to/img1.png" \
  https://your-consumer-app.example.com/api/products/create

The uploaded files will be stored via the configured MinIO/S3 client and version records are created for APK uploads.

Exported services and methods

  • productService

    • getProductById(id) -> Promise<AppProduct|null>

    • getProducts(filters) -> Promise<AppProduct[]>

    • getPublishedProducts(opts) -> Promise<AppProduct[]>

    • viewAllProducts() -> Promise<FormattedProduct[]>

    • searchProducts(search) -> Promise<AppProduct[]>

    • productWriteService

      • createOrUpdateProduct(data) -> Promise
        • Note: This helper performs DB create/update logic but does NOT handle file uploads or authentication. Consumers should provide upload middleware and authentication when exposing write endpoints.
  • categoryService

    • getCategories() -> Promise<Category[]>
    • getPublishedCategories() -> Promise<Category[]>
  • appInstallationService

    • createInstallation(data) -> Promise
    • getInstallationCount(app_product_id, app_version?) -> Promise
    • getInstallationCountByVersion(app_product_id) -> Promise<{ total_installations, by_version }>
    • getInstallationByDownload(app_product_id) -> Promise
  • appLoginService

    • createAppLogin(data) -> Promise
    • getAppLogins(filters) -> Promise<{ data, total, limit, offset }>
    • getAppLoginById(id) -> Promise<AppLogin|null>
    • getAppLoginCount(app_product_id, app_version?) -> Promise
  • apiRouter — Express router exposing read endpoints for products and categories and several new endpoints for app installation/login data. It includes a small write endpoint at POST /products/create that calls createOrUpdateProduct and POST /app-installation/create and POST /app-login/create for simple programmatic creation. These write routes do not perform authentication or file upload handling; mount additional middleware in your app as needed.

Example: mounting auth middleware

The package includes a tiny example middleware authExample.requireAuth to demonstrate how a consumer might protect write routes. This middleware checks the Authorization header or x-api-key against process.env.API_KEY.

const express = require('express');
const { apiRouter, authExample } = require('appstore-backend-api');

const app = express();
// Protect write routes on the router by mounting middleware before the router
app.use('/api', authExample.requireAuth, apiRouter);

app.listen(3000);

Replace authExample.requireAuth with your real authentication (JWT verification, session middleware, etc.) in production.

Testing locally (pack + install)

From the package root:

npm pack
# this will produce appstore-backend-api-1.0.0.tgz

In your example consumer project directory:

npm install ../path/to/appstore-backend-api-1.0.0.tgz

# then in your app
node -e "require('dotenv').config(); const { productService } = require('appstore-backend-api'); (async()=>{ console.log(await productService.getProducts()); })()"

Build command

There is no build step for this JavaScript package — source is published as CommonJS under src/.

Publish to npm

  1. Update package.json name to a unique package name and set version.
  2. Login to npm: npm login.
  3. Publish: npm publish --access public (or omit --access for unscoped packages).

Notes

  • The package intentionally exposes read-only service functions and a router. The consuming application is responsible for authentication, file uploads, and any middleware needed for the more complex write endpoints that are tightly coupled to Express req/res in the original backend.
  • Do not commit secrets. The package reads credentials from the environment of the consumer.