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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@wereform/pkgm-api

v1.0.8

Published

Shared API utilities for BEGENONE and React / React Native apps

Downloads

972

Readme

@wereform/pkg-api

Thin client helpers for the WeReform / BEGENONE backend.

This package wraps common auth, user and channel flows into small, reusable functions so you can call the platform APIs from web, mobile or other Node services without rewriting the same axios logic again and again.


Install

npm install @wereform/pkg-api
# or
yarn add @wereform/pkg-api
# or
pnpm add @wereform/pkg-api

What this package gives you

  • Ready to use axios helpers for:

    • Email verification with OTP
    • Login and logout
    • User signup (with uniqueness check)
    • Channel create, delete and fetch
  • Consistent error logging and rethrow pattern

  • Works in:

    • React / Next
    • React Native / Expo
    • Node scripts or other backend services

Exports

From @wereform/pkg-api you can import:

import {
  emailVerify,
  login,
  logout,
  signup,
  createChannel,
  deleteChannel,
  getChannel,
} from "@wereform/pkg-api";

All functions are async and return the raw response.data from the backend.


Environment and endpoints

Each helper expects:

  • <SERVICE>_API_URL

    • Example: AUTH_API_URL, USER_API_URL, CHANNEL_API_URL, VIDEO_API_URL
  • <ACTION>_ENDPOINT

    • Example: VERIFY_EMAIL_ENDPOINT, LOGIN_ENDPOINT, CREATE_CHANNEL_ENDPOINT

You can:

  • Hardcode endpoints into this package, or
  • Pass them from the app based on environment

Typical patterns:

const AUTH_API_URL = process.env.AUTH_API_URL;
const USER_API_URL = process.env.USER_API_URL;
const CHANNEL_API_URL = process.env.CHANNEL_API_URL;
const VIDEO_API_URL = process.env.VIDEO_API_URL;
const CLOUDFRONT_URL = process.env.CLOUDFRONT_URL;

1. Email verification

Function

emailVerify({
  token,
  AUTH_API_URL,
  email,
  VERIFY_EMAIL_ENDPOINT,
}): Promise<any>
  • token 6 digit verification code
  • AUTH_API_URL Auth service base URL
  • email User email
  • VERIFY_EMAIL_ENDPOINT Path for verify email endpoint

Backend expectation

VERIFY_EMAIL_ENDPOINT = "/api/v1/authentication/route-verification/verifyEmail"

Example

import { emailVerify } from "@wereform/pkg-api";

await emailVerify({
  token: "123456",
  email: "[email protected]",
  AUTH_API_URL: process.env.AUTH_API_URL!,
  VERIFY_EMAIL_ENDPOINT:
    "/api/v1/authentication/route-verification/verifyEmail",
});

Expected backend payload:

{
  "code": "123456",
  "email": "[email protected]"
}

2. Login

Function

login({
  email,
  password,
  AUTH_API_URL,
  LOGIN_ENDPOINT,
}): Promise<any>
  • email User email
  • password User password
  • AUTH_API_URL Auth service base URL
  • LOGIN_ENDPOINT Path for login endpoint

Backend expectation

LOGIN_ENDPOINT = "/api/v1/authentication/route-login/login"

Payload shape:

{
  "eAddress": {
    "email": "[email protected]",
    "password": "secret"
  }
}

Example

import { login } from "@wereform/pkg-api";

const loginRes = await login({
  email: "[email protected]",
  password: "P@ssw0rd!",
  AUTH_API_URL: process.env.AUTH_API_URL!,
  LOGIN_ENDPOINT: "/api/v1/authentication/route-login/login",
});

const { user, tokens } = loginRes.data || loginRes;

Cookies and sessions are handled on the backend with withCredentials: true.


3. Logout

Function

logout({
  AUTH_API_URL,
  LOGOUT_ENDPOINT,
}): Promise<any>
  • AUTH_API_URL Auth service base URL
  • LOGOUT_ENDPOINT Path for logout endpoint

