Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F9582926
mount.ts
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
878 B
Referenced Files
None
Subscribers
None
mount.ts
View Options
import
Router
from
"@koa/router"
;
import
Koa
,
{
Context
}
from
"koa"
;
import
{
Middlewares
}
from
"sealious"
;
import
{
Mountable
}
from
"./page/mountable"
;
async
function
handleHtmlPromise
(
ctx
:
Context
,
next
:
Koa
.
Next
)
{
await
next
();
if
(
ctx
.
body
instanceof
Promise
)
{
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
ctx
.
body
=
await
ctx
.
body
;
}
ctx
.
set
(
"content-type"
,
"text/html;charset=utf-8"
);
}
export
function
mount
(
router
:
Router
,
url
:
string
,
mountable
:
Mountable
)
:
void
{
router
.
use
(
url
,
Middlewares
.
extractContext
(),
Middlewares
.
parseBody
(),
handleHtmlPromise
);
mountable
.
init
();
mountable
.
mount
(
router
,
url
);
// to automatically add trailing slashes:
router
.
get
(
url
.
slice
(
0
,
-
1
),
(
ctx
)
=>
{
ctx
.
redirect
(
ctx
.
originalUrl
+
"/"
);
});
router
.
use
(
url
,
(
ctx
)
=>
ctx
.
set
(
"content-type"
,
"text/html;charset=utf-8"
)
);
}
File Metadata
Details
Attached
Mime Type
text/x-java
Expires
Sat, Oct 11, 08:11 (1 d, 13 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
984032
Default Alt Text
mount.ts (878 B)
Attached To
Mode
rSGEN sealgen
Attached
Detach File
Event Timeline
Log In to Comment