Moonglade

Modern Markdown blogging with AI-powered localization and search.


NestJS pg template

This article introduces a backend project template based on NestJS, PostgreSQL, and TypeORM, aimed at providing a standardized development foundation. The article first outlines the configuration management approach, which involves reading YAML files and combining them with class-validator for strict data validation and transformation, ensuring the security and standardization of configurations. Next, it demonstrates how to use Docker Compose to quickly deploy Redis and PostgreSQL, optimizing the local development environment. The core functional modules include implementing database operations and migration management using TypeORM, as well as building a user authentication and permission control system based on JWT, Passport, and RBAC mechanisms, supporting dynamic retrieval of interface permission information via metadata. Additionally, the template integrates OpenAPI documentation generation and SDK automation tools to facilitate frontend integration. The logging system utilizes Winston and Dayjs to achieve Nest-style logging in development environments and file-based logging in production environments. Finally, the article covers specific data migration commands and a code submission process that follows the Conventional Commits specification, providing a complete technology stack reference for building robust, scalable enterprise-level backend applications.

Views 142
2024 daily nest node pgsql typeorm

Lite Version MongoDB Full-Text Search

This article primarily explores technical solutions for implementing Chinese full-text search in the MongoDB Community Edition. Since the Community Edition does not natively support Chinese word segmentation engines, the author proposes a custom solution based on NestJS, Mongoose, and the `@node-rs/jieba` segmentation library. The article details the use of Docker to deploy a MongoDB environment with replica set support, ensuring service stability through a health check mechanism. In terms of architecture, the project is organized using a Monorepo pattern. By listening to database change events, Chinese text is automatically segmented and written back to the collection upon data insertion, thereby constructing a full-text index that supports Chinese retrieval. This solution not only implements basic query functionality but also covers multi-entity detection, value object handling, and a comparative analysis with Elasticsearch, providing developers with a complete technical practice reference for achieving efficient Chinese search at low cost in constrained environments.

Views 175
docker fulltext mongodb nest node search study work