https://github.com/anzerr/http.ts
Simple http server in ts
https://github.com/anzerr/http.ts
decorators http nodejs ts typescript util
Last synced: about 1 year ago
JSON representation
Simple http server in ts
- Host: GitHub
- URL: https://github.com/anzerr/http.ts
- Owner: anzerr
- License: mit
- Created: 2019-04-15T16:20:34.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2022-10-26T13:27:37.000Z (over 3 years ago)
- Last Synced: 2025-02-10T06:35:40.778Z (about 1 year ago)
- Topics: decorators, http, nodejs, ts, typescript, util
- Language: TypeScript
- Homepage:
- Size: 209 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
### `Intro`

Decorator for a simple http server
#### `Install`
``` bash
npm install --save git+https://github.com/anzerr/http.ts.git
npm install --save @anzerr/http.ts
```
### `Example`
``` javascript
import 'reflect-metadata';
import {Server, Controller, Get} from 'http.ts';
import {Injectable, Inject, Module} from 'inject.ts';
@Injectable()
class Log {
count: number;
constructor() {
this.count = 0;
}
info(...arg) {
this.count += 1;
return console.log(this.count, ...arg);
}
}
@Controller('user')
class Test extends Server.Controller {
@Inject(Log)
logger: Log;
@Get()
list() {
this.logger.info('list');
this.res.status(200).send('1');
}
@Get(':id')
getUser() {
this.logger.info('getUser');
this.res.status(200).send('2');
}
@Get(':id/friends')
getFriends() {
this.logger.info('getFriends');
this.res.status(200).send('3');
}
}
new Server(3000)
.withController([Test])
.start();
```