Skip to content

Commit 300ff48

Browse files
committed
Add Welcome
1 parent dfa18b8 commit 300ff48

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

packages/core/src/application/Application.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ export class Application {
3737
const path = this.normalizePath(request.path);
3838

3939
switch (path) {
40+
case '':
41+
case '/':
42+
return this.welcomeResponse();
43+
4044
case '/storeavalue':
4145
return await this.storeHandler.handle(request);
4246

@@ -56,6 +60,25 @@ export class Application {
5660
return path.toLowerCase().replace(/\/$/, '');
5761
}
5862

63+
private welcomeResponse(): HttpResponse {
64+
return {
65+
status: 200,
66+
headers: {
67+
'Content-Type': 'application/json',
68+
},
69+
body: JSON.stringify({
70+
service: 'TinyWebDB',
71+
version: '1.0',
72+
endpoints: {
73+
'/storeavalue': 'POST - Store a tag-value pair',
74+
'/getvalue': 'POST - Get a value by tag',
75+
'/deleteentry': 'POST - Delete an entry by tag',
76+
},
77+
documentation: 'https://ai2.appinventor.mit.edu/reference/other/tinywebdb.html',
78+
}),
79+
};
80+
}
81+
5982
private notFoundResponse(): HttpResponse {
6083
return {
6184
status: 404,

0 commit comments

Comments
 (0)