Skip to main content

# Getting Started

## Overview​

`@elliemae/pui-service-sdk` is a TypeScript SDK for building secure, production-ready Node.js microservices. It provides a pre-configured Express application with built-in security headers, structured logging with PII redaction, Redis caching with in-memory fallback, AWS integrations, and JWT/OAuth token management.

## Prerequisites​

- Node.js >= 20
- pnpm >= 8

## Installation​

    pnpm add @elliemae/pui-service-sdk

## Quick Start​

Create a minimal microservice in three steps:

    import { initApp, listen, service, logger } from '@elliemae/pui-service-sdk';

    // 1. Create a structured logger
    const log = logger({
      appName: 'my-service',
      team: 'my-team',
    });

    // 2. Define your routes
    const myRoutes = (app) => {
      app.get('/api/hello', (req, res) => {
        res.json({ message: 'Hello, world!' });
      });
    };

    // 3. Initialize, wire up routes, and start
    const app = initApp();
    service.handleRequest({ logger: log, routes: [myRoutes] })(app);
    listen(app);

Run the service and visit `http://localhost:3000/health` to confirm it's working.

## What You Get Out of the Box​

Feature | Details
--- | ---
Security headers | HSTS, X-Content-Type-Options, X-Download-Options, Referrer-Policy, Hide X-Powered-By (via Helmet)
CORS | Pre-configured for ICE/Ellie Mae domains, customizable
HTTP parameter pollution | Protected via `hpp`
Compression | gzip response compression
Body parsing | JSON, URL-encoded, plain text, and CSP reports
Health check | Built-in `GET /health` endpoint
Error handling | 404 handler and unhandled exception handler with correlation IDs
Structured logging | Pino-based with PII redaction and environment metadata
Graceful shutdown | Handles SIGINT/SIGTERM with optional cleanup hooks
Serverless support | AWS Lambda wrapper via `@vendia/serverless-express`

## Project Structure​

A typical service built with this SDK:

    my-service/
    ├── src/
    │   ├── routes/
    │   │   ├── users.ts
    │   │   └── orders.ts
    │   └── index.ts          # Entry point
    ├── package.json
    └── tsconfig.json

## Next Steps​

See the User Guide for detailed documentation on each module.