@spurtcommerce/blogs) provides blog management and storefront blog functionality for SpurtCommerce Community and Enterprise editions.
It includes blog post management for vendors and admins, hierarchical blog categories, tags, related blogs, and storefront browsing with comments.
Unlike add-ons that rely on automatic package discovery, this module is integrated explicitly through its exported initialization function, TypeORM entities, and routing-controllers controllers.
Key Features
- Vendor and Admin blog management: Create, view, update, and delete blog posts, generate slugs, assign categories, upload cover images, manage publication status, and associate related blogs.
- Hierarchical categories: Organize categories using parent-child relationships with category path calculations through
BlogCategoryPath. - Storefront blog browsing: List published blogs, view blog details, search, and filter by category or tag.
- Comments and replies: Accept public comments, support nested replies, and provide moderation functionality.
- Tag management: Create tags and associate them with blog posts through a many-to-many relationship.
- Related blogs: Associate blog posts to provide related-content recommendations.
- Host-application adapters: Integrate with the host application’s TypeORM DataSource, media storage, user resolution, and authentication middleware without hardcoded relative imports into the host project.
Requirements
| Requirement | Version |
|---|---|
| Node.js | >=18.x |
| TypeScript | >=4.9.x / 5.x |
| TypeORM | >=0.3.x |
| routing-controllers | >=0.11.x |
| typedi | >=0.10.x |
Peer dependencies
These dependencies are expected to be provided by the host SpurtCommerce application:
Installation
Run the following command from the root directory of your SpurtCommerce project:Setup and Integration
The package exposes an initialization function, entities, and controllers. Register these components with the host application.1. Configure the TypeORM DataSource
ImportBlogEntities and include them in the application’s TypeORM DataSource configuration.
2. Initialize the Blog Module
ImportinitBlog and pass the application’s DataSource. The module also accepts logger, media, and user adapters.
media adapter connects blog cover-image handling to the host application’s storage solution. The user adapter connects blog operations to the host application’s user-resolution logic.
3. Register the Blog Controllers
ImportBlogControllers and register them with routing-controllers when creating the Express application.
Exported Components
Entities
The package exports the following entities and base model:Controllers
Services and Repositories
The package also exports service and repository layers for its core modules:BlogService/BlogRepositoryBlogCategoryService/BlogCategoryRepositoryBlogCategoryPathService/BlogCategoryPathRepositoryBlogRelatedService/BlogRelatedRepositoryBlogCommentService/BlogCommentRepositoryTagService/TagRepositoryBlogTagService/BlogTagRepository
Functional Overview
Blog Posts
Vendors and admins can manage blog posts, including their content, slug, category assignment, cover image, publication status, and related blog associations.Blog Categories
Categories support nested parent-child structures. TheBlogCategoryPath model stores the calculated paths used to represent the category hierarchy.
Tags
Tags provide an additional way to organize and filter blog content. TheTag and BlogTag models provide the tag records and their associations with blog posts.
Storefront and Comments
The storefront controllers expose blog browsing functionality for published content. Visitors can browse and search blogs, filter by category or tag, open blog details, and submit comments. The module also supports nested replies and comment moderation.Media and Host Application Integration
The blog module is designed to remain decoupled from host application internals. It uses the supplied TypeORM DataSource and adapters rather than relying on hardcoded relative imports into the SpurtCommerce application. Configure the adapters to match the host application’s implementation for:- Media storage: Cover image handling, such as S3 or local file storage.
- User resolution: Resolving the current application user for blog operations.
- Authentication middleware: Applying the host application’s authentication rules to the relevant routes.
License
The package is distributed under the ISC License.Summary
@spurtcommerce/blogs adds a complete blog module to SpurtCommerce, covering vendor and admin blog management, hierarchical categories, tags, related content, and storefront comments. Integration is performed by configuring the TypeORM DataSource, calling initBlog, and registering BlogControllers with routing-controllers.