Skip to content

Commit dccc6c5

Browse files
Improve docs and release 0.0.3 version
1 parent e15adc9 commit dccc6c5

File tree

3 files changed

+29
-3
lines changed

3 files changed

+29
-3
lines changed

README.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,22 @@ expressjs.
106106

107107
### Server
108108

109-
TBD
109+
The Server class is used to configure the server, like:
110+
111+
```typescript
112+
let app: express.Application = express();
113+
Server.setFileDest('/uploads');
114+
Server.buildServices(app);
115+
app.listen(3000, function() {
116+
console.log('Rest Server listening on port 3000!');
117+
});
118+
```
119+
120+
Note that Server receives an ```express.Router``` instance. Then it configures
121+
all the routes based on the decorators used on your classes.
122+
123+
So, you can use also any other expressjs feature, like error handlers, middlewares etc
124+
without any restriction.
110125

111126
### @Path Decorator
112127

doc/index.html

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,18 @@ <h2 id="basic-usage">Basic Usage</h2>
147147
<p>This library allows you to use ES7 decorators to configure your services using
148148
expressjs. </p>
149149
<h3 id="server">Server</h3>
150-
<p>TBD</p>
150+
<p>The Server class is used to configure the server, like: </p>
151+
<pre><code class="lang-typescript"><span class="hljs-keyword">let</span> app: express.Application = express();
152+
Server.setFileDest(<span class="hljs-string">'/uploads'</span>);
153+
Server.buildServices(app);
154+
app.listen(<span class="hljs-number">3000</span>, <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>) </span>{
155+
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">'Rest Server listening on port 3000!'</span>);
156+
});
157+
</code></pre>
158+
<p>Note that Server receives an <code>express.Router</code> instance. Then it configures
159+
all the routes based on the decorators used on your classes.</p>
160+
<p>So, you can use also any other expressjs feature, like error handlers, middlewares etc
161+
without any restriction. </p>
151162
<h3 id="-path-decorator">@Path Decorator</h3>
152163
<p>The @Path decorator allow us to define a router path for a given endpoint.
153164
Route paths, in combination with a request method, define the endpoints at

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "typescript-rest",
3-
"version": "0.0.2",
3+
"version": "0.0.3",
44
"description": "A Library to create RESTFul APIs with Typescript",
55
"author": "Thiago da Rosa de Bustamante <thiago@cruxframework.org>",
66
"dependencies": {

0 commit comments

Comments
 (0)