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 CHANGED
@@ -1,98 +1,95 @@
1
-
2
1
  # Skapi
3
2
 
4
- Welcome to Skapi, the serverless backend API service that simplifies your web development.
3
+ Skapi is a backend API service that is specially designed for frontend web developers.
5
4
 
6
- This guide will walk you through importing the Skapi library into your project, creating a service, and connecting your application to the Skapi server.
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
- ## Creating a service
9
+ #### All-in-One Package
10
10
 
11
- 1. Register for an account at [skapi.com](https://www.skapi.com/signup).
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
- ## Initializing the Skapi library
13
+ #### Simple, Yet Flexible Database
15
14
 
16
- Skapi is compatible with both vanilla HTML and webpack-based projects (ex. Vue, React, Angular... etc).
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
- ### For HTML projects
17
+ ## Getting Started
20
18
 
21
- For vanilla HTML projects, you can import Skapi using the script tag.
19
+ ### 1. Create a service
22
20
 
23
- Add the following script to the head tag of your HTML file:
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
- This is what your starter code should look like:
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
- <body>
34
- <!-- Your content goes here -->
35
- </body>
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
- ### For webpack projects
48
+ #### For SPA projects:
46
49
 
47
- To use Skapi in a webpack-based project (such as Vue, React, or Angular), install skapi-js using npm:
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 install skapi-js
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'; // imports the library
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 Skapi from anywhere in your project.
65
+ // Now you can import skapi from anywhere in your project.
67
66
  ```
68
67
 
69
- Don't forget to replace `service_id` and `owner_id` with the values provided in your Skapi dashboard.
68
+ ### 3. Test your connection
70
69
 
71
- ## Obtaining Connection Information
70
+ After you initialized the Skapi library, you can test your connection by pinging your request with the `mock()` method.
72
71
 
73
- After initializing the Skapi object, you can retrieve information about the current connection by calling the `getConnection()` method.
72
+ Below is an example of how you can use the `mock()` method in both HTML forms and JavaScript code.
74
73
 
75
- ```javascript
76
- skapi.getConnection().then((c) => {
77
- // Connection information
78
- console.log(c);
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
- This method returns a `promise` that resolves with an object containing the following properties:
83
-
84
- ```typescript
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
- ## Documentation
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 [Documentation](https://docs.skapi.com)
95
+ #### For more information, check out our [documentation](https://docs.skapi.com).