typed-framework
raw JSON → 0.8.12 verified Sat May 09 auth: no javascript
TypeScript-first, Express-based MVC framework with dependency injection, decorators, and Spring-like patterns. Current version: 1.1.7. Release cadence: irregular, pre-1.0.0 status indicated. Differentiator: full decorator support for controllers, services, filters, middleware, and parameter injection without runtime config files – all via TypeScript decorators (experimentalDecorators required).
Common errors
error Cannot read property 'getUser' of undefined ↓
cause Constructor injection not working because UserService not registered properly or decorators missing.
fix
Ensure UserService has @Service() decorator and @RestController() is applied. Also check tsconfig.json for experimentalDecorators and emitDecoratorMetadata.
error Error: No metadata for 'type' found on property 'indexAction' ↓
cause emitDecoratorMetadata not enabled in tsconfig.json.
fix
Add 'emitDecoratorMetadata': true under compilerOptions in tsconfig.json.
error Class extends value undefined is not a constructor or null ↓
cause ApplicationLoader is not imported correctly or reflect-metadata not imported first.
fix
Ensure reflect-metadata is imported at the top of the entry file: import 'reflect-metadata';
Warnings
breaking TypeScript version compatibility: requiring experimentalDecorators and emitDecoratorMetadata in tsconfig.json. Fails silently without them. ↓
fix Set 'experimentalDecorators': true and 'emitDecoratorMetadata': true in tsconfig.json.
gotcha ApplicationSettings must specify rootDir as absolute path; relative paths cause runtime errors looking for srcDir, publicDir etc. ↓
fix Use path.resolve() or __dirname to pass absolute path to rootDir.
deprecated The package README states 'pre-1.0.0', but versions 1.1.x exist. API stability not guaranteed; breaking changes possible in minor versions. ↓
fix Pin exact version in package.json and test upgrades carefully.
gotcha ConnectionFactory.getConnection() and LogFactory.getLogger() are singleton factories that require prior configuration. If called before setup, they return undefined causing crashes. ↓
fix Initialize database and logger in ApplicationLoader subclass before any service uses them.
Install
npm install typed-framework yarn add typed-framework pnpm add typed-framework Imports
- ApplicationLoader wrong
const { ApplicationLoader } = require('typed-framework')correctimport { ApplicationLoader } from 'typed-framework' - RestController wrong
import { RestController } from 'typed-framework/dist'correctimport { RestController } from 'typed-framework' - Service wrong
import { Service } from 'typed-framework/lib'correctimport { Service } from 'typed-framework'
Quickstart
import 'reflect-metadata';
import { ApplicationLoader, ApplicationSettings, RestController, Get, Data, Res, Service } from 'typed-framework';
import express from 'express';
@Service()
class UserService {
public getUser() {
return { id: 1, name: 'John' };
}
}
@RestController('/api')
class UserController {
constructor(private userService: UserService) {}
@Get('/user')
public indexAction(@Data() data: any, @Res() res: express.Response) {
res.json(this.userService.getUser());
}
}
@ApplicationSettings({ rootDir: __dirname })
class App extends ApplicationLoader {}
App.initialize().catch(console.error);