@trenskow/app 0.7.0 → 0.7.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,7 +5,7 @@
5
5
  "version": "0.2.0",
6
6
  "configurations": [
7
7
  {
8
- "type": "pwa-node",
8
+ "type": "node",
9
9
  "request": "launch",
10
10
  "name": "Test",
11
11
  "skipFiles": [
package/README.md CHANGED
@@ -123,21 +123,26 @@ import { Application, Endpoint } from '@trenskow/app';
123
123
 
124
124
  const app = new Application({ port: 8080 });
125
125
 
126
- (async () => {
126
+ try {
127
127
 
128
- return (await app
129
- .root(
130
- new Endpoint()
131
- .mount('iam', await import('./iam.js')))
132
- .renderer(async ({ result, response }) => {
128
+ const root = new Endpoint()
129
+ .mount('iam', await import('./iam.js'));
130
+
131
+ const renderer = async ({ result, response }) => {
133
132
  response.headers.contentType = 'text/plain';
134
133
  response.end(result);
135
- })
136
- .start())
137
- .port;
134
+ };
135
+
136
+ await app
137
+ .root(root)
138
+ .renderer(renderer)
139
+ .start();
140
+
141
+ console.info(`Application is running on port ${app.port}`)
138
142
 
139
- })().then((port) => console.info(`Application is running on port ${app.port}`))
140
- .catch(console.error);
143
+ } catch (error) {
144
+ console.error(error);
145
+ }
141
146
  ````
142
147
 
143
148
  ````javascript
@@ -510,8 +515,8 @@ Below is an example on how to use the method.
510
515
  default export ({ endpoint }) => {
511
516
  endpoint
512
517
  .get(
513
- async (context) => 'Hello, world!',
514
- () => console.info("Said hello."));
518
+ async (context) => 'Hello, world!',
519
+ () => console.info("Said hello."));
515
520
  };
516
521
  ````
517
522
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trenskow/app",
3
- "version": "0.7.0",
3
+ "version": "0.7.3",
4
4
  "description": "A small HTTP router.",
5
5
  "type": "module",
6
6
  "main": "index.js",