Moonglade

Modern Markdown blogging with AI-powered localization and search.


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

OpenAPI client generation

This article documents the selection process and practical experience of automatically generating SDKs based on OpenAPI metadata. The author compared three libraries: `autorest`, `swagger-codegen-cli`, and `@hey-api/openapi-ts`, ultimately choosing the latter due to its superior performance in frontend environment compatibility, code conciseness, and type reuse. This choice effectively reduces the workload of manually writing request code and improves development efficiency. Using a NestJS backend and Vue frontend as examples, the article details the complete technical pipeline: configuring `nest-cli.json` to extract DTO and Entity types, utilizing a GitHub Actions pipeline to start the service in a CI environment to retrieve metadata, invoking `@hey-api/openapi-ts` to generate the SDK, and pushing it to a separate sub-repository. The frontend wraps the `@hey-api/client-fetch` client to implement unified authentication interception and error handling, directly importing the generated types and functions within Pinia Stores to achieve type safety and code reuse. This workflow not only reduces the collaboration cost between frontend and backend teams but also minimizes format errors through standardized interface definitions. Although the currently auto-generated parameter validation feature has limitations, the overall solution offers significant advantages in terms of type safety and development efficiency.

Views 385
2024 ci-cd github openapi study swagger vue work

ts strict mode configuration, comfortable

This article primarily demonstrates the TypeScript compiler options configured in strict mode and highlights their positive impact on the development experience. The core configuration includes setting the module system to NodeNext, targeting ES2021 as the compilation target, and enabling strict mode to catch more potential errors. Additionally, to support modern frontend framework features, the configuration enables experimental decorators and decorator metadata emission, and generates declaration files and source maps for debugging purposes. Notably, to reduce type error friction during initialization, the configuration specifically disables strictPropertyInitialization, allowing properties to be initialized later in the constructor. The author concludes by expressing appreciation for the comfort brought by strict mode, indicating that through reasonable compiler option configuration, developers can enjoy the safety and maintainability of strict type checking while balancing development efficiency by fine-tuning certain rules, thereby achieving a smoother coding experience.

Views 185
config daily study ts typescript typescript compiler

pyenv Notes

This article documents the practice and experience of managing Python versions using `pyenv` in an Ubuntu 24.04 environment. The motivation was that while building the MongoDB source code, the official documentation required Python 3.10+, but the system's default version 3.12.3 caused the build to fail due to API incompatibility. Since modifying the source code was not an option, the decision was made to use `pyenv` to specifically install a 3.10.x version. The article details the process of automatically installing `pyenv` via a `curl` script and configuring `~/.bashrc`. It also highlights the extremely unfriendly user experience of `pyenv`, specifically noting the lack of progress indicators, minimal information feedback, and the absence of interactive options during installation and build processes. Additionally, addressing the issue where `pip` and `poetry` command-line mirror source configurations failed, the author successfully configured the Tsinghua University or Tencent Cloud mirror addresses to accelerate dependency package downloads by manually creating and editing the `~/.pip/pip.conf` and `~/.config/pypoetry/config.toml` files. The article emphasizes the importance of not arbitrarily modifying the system's pre-installed Python environment and repeatedly warns developers to avoid writing programs that lack user feedback and interactivity. It suggests that readers refer to this configuration method in similar scenarios to avoid potential pitfalls.

Views 96
daily env install mongodb pyenv study

debug vue3 source code

This article introduces a simple solution for implementing source code debugging in Vue 3 projects. The core idea is to leverage the sourcemap files generated during the Vue 3 build process, combined with VS Code debugging configuration, allowing direct execution without modifying complex configurations. The article first demonstrates how to install dependencies using `pnpm` and run the development command, resulting in build artifacts in the `dist` directory that include map files. It then provides detailed `launch.json` configuration examples covering three debugging scenarios: first, Node.js debugging for the `npm run build` script; second, debugging remotely loaded Vue projects via URL, where it is important to set `webRoot`; and third, debugging original HTML files that reference local Vue packages, requiring correct configuration of `outFiles` to map source code paths. The article also lists complete environment setup steps, including cloning the Vue core repository, creating temporary HTML test files, and creating a Vue project using the official template. This solution aims to help developers quickly establish a debugging chain from browser breakpoints to Vue source code, improving development efficiency. Plans are in place to supplement this with a debugging video demonstration in the future.

Views 59
daily sourcemap study vue vue3 web

Debug Vue3 source code (deprecated)

