JSPM

skapi-js

1.0.0-alpha.49
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 755
  • Score
    100M100P100Q101004F
  • License Apache-2.0

Javascript library for Skapi: Complete JAM Stack, front-end driven serverless backend API service.

Package Exports

  • skapi-js
  • skapi-js/dist/skapi.module.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (skapi-js) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Skapi

Welcome to Skapi, the serverless backend API service that simplifies your web development.

This guide will walk you through importing the Skapi library into your project, creating a service, and connecting your application to the Skapi server.

Creating a service

  1. Register for an account at skapi.com.
  2. Log in and create a new service from your admin page.

Initializing the Skapi library

Skapi is compatible with both vanilla HTML and webpack-based projects (ex. Vue, React, Angular... etc). You need to import the library using the <script> tag or install via npm.

For HTML projects

For vanilla HTML projects, you can import Skapi using the script tag.

Add the following script to the head tag of your HTML file:

<script src="https://cdn.jsdelivr.net/npm/skapi-js@latest/dist/skapi.js"></script>

This is what your starter code should look like:

<!DOCTYPE html>
<script src="https://cdn.jsdelivr.net/npm/skapi-js@latest/dist/skapi.js"></script>
<body>
  <!-- Your content goes here -->
</body>
<script>
    // Initialize Skapi
    // Replace 'service_id' and 'owner_id' with the values from your Skapi dashboard.
    const skapi = new Skapi('service_id', 'owner_id');
    ...
</script>

For webpack projects

To use Skapi in a webpack-based project (such as Vue, React, or Angular), install skapi-js using npm:

$ npm install skapi-js

Then, import the library into your main JavaScript file:

// main.js
import { Skapi } from 'skapi-js'; // imports the library

// Initialize Skapi
// Replace 'service_id' and 'owner_id' with the values from your Skapi dashboard.
const skapi = new Skapi('service_id', 'owner_id');

// export the initialized Skapi instance.
export { skapi }

// Now you can import Skapi from anywhere in your project.

Don't forget to replace service_id and owner_id with the values provided in your Skapi dashboard.

Obtaining Connection Information

After initializing the Skapi object, you can retrieve information about the current connection by calling the getConnection() method.

skapi.getConnection().then((c) => {
    // Connection information
    console.log(c);
});

This method returns a promise that resolves with an object containing the following properties:

{
  email: string; // The email address of the service owner.
  ip: string; // The IP address of the current connection.
  locale: string; // The current locale of the connection.
  owner: string; // The user ID of the service owner.
  region: string; // The region where the service resource is located.
  service: string; // The service ID.
  timestamp: number; // The timestamp of the service creation.
}

Documentation

For more information, check out our Documentation