Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F995594
rest-api.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
rest-api.ts
View Options
/* eslint-disable */
import
axios
from
"axios"
;
export
type
Item
<
Fields
>
=
{
id
:
string
;
[
field_name
:
string
]
:
unknown
;
}
&
Fields
;
export
type
CollectionResponse
<
Fields
=
{}
>
=
{
items
:
Item
<
Fields
>
[];
attachments
:
{
[
id
:
string
]
:
any
};
};
export
type
ItemResponse
<
Fields
=
{}
>
=
{
items
:
[
Item
<
Fields
>
];
attachments
:
{
[
id
:
string
]
:
any
};
};
export
type
ItemCreatedResponse
<
Fields
=
{}
>
=
Item
<
Fields
>
;
export
default
class
MockRestApi
{
constructor
(
public
base_url
:
string
)
{}
async
get
(
url
:
string
,
options
?:
Parameters
<
typeof
axios
.
get
>
[
1
])
{
return
(
await
axios
.
get
(
`
${
this
.
base_url
}${
url
}
`
,
options
)).
data
;
}
async
delete
(
url
:
string
,
options
?:
Parameters
<
typeof
axios
.
delete
>
[
1
])
{
return
(
await
axios
.
delete
(
`
${
this
.
base_url
}${
url
}
`
,
options
)).
data
;
}
async
patch
(
url
:
string
,
data
:
any
,
options
?:
Parameters
<
typeof
axios
.
patch
>
[
1
]
)
{
return
(
await
axios
.
patch
(
`
${
this
.
base_url
}${
url
}
`
,
data
,
options
))
.
data
;
}
async
post
(
url
:
string
,
data
:
any
,
options
?:
Parameters
<
typeof
axios
.
post
>
[
2
]
)
{
return
(
await
axios
.
post
(
`
${
this
.
base_url
}${
url
}
`
,
data
,
options
)).
data
;
}
async
login
({
username
,
password
,
}
:
{
username
:
string
;
password
:
string
;
})
{
const
response
=
await
axios
.
post
(
`
${
this
.
base_url
}
/api/v1/sessions`
,
{
username
,
password
,
});
const
session_id
=
response
.
headers
[
"set-cookie"
][
0
]
.
split
(
" "
)[
0
]
.
split
(
"="
)[
1
]
.
slice
(
0
,
-
1
);
return
{
headers
:
{
Cookie
:
`sealious-session=
${
session_id
}
`
}
};
}
static
async
getWithFullUrl
(
url
:
string
,
options
?:
Parameters
<
typeof
axios
.
get
>
[
1
]
)
{
return
await
axios
.
get
(
`
${
url
}
`
,
options
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-java
Expires
Mon, Dec 23, 08:40 (21 h, 7 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
556884
Default Alt Text
rest-api.ts (1 KB)
Attached To
Mode
rS Sealious
Attached
Detach File
Event Timeline
Log In to Comment