Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/prostgles/prostgles-server-js
Isomorphic TypeScript Client for Postgres. Realtime data, access control, file storage
https://github.com/prostgles/prostgles-server-js
javascript nodejs pg-promise postgresql socketio typescript
Last synced: about 11 hours ago
JSON representation
Isomorphic TypeScript Client for Postgres. Realtime data, access control, file storage
- Host: GitHub
- URL: https://github.com/prostgles/prostgles-server-js
- Owner: prostgles
- License: mit
- Created: 2020-07-02T12:30:12.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2024-10-21T17:40:48.000Z (4 months ago)
- Last Synced: 2024-10-23T14:03:53.062Z (4 months ago)
- Topics: javascript, nodejs, pg-promise, postgresql, socketio, typescript
- Language: TypeScript
- Homepage: https://prostgles.com
- Size: 35.5 MB
- Stars: 34
- Watchers: 3
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# prostgles-server
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
## Features
- 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
```bash
$ npm install prostgles-server
```## Quick start
```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,
},
tsGeneratedTypesDir: __dirname,
onReady: async ({ dbo }) => {
const posts = await dbo.posts.find(
{ title: { $ilike: "%car%" } },
{
orderBy: { created: -1 },
limit: 10,
},
);
},
});
```## Server-Client usage
server.js
```js
const express = require("express");
const app = express();
const path = require("path");
var http = require("http").createServer(app);
var io = require("socket.io")(http);
http.listen(3000);let prostgles = require("prostgles-server");
prostgles({
dbConnection: {
host: "localhost",
port: "5432",
user: process.env.PRGL_USER,
password: process.env.PRGL_PWD,
},
io,
publish: "*", // Unrestricted INSERT/SELECT/UPDATE/DELETE access to the tables in the database
onReady: async (dbo) => {},
});
```react.tsx
```js
const App = () => {
const { isLoading, dbo } = useProstglesClient();
if (isLoading) return null;
return <>Database tables: {Object.keys(dbo)}>;
};
```./public/index.html
```html
Prostgles
prostgles({
socket: io(),
onReady: async ({ dbo, dbsMethods, schemaTables, auth }) => {},
});
```
## License
[MIT](LICENSE)