0.4.2 • Published 2 years ago

api-socket-client v0.4.2

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

⚠️ IMPORTANT: api-socket-client is still a work in progress. It is subject to constant and unnotified changes. Do not use this library until version 1.0.0.

What is api-socket-client

api-socket-client is is used to communicate with a server created with api-socket.

What is api-socket

api-socket is the server-side version of this library. It allows you to very easily define the api that this client will use to communicate with the server.

Installation

To install the latest version of api-socket-client:

npm install api-socket-client

To install the latest version of api-socket for your server side code go to installation.

Basic Usage

Creating a simple api client

import { ApiClient, createClient } from "api-socket-client";
import { ApiServer } from "./server";

// The client is created with the server's ip and an optional
// callback for when the client connects to the server.
const client = createClient<ApiServer>("http://localhost:3000", async () => {
  // We can post the login message to the server like this. This is
  // completely typesafe since we created the client with the ApiServer type.
  const response = await client.post("user", "login", {
    email: "email",
    password: "password",
  });

  console.log(response);
});

⚠️ IMPORTANT: If you are going to be sending secret information like emails and passwords be sure that your server and client are using https and not http.

0.4.2

2 years ago

0.4.1

2 years ago

0.4.0

2 years ago

0.3.2

2 years ago

0.3.1

2 years ago

0.3.0

2 years ago

0.2.0

2 years ago

0.1.4

2 years ago

0.1.3

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago