Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F1262349
page.ts
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
page.ts
View Options
import
Router
from
"@koa/router"
;
import
{
Context
}
from
"koa"
;
import
{
FlatTemplatable
,
tempstream
}
from
"tempstream"
;
import
type
{
FormDataValue
}
from
"../forms/form-types.js"
;
import
{
Fields
,
MountableWithFields
,
PageErrorMessage
,
}
from
"./mountable-with-fields.js"
;
import
{
AllQueryParams
,
PagePropsParser
}
from
"./props-parser.js"
;
export
abstract
class
Page
<
F
extends
Fields
=
Record
<
string
,
never
>
>
extends
MountableWithFields
<
F
>
{
propsParser
:
PagePropsParser
<
Record
<
keyof
Fields
,
unknown
>>
=
new
AllQueryParams
();
controls
=
[];
mount
(
router
:
Router
,
path
:
string
)
:
void
{
router
.
get
(
path
,
async
(
ctx
)
=>
{
ctx
.
body
=
await
this
.
render
(
ctx
);
});
}
// eslint-disable-next-line @typescript-eslint/no-unused-vars
async
canAccess
(
_
:
Context
)
{
return
{
canAccess
:
true
,
message
:
""
};
}
async
renderError
(
_
:
Context
,
error
:
PageErrorMessage
)
:
Promise
<
FlatTemplatable
>
{
return
tempstream
/* HTML */
`<div>
${
error
.
message
}
</div>`
;
}
public
abstract
render
(
ctx
:
Context
)
:
Promise
<
FlatTemplatable
>
;
async
extractRawValues
(
ctx
:
Context
)
:
Promise
<
Record
<
string
,
FormDataValue
>>
{
return
this
.
propsParser
.
decode
(
ctx
)
||
{};
}
}
File Metadata
Details
Attached
Mime Type
text/x-java
Expires
Thu, Jan 23, 19:19 (1 d, 1 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
599874
Default Alt Text
page.ts (1 KB)
Attached To
Mode
rSGEN sealgen
Attached
Detach File
Event Timeline
Log In to Comment