@squadbase/server 0.0.1-beta.5 → 0.0.1
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 +89 -0
- package/package.json +4 -4
package/README.md
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# @squadbase/server
|
|
2
|
+
|
|
3
|
+
Server Side JavaScript SDK for Squadbase - A package for handling server-side operations in Squadbase applications.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @squadbase/server
|
|
9
|
+
# or
|
|
10
|
+
yarn add @squadbase/server
|
|
11
|
+
# or
|
|
12
|
+
pnpm add @squadbase/server
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Features
|
|
16
|
+
|
|
17
|
+
### User Session
|
|
18
|
+
|
|
19
|
+
```typescript
|
|
20
|
+
import { createServerClient } from "@squadbase/server";
|
|
21
|
+
|
|
22
|
+
const client = createServerClient({
|
|
23
|
+
projectId: "your-project-id",
|
|
24
|
+
cookieOptions: {
|
|
25
|
+
getCookie: () => {
|
|
26
|
+
// Implement your cookie retrieval logic here
|
|
27
|
+
// This should return the session cookie string
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
// Get the current authenticated user
|
|
33
|
+
const user = await client.getUser();
|
|
34
|
+
console.log(user);
|
|
35
|
+
// {
|
|
36
|
+
// username: string,
|
|
37
|
+
// email: string,
|
|
38
|
+
// firstName: string,
|
|
39
|
+
// lastName: string,
|
|
40
|
+
// iconUrl: string | null,
|
|
41
|
+
// roles: string[]
|
|
42
|
+
// }
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Local Development
|
|
46
|
+
|
|
47
|
+
For local development, you can provide a mock user:
|
|
48
|
+
|
|
49
|
+
```typescript
|
|
50
|
+
const client = createServerClient({
|
|
51
|
+
projectId: "your-project-id",
|
|
52
|
+
cookieOptions: {
|
|
53
|
+
getCookie: () => undefined,
|
|
54
|
+
},
|
|
55
|
+
mockUser: {
|
|
56
|
+
username: "test-user",
|
|
57
|
+
email: "test@example.com",
|
|
58
|
+
firstName: "Test",
|
|
59
|
+
lastName: "User",
|
|
60
|
+
iconUrl: null,
|
|
61
|
+
roles: ["user"],
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## API Reference
|
|
67
|
+
|
|
68
|
+
### `createServerClient(options: ServerClientOptions)`
|
|
69
|
+
|
|
70
|
+
Creates a new server client instance.
|
|
71
|
+
|
|
72
|
+
#### Options
|
|
73
|
+
|
|
74
|
+
- `projectId` (string): Your Squadbase project ID
|
|
75
|
+
- `cookieOptions` (object):
|
|
76
|
+
- `getCookie`: Function that returns the session cookie string
|
|
77
|
+
- `mockUser` (optional): Mock user object for local development
|
|
78
|
+
|
|
79
|
+
### `ServerClient`
|
|
80
|
+
|
|
81
|
+
#### Methods
|
|
82
|
+
|
|
83
|
+
- `getUser()`: Returns the current authenticated user
|
|
84
|
+
- Returns: Promise<User>
|
|
85
|
+
- Throws: Error if authentication fails
|
|
86
|
+
|
|
87
|
+
## License
|
|
88
|
+
|
|
89
|
+
MIT
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@squadbase/server",
|
|
3
|
-
"version": "0.0.1
|
|
4
|
-
"description": "Server SDK for Squadbase",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Server-side SDK for Squadbase",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
7
7
|
"type": "module",
|
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
"access": "public"
|
|
25
25
|
},
|
|
26
26
|
"keywords": [],
|
|
27
|
-
"author": "
|
|
28
|
-
"license": "
|
|
27
|
+
"author": "Squadbase",
|
|
28
|
+
"license": "MIT",
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"cookie": "^1.0.2"
|
|
31
31
|
},
|