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
- Install Node.js and Git -- see Prerequisites
- Familiarize yourself with the Packages workspace setup and release flow
- This package depends on
@churchapps/helpers(as a peer dependency) and re-exports it
What's Included
- CustomBaseController -- base class for API controllers, built on
inversify-express-utils - Auth -- JWT authentication via
CustomAuthProvider,AuthenticatedUser, andPrincipal - Database utilities --
DB.query/DB.queryOneand thePoolclass for MySQL connection management, plusMySqlHelperandDBCreatorfor schema setup - AWS integrations --
AwsHelperfor S3 file storage and SSM Parameter Store reads - Email --
EmailHelpersupporting SES and SMTP transports - Config loading --
EnvironmentBasereads 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:
-
Clone the workspace:
git clone https://github.com/ChurchApps/Packages.git -
Install dependencies at the workspace root:
cd Packages && yarn install -
Build (compiles TypeScript to
dist/):yarn workspace @churchapps/apihelper buildOr run
yarn buildat 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.
Related Articles
- 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