A TypeScript library that automatically generates strongly-typed Express route handlers from REST API contracts defined via the rest-contracts package. Version 1.1.3 is the current stable release; no recent updates or defined release cadence. It eliminates manual type mapping by allowing developers to define contracts (method, path, parameters, return type) and then call an implement() method on RestContractsExpressServer, which enforces type safety at compile time and generates Express handlers. Key differentiators: minimal footprint, no code generation step, pure TypeScript compile-time enforcement, and seamless integration with both client and server sides using the same contract definitions. Requires peer dependency rest-contracts@^1.0.8 and Node >=6.9.
npm install rest-contracts-express-serverNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates defining a REST contract with rest-contracts and implementing it with rest-contracts-express-server, showing automatic type safety for path parameters and return value.
Consider migrating to a more actively maintained alternative like rest-contracts-lambda or implementing your own server adapter.
Always create an express.Router() and pass it to the constructor, then mount the router on the app.
Pass the same router object to all RestContractsExpressServer instances or reuse the same server instance.
Ensure the contract is properly defined and imported before calling implement(contract, handler).
Check that the handler's return type matches the Returns<> type in the contract.
Ensure app.use('/basepath', router) is called after all implement() calls.