Skip to content

Commit

Permalink
add documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
prostgles committed Dec 13, 2024
1 parent db71f70 commit 4855673
Show file tree
Hide file tree
Showing 34 changed files with 10,808 additions and 3,756 deletions.
100 changes: 48 additions & 52 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
# prostgles-server
Isomorphic PostgreSQL client for [node](http://nodejs.org)

Isomorphic PostgreSQL client for [node](http://nodejs.org)

[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/prostgles/prostgles-server-js/blob/master/LICENSE)
[![npm version](https://img.shields.io/npm/v/prostgles-server.svg?style=flat)](https://www.npmjs.com/package/prostgles-server)
![Tests](https://github.com/prostgles/prostgles-server-js/actions/workflows/main.yml/badge.svg)

### New: JSONB schema runtime validation and TS types
<img src="https://prostgles.com/tsdef2.png" width="600px" style="max-width: 90vw; " />
### New: JSONB schema runtime validation and TS types

<img src="https://prostgles.com/tsdef2.png" width="600px" style="max-width: 90vw; " />

## Features
* CRUD operations
* Subscriptions to data changes
* Fine grained access control
* Optimistic data replication
* Generated TypeScript Definition for Database schema

- CRUD operations with end-to-end type safety
- Auto-Generated TypeScript Definition for Database schema
- Subscriptions to data and schema changes
- Fine grained access control
- Optimistic data replication

## Installation

Expand All @@ -25,101 +26,96 @@ $ npm install prostgles-server

## Quick start

```js
let prostgles = require('prostgles-server');
```typescript
import prostgles from "prostgles-server";
import prostgles from "prostgles-server";

prostgles({
dbConnection: {
host: "localhost",
port: "5432",
user: process.env.PG_USER,
password: process.env.PG_PASS
password: process.env.PG_PASS,
},
tsGeneratedTypesDir: __dirname,
onReady: async ({ dbo }) => {

const posts = await dbo.posts.find(
{ title: { $ilike: "%car%" } },
{
orderBy: { created: -1 },
limit: 10
{ title: { $ilike: "%car%" } },
{
orderBy: { created: -1 },
limit: 10,
}
);

}
},
});
```

## Server-Client usage

server.js

```js
const express = require('express');
const express = require("express");
const app = express();
const path = require('path');
var http = require('http').createServer(app);
var io = require('socket.io')(http);
const path = require("path");
var http = require("http").createServer(app);
var io = require("socket.io")(http);
http.listen(3000);

let prostgles = require('prostgles-server');
let prostgles = require("prostgles-server");

prostgles({
dbConnection: {
host: "localhost",
port: "5432",
user: process.env.PRGL_USER,
password: process.env.PRGL_PWD
password: process.env.PRGL_PWD,
},
io,
publish: "*", // Unrestricted INSERT/SELECT/UPDATE/DELETE access to the tables in the database
onReady: async (dbo) => {

}
onReady: async (dbo) => {},
});
```

react.tsx
```js

```js
const App = () => {
const { isLoading, dbo } = useProstglesClient();
if(isLoading) return null;
return <>
Database tables: {Object.keys(dbo)}
</>
}

if (isLoading) return null;
return <>Database tables: {Object.keys(dbo)}</>;
};
```

./public/index.html

```html

<!DOCTYPE html>
<html>
<head>
<title> Prostgles </title>

<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="https://unpkg.com/socket.io-client@latest/dist/socket.io.min.js" type="text/javascript"></script>
<script src="https://unpkg.com/prostgles-client@latest/dist/index.js" type="text/javascript"></script>
<title>Prostgles</title>

<meta name="viewport" content="width=device-width, initial-scale=1" />
<script
src="https://unpkg.com/socket.io-client@latest/dist/socket.io.min.js"
type="text/javascript"
></script>
<script
src="https://unpkg.com/prostgles-client@latest/dist/index.js"
type="text/javascript"
></script>
</head>
<body>

<script>
prostgles({
socket: io(),
onReady: async ({ dbo, dbsMethods, schemaTables, auth }) => {
}
socket: io(),
onReady: async ({ dbo, dbsMethods, schemaTables, auth }) => {},
});
</script>

</body>
</html>
```


## License

[MIT](LICENSE)
[MIT](LICENSE)
542 changes: 0 additions & 542 deletions documentation/CLIENT.md

This file was deleted.

Loading

0 comments on commit 4855673

Please sign in to comment.