Skip to content

Commit

Permalink
readme file
Browse files Browse the repository at this point in the history
  • Loading branch information
thiagobustamante committed Feb 28, 2020
1 parent 247edc8 commit b976126
Showing 1 changed file with 46 additions and 2 deletions.
48 changes: 46 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@
# REST Services for Typescript
This is a lightweight annotation-based [expressjs](http://expressjs.com/) extension for typescript.

It can be used to define your APIs using ES7 decorators.
It can be used to define your APIs using decorators.

**Table of Contents**

- [REST Services for Typescript](#)
- [Installation](#installation)
- [Configuration](#configuration)
- [Basic Usage](#basic-usage)
- [Using with an IoC Container](#using-with-an-ioc-container)
- [Documentation](https://github.com/thiagobustamante/typescript-rest/wiki)
- [Boilerplate Project](#boilerplate-project)

Expand All @@ -40,7 +41,8 @@ Typescript-rest requires the following TypeScript compilation options in your ts
{
"compilerOptions": {
"experimentalDecorators": true,
"emitDecoratorMetadata": true
"emitDecoratorMetadata": true,
"target": "es6" // or anything newer like esnext
}
}
```
Expand Down Expand Up @@ -75,6 +77,48 @@ That's it. You can just call now:
GET http://localhost:3000/hello/joe
```

## Using with an IoC Container

Install the IoC container and the serviceFactory for the IoC Container

```bash
npm install typescript-rest --save
npm install typescript-ioc --save
npm install typescript-rest-ioc --save
```

Then add a rest.config file in the root of your project:

```json
{
"serviceFactory": "typescript-rest-ioc"
}
```

And you can use Injections, Request scopes and all the features of the IoC Container. It is possible to use it with any other IoC Container, like Inversify.

Example:

```typescript
class HelloService {
sayHello(name: string) {
return "Hello " + name;
}
}

@Path("/hello")
class HelloRestService {
@Inject
private helloService: HelloService;

@Path(":name")
@GET
sayHello( @PathParam('name') name: string): string {
return this.sayHello(name);
}
}
```

## Complete Guide

Check our [documentation](https://github.com/thiagobustamante/typescript-rest/wiki).
Expand Down

0 comments on commit b976126

Please sign in to comment.