Backend expectation

LOGOUT_ENDPOINT = "/api/v1/authentication/route-logout/logout"

Example

import { logout } from "@wereform/pkg-api";

await logout({
  AUTH_API_URL: process.env.AUTH_API_URL!,
  LOGOUT_ENDPOINT: "/api/v1/authentication/route-logout/logout",
});

4. Signup

Function

signup({
  firstName,
  secondName,
  email,
  password,
  passwordConfirm,
  username,
  USER_API_URL,
  USER_CHECK_EXISTENCE_ENDPOINT,
  CREATE_USER_ENDPOINT,
}): Promise<any>
  • Validates password === passwordConfirm on client
  • First calls a check existence endpoint
  • Then sends final user creation payload

Backend expectations

USER_CHECK_EXISTENCE_ENDPOINT = "/api/v1/users/check-existence"
CREATE_USER_ENDPOINT = "api/v1/users"

Example

import { signup } from "@wereform/pkg-api";

const res = await signup({
  firstName: "John",
  secondName: "Doe",
  email: "[email protected]",
  password: "P@ssw0rd!",
  passwordConfirm: "P@ssw0rd!",
  username: "john-doe",
  USER_API_URL: process.env.USER_API_URL!,
  USER_CHECK_EXISTENCE_ENDPOINT: "/api/v1/users/check-existence",
  CREATE_USER_ENDPOINT: "api/v1/users",
});

const createdUser = res.data || res;

5. Create channel

Function

createChannel({
  NAME,
  ABOUT,
  CHANNEL_USERNAME,
  CHANNEL_API_URL,
  CREATE_CHANNEL_ENDPOINT,
}): Promise<any>

Backend expectation

CREATE_CHANNEL_ENDPOINT = "/api/v1/channels/channel-routes/"

Example

import { createChannel } from "@wereform/pkg-api";

const channel = await createChannel({
  NAME: "WeReform HQ",
  ABOUT: "Long form breakdowns, wires and experiments",
  CHANNEL_USERNAME: "wereform",
  CHANNEL_API_URL: process.env.CHANNEL_API_URL!,
  CREATE_CHANNEL_ENDPOINT: "/api/v1/channels/channel-routes/",
});

6. Delete channel

Function

deleteChannel({
  channelId,
  CHANNEL_API_URL,
  DELETE_CHANNEL_ENDPOINT,
}): Promise<any>

Example

import { deleteChannel } from "@wereform/pkg-api";

await deleteChannel({
  channelId: "CHANNEL_ID_123",
  CHANNEL_API_URL: process.env.CHANNEL_API_URL!,
  DELETE_CHANNEL_ENDPOINT: "/api/v1/channels/channel-routes/",
});

7. Get channel with videos and wires

Function

getChannel({
  channelId,
  CHANNEL_API_URL,
  VIDEO_API_URL,
  CLOUDFRONT_URL,
  GET_CHANNEL_ENDPOINT,
}): Promise<any>

Example

import { getChannel } from "@wereform/pkg-api";

const channel = await getChannel({
  channelId: "CHANNEL_ID_123",
  CHANNEL_API_URL: process.env.CHANNEL_API_URL!,
  VIDEO_API_URL: process.env.VIDEO_API_URL!,
  CLOUDFRONT_URL: process.env.CLOUDFRONT_URL!,
  GET_CHANNEL_ENDPOINT: "/api/v1/channels/channel-routes/",
});

Error handling pattern

All helpers:

  • Log a detailed message to console.error
  • Rethrow the original error
try {
  const data = await login({
    email,
    password,
    AUTH_API_URL: process.env.AUTH_API_URL!,
    LOGIN_ENDPOINT: "/api/v1/authentication/route-login/login",
  });
} catch (err: any) {
  const message =
    err?.response?.data?.message || err?.message || "Unexpected error";
  console.log("AUTH ERROR:", message);
}

License

MIT License

Copyright (c) 2025 WeReform / BEGENONE

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.