Registry / devops / think-router-rest

think-router-rest

JSON →
library1.0.5jsnpmunverified

Middleware for ThinkJS 3.x that adds automatic RESTful route recognition to think-router, eliminating the need for custom route definitions. Version 1.0.5 is the latest stable release, with no active development observed since 2018. It is specific to ThinkJS 3.x and requires think-router as a peer dependency. Compared to manual route setup, it infers routes from controller methods (e.g., GET, POST) automatically.

npm install think-router-rest
INSTALL
IMPORT
SIG · THINK-ROUTER-REST
T
think-router-rest
devopsjavascriptv1.0.5
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default (think-router-rest module)
const routerREST = require('think-router-rest');
import routerREST from 'think-router-rest';
ThinkJS uses CommonJS require() by default. ESM import may fail in Node environments without ESM support.

Adds think-router-rest middleware to ThinkJS 3.x config, enabling automatic RESTful route mapping from controller action names.

// src/config/middleware.js const router = require('think-router'); const routerREST = require('think-router-rest'); module.exports = [ {handle: router, options: {}}, {handle: routerREST, options: {}} ]; // Then define a RESTful controller: // src/controller/api/user.js module.exports = class extends think.Controller { getAction() { // GET /api/user this.success('get'); } postAction() { // POST /api/user this.success('post'); } };
Debug
Known issues
gotchaMiddleware order matters: routerREST must come after think-router in the middleware stack.
fix
Ensure think-router is listed before think-router-rest in the middleware array.
affects: >=1.0
gotchaOnly works with ThinkJS 3.x; incompatible with version 2.x.
fix
Use with ThinkJS 3.x only.
affects: >=1.0
Errors
Common errors & fixes
Cannot find module 'think-router-rest'
Package not installed or not in node_modules.
fix
Run: npm install think-router-rest --save
Upgrade
Version history
1.0.5latest on npm
Audit
Dependencies
think-routerrequiredPeer dependency: this plugin extends think-router's functionality and must be used together with it.
Agent activity
5 hits · last 30 days
node
4
Amazon
1
Resources