This article primarily shares an awkward experience of accidentally using Vue 2 source code while debugging Vue 3 source code, and elaborates in detail on the correct debugging approach and configuration methods. The core strategy is to have the Vue 3 source code generate sourcemaps and link them to the project template via a local build, replacing remote package references. Specifically, in Vue's Rollup build configuration file, you need to add `sourcemap: true` in the `output` section to enable source mapping. Regarding the debugging environment configuration, the article provides a VS Code `launch.json` example covering three debugging scenarios: first, debugging the `npm run build` build script itself; second, debugging a remote project based on the official Vue template, where you need to configure `outFiles` to correctly map the source code; and third, debugging raw HTML files, which also requires specifying the `outFiles` path to point to the local Vue source code directory. By combining local builds with source mapping, developers can more effectively track and debug Vue 3 internal logic, avoiding the difficulties of directly debugging minified code, and providing a practical technical solution for deeply understanding the framework's source code.

Views 83
2024 source-code study vue vue3 web

Related Content to Note

This article comprehensively outlines the core technology stack required for full-stack development and operations. The frontend section covers React, Vue, ES, TS, CSS, and UI frameworks, aiming to build modern user interfaces. The backend employs Node.js with the NestJS framework for data type ORM management, integrates mainstream databases and caching technologies such as MySQL, PostgreSQL, MongoDB, and Redis, and incorporates Nginx reverse proxy, Kafka message queue, and V8 engine optimization to ensure high-concurrency processing capabilities. On the operations side, containerized deployment is implemented based on Docker and Containerd, orchestration management is handled via Kubernetes, and a robust observability system is established using Elastic Stack, APM, monitoring, and distributed tracing systems, thereby ensuring high availability and stability of services.

Views 52
2024 Backend Technologies Frontend Development docker study todo

Detailed records of pre-installed Ubuntu applications are documented here.

This document records the checklist of essential software to be installed on the Ubuntu 24.04 system and the operational details. The author lists commonly used software including v2raya proxy tool, Edge browser, VSCode-Insider, QQ, Git, curl, nvm, Docker, CopyQ, DBeaver, MongoDB Compass, VLC, OBS Studio, Four-Leaf Clover Pinyin Input Method, Calibre, Bing Wall, and uLauncher. The text specifically notes potential startup delays after installing the Edge browser, as well as possible permission insufficiency issues when installing curl via snap that may lead to Node.js download failures, and provides corresponding resolution ideas. Additionally, the article includes specific installation commands covering various methods such as snap, apt, flatpak, and script-based installation. Examples include using snap to install v2raya and VLC, using apt to install Git and flatpak, using scripts to install nvm, and using flatpak to install OBS and Calibre, providing a reference for subsequent supplementary software installations.

Views 227
2024 Development Tools Software Installation Ubuntu 24.04 daily ubuntu

Upgrading umijs 3 to 4

This article documents the complete process and insights gained from upgrading the frontend framework of a legacy project from UmiJS 3 to UmiJS 4. The upgrade aims to address low development efficiency, clean up redundant code and libraries, and strengthen engineering standards such as TypeScript and ESLint. The author adopted a strategy of creating a new UmiJS 4 project and gradually migrating code, ensuring functionality stability before merging back into the original project. Specific changes include: replacing configurations with @umijs/max, removing dependencies on webpack-chain, proxy, and mock; rewriting the permission system to support dynamic routing and menus; refactoring class components into function components and introducing Hooks; updating Ant Design to the latest version and removing Less dependencies; deprecating umi-request in favor of axios; and adjusting tsconfig and internationalization configurations. Although specific errors were not detailed in this record, compatibility issues were successfully resolved through official documentation and community assistance, providing a practical reference for similar project upgrades.

Views 126
2024 configuration migration react ts umijs upgrade work

Frontend Excel Import Related Optimizations

This article introduces an implementation approach for an Excel import component based on Ant Design Pro Components. The component uses the Steps component to implement step-by-step operations and integrates ProTable to support online data editing, deletion, and paginated display. Core features include using class-validator for data validation, intuitively displaying validation error messages within the table, and supporting custom validation rules. The component utilizes the ActionProvider pattern to pass data sources, column configurations, and properties between steps, thereby achieving state transitions and data linkage across steps. However, the current implementation has several areas for optimization: the stepChange function should be exposed as a public API; the validation logic is currently hard-coded to depend on class-validator and needs to support pluggable validation libraries; the rawColumns and nextColumns parameter design is redundant and difficult to adapt to single-step or multi-step scenarios; the implicit length-matching convention between the stepActions array and the step list is not flexible enough, so it is recommended to refactor it into a clearer state machine pattern combined with stepProp. The overall architecture aims to provide a flexible data import experience, but further improvements are needed in API design, extensibility, and state management to enhance generality and maintainability.

Views 135
2024 Data Processing Form Validation improve react ts