@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.
- package/.vscode/launch.json +1 -1
- package/README.md +18 -13
- package/package.json +1 -1
package/.vscode/launch.json
CHANGED
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
|
-
|
|
126
|
+
try {
|
|
127
127
|
|
|
128
|
-
|
|
129
|
-
.
|
|
130
|
-
|
|
131
|
-
|
|
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
|
-
|
|
137
|
-
|
|
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
|
-
}
|
|
140
|
-
|
|
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
|
-
|
|
514
|
-
|
|
518
|
+
async (context) => 'Hello, world!',
|
|
519
|
+
() => console.info("Said hello."));
|
|
515
520
|
};
|
|
516
521
|
````
|
|
517
522
|
|