Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F22406047
users.ts
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Authored By
Unknown
Size
815 B
Referenced Files
None
Subscribers
None
users.ts
View Options
import
{
CollectionItem
,
TestUtils
}
from
"sealious"
;
import
TheApp
from
"../app.js"
;
import
Users
from
"../collections/users.js"
;
type
Unpromisify
<
T
>
=
T
extends
Promise
<
infer
R
>
?
R
:
T
;
export
function
createAUser
(
app
:
TheApp
,
username
:
string
)
{
return
app
.
collections
.
users
.
suCreate
({
username
,
email
:
`
${
username
}
@example.com`
,
password
:
"password"
,
roles
:
[],
});
}
export
async
function
createAdmin
(
app
:
TheApp
,
rest_api
:
TestUtils
.
MockRestApi
)
:
Promise
<
[
CollectionItem
<
Users
>
,
Unpromisify
<
ReturnType
<
typeof
rest_api
.
login
>>
]
>
{
const
user
=
await
createAUser
(
app
,
"super_user"
);
await
app
.
collections
[
"user-roles"
].
suCreate
({
user
:
user
.
id
,
role
:
"admin"
,
});
const
session
=
await
rest_api
.
login
({
username
:
"super_user"
,
password
:
"password"
,
});
return
[
user
,
session
];
}
File Metadata
Details
Attached
Mime Type
application/javascript
Expires
Fri, Nov 27, 20:11 (5 h, 51 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1228027
Default Alt Text
users.ts (815 B)
Attached To
Mode
rPLAY Sealious playground
Attached
Detach File
Event Timeline