skapi-js 1.0.0-alpha.9 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +52 -55
- package/dist/skapi.js +1 -1
- package/dist/skapi.js.map +1 -1
- package/dist/skapi.module.js +1 -1
- package/dist/skapi.module.js.map +1 -1
- package/js/Types.d.ts +53 -53
- package/js/main/error.d.ts +1 -0
- package/js/main/error.js +1 -1
- package/js/main/skapi.d.ts +43 -29
- package/js/main/skapi.js +115 -35
- package/js/methods/database.d.ts +13 -9
- package/js/methods/database.js +309 -137
- package/js/methods/request.d.ts +1 -0
- package/js/methods/request.js +47 -24
- package/js/methods/subscription.d.ts +1 -2
- package/js/methods/subscription.js +24 -30
- package/js/methods/user.d.ts +13 -8
- package/js/methods/user.js +36 -18
- package/js/utils/utils.d.ts +1 -0
- package/js/utils/utils.js +17 -17
- package/js/utils/validator.js +26 -20
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,98 +1,95 @@
|
|
|
1
|
-
|
|
2
1
|
# Skapi
|
|
3
2
|
|
|
4
|
-
|
|
3
|
+
Skapi is a backend API service that is specially designed for frontend web developers.
|
|
5
4
|
|
|
6
|
-
|
|
5
|
+
#### Compatible with both vanilla HTML and SPA projects
|
|
7
6
|
|
|
7
|
+
No fancy framework or complex deployment required. Just focused on the basics, Skapi is a single JavaScript library fully compatible with vanilla HTML, as well as any frontend frameworks.
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
#### All-in-One Package
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
2. Log in and create a new service from your [admin page](https://www.skapi.com/admin).
|
|
11
|
+
Skapi provides all the backend features you need for your web application out of the box, without the need to set up or maintain multiple services.
|
|
13
12
|
|
|
14
|
-
|
|
13
|
+
#### Simple, Yet Flexible Database
|
|
15
14
|
|
|
16
|
-
Skapi
|
|
17
|
-
You need to import the library using the `<script>` tag or install via npm.
|
|
15
|
+
Skapi's unique database design combines the best of SQL and noSQL worlds, providing both scalability and flexibility without the need for manual schema design.
|
|
18
16
|
|
|
19
|
-
|
|
17
|
+
## Getting Started
|
|
20
18
|
|
|
21
|
-
|
|
19
|
+
### 1. Create a service
|
|
22
20
|
|
|
23
|
-
|
|
21
|
+
1. Signup for an account at [skapi.com](https://www.skapi.com/signup).
|
|
22
|
+
2. Log in and create a new service from your [dashboard page](https://www.skapi.com/admin).
|
|
24
23
|
|
|
25
|
-
```html
|
|
26
|
-
<script src="https://cdn.jsdelivr.net/npm/skapi-js@latest/dist/skapi.js"></script>
|
|
27
|
-
```
|
|
28
24
|
|
|
29
|
-
|
|
25
|
+
### 2. Initialize the Skapi library
|
|
26
|
+
|
|
27
|
+
Skapi is compatible with both vanilla HTML and webpack-based projects (ex. Vue, React, Angular... etc).
|
|
28
|
+
You need to import the library using the `<script>` tag or install via npm.
|
|
29
|
+
|
|
30
|
+
#### For HTML projects:
|
|
31
|
+
|
|
32
|
+
For vanilla HTML projects, import Skapi in the script tag, and initialize the library.
|
|
33
|
+
|
|
30
34
|
```html
|
|
35
|
+
<!-- index.html -->
|
|
31
36
|
<!DOCTYPE html>
|
|
32
37
|
<script src="https://cdn.jsdelivr.net/npm/skapi-js@latest/dist/skapi.js"></script>
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
38
|
+
|
|
39
|
+
<!-- Your content goes here -->
|
|
40
|
+
|
|
36
41
|
<script>
|
|
37
|
-
// Initialize Skapi
|
|
38
|
-
// Replace 'service_id' and 'owner_id' with the values from your Skapi dashboard.
|
|
39
42
|
const skapi = new Skapi('service_id', 'owner_id');
|
|
40
|
-
...
|
|
41
43
|
</script>
|
|
42
44
|
```
|
|
43
45
|
|
|
46
|
+
**Be sure to replace `'service_id'` and `'owner_id'` with the actual values of your service.**
|
|
44
47
|
|
|
45
|
-
|
|
48
|
+
#### For SPA projects:
|
|
46
49
|
|
|
47
|
-
To use Skapi in a
|
|
50
|
+
To use Skapi in a SPA projects (such as Vue, React, or Angular), you can install skapi-js via npm.
|
|
48
51
|
|
|
49
52
|
```sh
|
|
50
|
-
$ npm
|
|
53
|
+
$ npm i skapi-js
|
|
51
54
|
```
|
|
52
55
|
|
|
53
|
-
Then, import the library into your main JavaScript file
|
|
56
|
+
Then, import the library into your main JavaScript file.
|
|
54
57
|
|
|
55
58
|
```javascript
|
|
56
59
|
// main.js
|
|
57
|
-
import { Skapi } from 'skapi-js';
|
|
58
|
-
|
|
59
|
-
// Initialize Skapi
|
|
60
|
-
// Replace 'service_id' and 'owner_id' with the values from your Skapi dashboard.
|
|
60
|
+
import { Skapi } from 'skapi-js';
|
|
61
61
|
const skapi = new Skapi('service_id', 'owner_id');
|
|
62
62
|
|
|
63
|
-
// export the initialized Skapi instance.
|
|
64
63
|
export { skapi }
|
|
65
64
|
|
|
66
|
-
// Now you can import
|
|
65
|
+
// Now you can import skapi from anywhere in your project.
|
|
67
66
|
```
|
|
68
67
|
|
|
69
|
-
|
|
68
|
+
### 3. Test your connection
|
|
70
69
|
|
|
71
|
-
|
|
70
|
+
After you initialized the Skapi library, you can test your connection by pinging your request with the `mock()` method.
|
|
72
71
|
|
|
73
|
-
|
|
72
|
+
Below is an example of how you can use the `mock()` method in both HTML forms and JavaScript code.
|
|
74
73
|
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
74
|
+
```html
|
|
75
|
+
<!-- index.html -->
|
|
76
|
+
<!DOCTYPE html>
|
|
77
|
+
<script src="https://cdn.jsdelivr.net/npm/skapi-js@latest/dist/skapi.js"></script>
|
|
78
|
+
|
|
79
|
+
<form onsubmit='skapi.mock(event).then(ping=>alert(ping.msg))'>
|
|
80
|
+
<input name='msg' placeholder='Test message'>
|
|
81
|
+
<input type='submit' value='Test Connection'>
|
|
82
|
+
</form>
|
|
81
83
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
{
|
|
86
|
-
email: string; // The email address of the service owner.
|
|
87
|
-
ip: string; // The IP address of the current connection.
|
|
88
|
-
locale: string; // The current locale of the connection.
|
|
89
|
-
owner: string; // The user ID of the service owner.
|
|
90
|
-
region: string; // The region where the service resource is located.
|
|
91
|
-
service: string; // The service ID.
|
|
92
|
-
timestamp: number; // The timestamp of the service creation.
|
|
93
|
-
}
|
|
84
|
+
<script>
|
|
85
|
+
const skapi = new Skapi('service_id', 'owner_id');
|
|
86
|
+
</script>
|
|
94
87
|
```
|
|
95
88
|
|
|
96
|
-
|
|
89
|
+
This will send a request to your Skapi service and ping back the response.
|
|
90
|
+
When the request is resolved, the `mock()` method will return the response data as a `Promise` object.
|
|
91
|
+
The response data will be displayed in an alert box.
|
|
92
|
+
|
|
93
|
+
Skapi is capable of handling HTML `onsubmit` event directly.
|
|
97
94
|
|
|
98
|
-
For more information, check out our [
|
|
95
|
+
#### For more information, check out our [documentation](https://docs.skapi.com).
|