JSPM

  • Created
  • Published
  • Downloads 122
  • Score
    100M100P100Q70286F
  • License ISC

Shared API core library for PowrStack projects

Package Exports

  • powr-sdk-api
  • powr-sdk-api/dist/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (powr-sdk-api) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Powr SDK API

A shared API core library for PowrStack projects that provides common admin routes and middleware.

Installation

npm install powr-sdk-api

Usage

Basic Setup

const express = require('express');
const { createAdminRoutes } = require('powr-sdk-api');

const app = express();

// Mount admin routes (projectId from environment)
app.use('/admin', createAdminRoutes());

app.listen(3000);

Environment Variables

The SDK uses environment variables from the host project. Set these in your .env file:

# Required
MONGODB_URI=mongodb+srv://user:pass@cluster/database
PROJECT_ID=your-project-id

# Optional
JWT_TOKEN=your-jwt-token
STORAGE_BUCKET=your-storage-bucket

Example Host Project Setup

# spriny-api/.env
MONGODB_URI=mongodb+srv://powrbase:powrbase123@cluster0.3jgjn.mongodb.net/powrbasedb
PROJECT_ID=67feef40059e70e9cf0db96b
JWT_TOKEN=5b69e0614a3d265ae4f7e01fb46205780208be81b6a646797d687448d730550e
STORAGE_BUCKET=powrbase-files
// spriny-api/app.js
const express = require('express');
const { createAdminRoutes } = require('powr-sdk-api');

const app = express();

// One line integration!
app.use('/admin', createAdminRoutes());

app.listen(3000);

Available Routes

The SDK provides these admin routes:

  • /admin/comments - Comments management
  • /admin/files - File uploads
  • /admin/forms - Dynamic forms
  • /admin/invoice - Invoice management
  • /admin/likes - Like/unlike functionality
  • /admin/ratings - Rating system
  • /admin/users - User management
  • /admin/waitlists - Waitlist management
  • /admin/activities - Activity tracking
  • /admin/auth - Authentication
  • /admin/blogs - Blog management
  • /admin/slides - Banner slides
  • /admin/notifications - Notifications

Error Handling

The SDK will throw clear errors if required environment variables are missing:

// Error: MONGODB_URI environment variable is required
// Error: PROJECT_ID environment variable is required

Version

Current version: 2.0.3