メインコンテンツに移動

ApiHelper

The @churchapps/apihelper package provides server-side utilities for all ChurchApps Express.js APIs. It includes the base controller class, JWT authentication, database utilities, and AWS integrations that every API project depends on.

Before You Begin

What's Included

  • CustomBaseController -- base class for API controllers, built on inversify-express-utils
  • Auth -- JWT authentication via CustomAuthProvider, AuthenticatedUser, and Principal
  • Database utilities -- DB.query / DB.queryOne and the Pool class for MySQL connection management, plus MySqlHelper and DBCreator for schema setup
  • AWS integrations -- AwsHelper for S3 file storage and SSM Parameter Store reads
  • Email -- EmailHelper supporting SES and SMTP transports
  • Config loading -- EnvironmentBase reads connection strings and secrets from environment variables or Parameter Store
  • Misc -- EncryptionHelper, FileStorageHelper, LoggingHelper, BasePermissions, SlugHelper

Setup for Local Development

This package lives in the Packages workspace alongside the other shared libraries:

  1. Clone the workspace:

    git clone https://github.com/ChurchApps/Packages.git
  2. Install dependencies at the workspace root:

    cd Packages && yarn install
  3. Build (compiles TypeScript to dist/):

    yarn workspace @churchapps/apihelper build

    Or run yarn build at the root to build every package in dependency order.

To test changes inside a consuming API, use a temporary Yarn portal -- see Local Development Against a Consuming App.

Publishing

Releases go through changesets: run yarn changeset at the workspace root with every change, then yarn publish-all when ready to release. See the Shared Libraries Overview for the full flow.

情報

This package is a dependency of every ChurchApps API -- the core Api, AskApi, and LessonsApi. When making changes, test against an API locally before publishing.

  • Helpers -- The base utility package that this package depends on
  • Module Structure -- How controllers and auth middleware are used in API modules
  • Local API Setup -- Setting up the API for local development