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 🙏

© 2026 – Pkg Stats / Ryan Hefner

cca-blog-module

v0.0.37

Published

Blog module

Readme

CCA Blog Module

This repository contains the Blog module. It is a module only and is integrated into a larger system (no standalone Express server inside this module).

Features

  • Create a post (with categories).
  • Get a single post.
  • Get a paginated list of posts.
  • Update a post.
  • Delete a post.

Integration (container + controller)

import express from "express";
import { createPostContainer } from "cca-blog-module/dist/infrastructure/container/createPostContainer";
import { BaseDatabase } from "cca-core";

const app = express();
app.use(express.json());

// BaseDatabase instance is provided by the main API
const database = new BaseDatabase(/* ... */);

const { postController } = createPostContainer(database);

app.post("/posts", postController.createPost);
app.get("/posts/:id", postController.getPost);
app.get("/posts", postController.getAllPosts);
app.put("/posts/:id", postController.updatePost);
app.delete("/posts/:id", postController.deletePost);

Endpoints

POST /posts

Create a post.

  • Body: title, content, categoryIds (optional), other fields from PostDTO
  • Auth: req.user.id must be set

GET /posts/:id

Get one post by ID.

  • Param: id

GET /posts

Get paginated posts.

  • Query: page, limit, orderBy, order
  • orderBy whitelist: createdAt, publishedAt, title

PUT /posts/:id

Update a post.

  • Param: id
  • Auth: req.user.id must be set

DELETE /posts/:id

Delete a post.

  • Param: id

Response format

type ApiResponse<T> = {
  success: boolean;
  message: string;
  data?: T;
  meta?: {
    timestamp: string;
  };
};

Post DTO (excerpt)

export type PostImageUrlsDTO = {
  imageId?: string;
  originalUrl?: string;
  thumbUrl?: string;
  smUrl?: string;
  mdUrl?: string;
  lgUrl?: string;
  xlUrl?: string;
  title?: string;
  description?: string;
};

export class PostDTO {
  id!: string;
  title!: string;
  slug!: string;
  content!: string;
  excerpt!: string;
  published!: boolean;
  publishedAt?: Date;
  authorId!: string;
  adminAuthorId?: string;
  categoryIds?: string[];
  imageIds?: string[];
  imageUrls?: PostImageUrlsDTO[];
}

Validation

Inputs are validated with yup schemas in src/application/validators/postValidation.ts:

  • required fields title, content
  • unique slug
  • category existence checks

Caching

Uses BaseCacheService (in-memory). PostsCacheService provides:

  • posts:list:* keys for lists
  • posts:detail:* keys for post detail
  • invalidateAllPostsCaches and invalidatePostCache

Build / test

pnpm install
pnpm build:tsup
pnpm test

Testing

There are no tests in this module yet; pnpm test will fail by design. Recommended minimal tests:

  • PostController create + get (integration)
  • GetAllPosts returns data: [] for empty list

Notes

  • This module does not provide a logger; use the main API logger in integration.
  • API response payloads always wrap the result inside data.