Skip to content

Commit

Permalink
Create basic data and auth providers
Browse files Browse the repository at this point in the history
  • Loading branch information
stnguyen90 committed Nov 23, 2021
1 parent 8fb7b4e commit 675a33f
Show file tree
Hide file tree
Showing 8 changed files with 1,834 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
dist
70 changes: 70 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# ra-appwrite

This package provides a Data Provider and Auth Provider to integrate [Appwrite](https://appwrite.io/) with [react-admin](https://marmelab.com/react-admin).

The Data Provider supports:

- Documents

The Auth Provider supports:

- Login
- Logout
- Permissions (Teams)

## Installation

```sh
yarn add ra-appwrite
# or
npm install ra-appwrite
```

## Usage

```jsx
import React from "react";
import { Appwrite } from "appwrite";
import { AppwriteDataProvider, AppwriteAuthProvider } from "ra-appwrite";
import {
Admin,
EditGuesser,
ListGuesser,
Resource,
ShowGuesser,
} from "react-admin";

// Init your Web SDK
const appwrite = new Appwrite();

appwrite
.setEndpoint("http://localhost/v1") // Your Appwrite Endpoint
.setProject("455x34dfkj"); // Your project ID

// Create a mapping of resources to collection IDs
const resources = {
movies: "6160a2ca6b6fc",
};

// Initialize the providers
const dataProvider = new AppwriteDataProvider(appwrite, resources);
const authProvider = new AppwriteAuthProvider(appwrite);

const App = (): JSX.Element => (
<Admin dataProvider={dataProvider} authProvider={authProvider}>
<Resource
name="movies" // Matches resources key
list={ListGuesser}
edit={EditGuesser}
show={ShowGuesser}
/>
</Admin>
);

export default App;
```

## Roadmap

- Add support for fetching teams
- Add support for fetching files
Loading

0 comments on commit 675a33f

Please sign in to comment.