A convention based web application framework for TypeScript
Focus on what matters! The irony
web application framework supports you on writing clean code for your web application by providing some best practices and pattern, like AOP, IoC and Convention Over Configuration.
You will need nodejs
, at least v4.4.7 to run the examples.
This framework is intended to work with TypeScript
as programming language.
$ npm install -g typescript
Create a folder for your new TypeScript web application, cd into it and run the commands below:
$ npm init
$ npm install -S irony
The following TypeScript compilation options are required in your tsconfig.json
file:
{
"compilerOptions": {
"experimentalDecorators": true,
"emitDecoratorMetadata": true
}
}
To create a new web application, you need a web server.
Create a server.ts
file containing the following lines:
import {WebServer} from "irony";
class Server extends WebServer { }
Server.start();
Place the server file in the project root.
After transpiling, the following command will start your new web server application:
$ node server.js
To handle http requests to your web application, you need a controller.
Create a helloworld.ts
file containing the following lines:
import {Controller, Route} from "irony";
export class HelloWorldController extends Controller {
@Route("/")
public index(): string {
return "Hello World!";
}
}
Place the file in a folder called controller and everything will be wired up automatically.
Transpile, start your favorite web browser and enter the url http://127.0.0.1/
to see your greetings.
You can change default values that are not easy to define by conventions, with custom settings.
Create a settings.json
file that could contain the following lines:
{
"protocol": "http",
"hostname": "127.0.0.1",
"port": 80,
"root": "/"
}
Place the settings file in your project root for now.
$ npm run build
$ npm version patch|minor|major
I would like to thank thiagobustamante for his realy inspiring work on typescript-rest!
This web application framework for TypeScript started as a fork of typescript-rest. I realy liked it, but then I started refactoring the code. I wanted it to become more modular and convention based. Also I wanted to use the typescript-ioc package, which, at the point of forking, was not easy to implement. Evenmore at this time the code was written for ES6, while I needed to target ES5. In the end there was not much that I could have been back-merged, unfortunately.