skapi-js 0.1.99 → 0.1.101

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,37 +1,98 @@
1
- # skapi
2
1
 
3
- Complete JAM Stack, front-end driven backend API service designed to simplify the web development.
2
+ # Skapi
4
3
 
5
- ## For HTML projects
4
+ Welcome to Skapi, the serverless backend API service that simplifies your web development.
6
5
 
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.
7
+
8
+
9
+ ## Creating a service
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).
13
+
14
+ ## Initializing the Skapi library
15
+
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.
18
+
19
+ ### For HTML projects
20
+
21
+ For vanilla HTML projects, you can import Skapi using the script tag.
22
+
23
+ Add the following script to the head tag of your HTML file:
24
+
25
+ ```html
26
+ <script src="https://cdn.jsdelivr.net/npm/skapi-js@latest/dist/skapi.js"></script>
27
+ ```
28
+
29
+ This is what your starter code should look like:
7
30
  ```html
8
31
  <!DOCTYPE html>
9
32
  <script src="https://cdn.jsdelivr.net/npm/skapi-js@latest/dist/skapi.js"></script>
10
33
  <body>
11
- ...
34
+ <!-- Your content goes here -->
12
35
  </body>
13
36
  <script>
14
- const skapi = new Skapi('your_service_id', 'your_user_id');
15
- // ... Start Coding!
37
+ // Initialize Skapi
38
+ // Replace 'service_id' and 'owner_id' with the values from your Skapi dashboard.
39
+ const skapi = new Skapi('service_id', 'owner_id');
40
+ ...
16
41
  </script>
17
42
  ```
18
43
 
19
- ## For webpack projects
20
44
 
21
- To use skapi in a webpack-based project (such as Vue, React, or Angular), install skapi-js from npm:
45
+ ### For webpack projects
46
+
47
+ To use Skapi in a webpack-based project (such as Vue, React, or Angular), install skapi-js using npm:
22
48
 
23
49
  ```sh
24
- $ npm install skapi-js@latest
50
+ $ npm install skapi-js
25
51
  ```
26
52
 
27
53
  Then, import the library into your main JavaScript file:
28
54
 
29
55
  ```javascript
30
56
  // main.js
31
- import { Skapi } from 'skapi-js';
32
- const skapi = new Skapi('your_service_id', 'your_user_id');
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.
61
+ const skapi = new Skapi('service_id', 'owner_id');
33
62
 
34
- export { skapi }; // Import skapi from your project files
63
+ // export the initialized Skapi instance.
64
+ export { skapi }
65
+
66
+ // Now you can import Skapi from anywhere in your project.
35
67
  ```
36
68
 
37
- For more info, visit our [documentation page](https://docs.skapi.com)
69
+ Don't forget to replace `service_id` and `owner_id` with the values provided in your Skapi dashboard.
70
+
71
+ ## Obtaining Connection Information
72
+
73
+ After initializing the Skapi object, you can retrieve information about the current connection by calling the `getConnection()` method.
74
+
75
+ ```javascript
76
+ skapi.getConnection().then((c) => {
77
+ // Connection information
78
+ console.log(c);
79
+ });
80
+ ```
81
+
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
+ }
94
+ ```
95
+
96
+ ## Documentation
97
+
98
+ For more information, check out our [Documentation](https://docs.skapi.com)