Backend Development 14 min read

An In-Depth Review of ThinkJS: Installation, Architecture, Performance, and Features

This article provides a comprehensive overview of the ThinkJS Node.js framework, covering its installation, directory layout, startup process, routing conventions, performance benchmarks, controller design, adapters, and overall strengths and weaknesses for modern backend development.

Qunar Tech Salon
Qunar Tech Salon
Qunar Tech Salon
An In-Depth Review of ThinkJS: Installation, Architecture, Performance, and Features

ThinkJS is a lightweight, MVC‑style Node.js framework released under the MIT license; it inherits many concepts from ThinkPHP, embraces modern JavaScript features such as ES6/ES7/TypeScript, promises, and WebSocket, and aims for a simple yet powerful development experience.

Installation is performed globally with npm install -g thinkjs , after which the scaffold command thinkjs new demo --es generates a project containing a rich directory structure (app, src, view, www, etc.) and a ready‑to‑run demo.

The generated layout separates common configuration (common) from business modules (home, topic, …), mirroring Rails‑like conventions while recommending a module‑per‑feature organization that improves code discoverability compared with flat controller/model directories.

Running npm start executes www/development.js , which creates a ThinkJS instance with paths for APP_PATH, RUNTIME_PATH, ROOT_PATH, and RESOURCE_PATH, and selects an environment (development, production, testing) without relying on NODE_ENV . The production script www/production.js is used for performance testing.

Routing follows the convention module/controller/action/params ; the default module is home , the default controller is index , and actions map to view files such as view/home/index_index.html . Adding a new action (e.g., myAction ) requires a matching view file ( index_my.html ).

Performance tests with autocannon show that the development mode yields higher latency (≈108 ms) and lower throughput, while the production build improves to ~55 ms latency and ~1800 req/s, slightly slower than an equivalent Express + EJS setup but offering richer built‑in features.

ThinkJS supports two controller styles (plain and hierarchical) and provides __before and __after hooks. An example controller demonstrates constructor injection, a custom filter, and promise‑based action handling.

Routing can be customized with regular expressions, giving developers full control when the default conventions are insufficient.

The framework includes many built‑in adapters, database connectors, middleware, hooks, and plugins, which simplify development for beginners but can also lead to a heavier codebase and more complex refactoring.

Overall strengths are its all‑in‑one design, modern JavaScript support, extensive documentation, i18n, and integrated PM2/Nginx deployment; weaknesses include larger Babel dependencies, a learning curve for the ThinkPHP‑style conventions, and limited reuse of existing Express/Koa knowledge.

In conclusion, ThinkJS is a compelling choice for developers who want to leverage the latest ES features in a full‑stack MVC framework, especially newcomers or those with PHP background, while being aware of its trade‑offs compared with more minimalist Node frameworks.

backendPerformanceMVCRoutingnodejsview()thinkjs
Qunar Tech Salon
Written by

Qunar Tech Salon

Qunar Tech Salon is a learning and exchange platform for Qunar engineers and industry peers. We share cutting-edge technology trends and topics, providing a free platform for mid-to-senior technical professionals to exchange and learn.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.