Skip to content

Commit

Permalink
npm v1.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
vbilopav committed Apr 30, 2024
1 parent 80bcd8e commit 0395a0c
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 101 deletions.
13 changes: 13 additions & 0 deletions client.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,19 @@ Notes: `win-x64` is the designated target OS for the build. Adjust this paramete

The Mac OS builds are missing because I don't have a Mac machine. If someone could help me out with this I'd be grateful.

## Features

- Create an Automatic REST API for the PostgreSQL Databases.
- Generate TypeScript Code and HTTP files for testing.
- Configure security for use the of either encrypted cookies or JWT Bearer tokens or both.
- Expose REST API endpoints for the PostgreSQL Databases as Login/Logout.
- Use external authentication providers such as Google, LinkedIn or GitHub.
- Server static content.
- Use and configure built-in Serilog structured logging.
- Configure Cross-origin resource sharing (CORS) access, SSL, Server Certificates and more, everything needed for modern Web development.

See the [default configuration file](https://vb-consulting.github.io/npgsqlrest/config/) with descriptions for more information.

## Usage

```console
Expand Down
2 changes: 1 addition & 1 deletion npm/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "npgsqlrest",
"version": "1.0.0",
"version": "1.1.0",
"description": "Automatic REST API for PostgreSQL Databases Client Build",
"scripts": {
"postinstall": "node postinstall.js",
Expand Down
2 changes: 1 addition & 1 deletion npm/postinstall.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const os = require("os");
const https = require("https");

const downloadDir = "../.bin/";
const downloadFrom = "https://github.com/vb-consulting/NpgsqlRest/releases/download/v2.7.0/";
const downloadFrom = "https://github.com/vb-consulting/NpgsqlRest/releases/download/v2.7.1-client-v1.1.0/";

function download(url, to, done) {
https.get(url, (response) => {
Expand Down
125 changes: 26 additions & 99 deletions npm/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,119 +8,46 @@

## Description

The `npgsqlrest` is an NPM distribution of AOT (ahead-of-time) native client build of the `NpgsqlRest` standalone client web application.
The `npgsqlrest` is an NPM distribution of the self-contained ahead-of-time (AOT) compiled to native code executables of the [NpgsqlRest Client Web App](https://github.com/vb-consulting/NpgsqlRest/tree/master/NpgsqlRestClient).

- Currently, only **Windows-64** and **Linux-64** builds are supported.
- The source code for this build can be found on this location: [NpgsqlRestTestWebApi](https://github.com/vb-consulting/NpgsqlRest/tree/master/NpgsqlRestTestWebApi).
- Executable files are distributed from the [release download page for the latest version](https://github.com/vb-consulting/NpgsqlRest/releases).
- NPM post-install script will download the appropriate build for the target OS (Windows-64v or Linux-64, sorry Mac bros) and the [default configuration file](https://github.com/vb-consulting/NpgsqlRest/blob/master/NpgsqlRestTestWebApi/appsettings.json).
- Executable will be available through the NPX interface after installation:
NpgsqlRest is an Automatic REST API for PostgreSQL Database as the .NET8 Middleware. See the [GitHub Readme](https://github.com/vb-consulting/NpgsqlRest) for more info.

```console
vbilopav@DESKTOP-O3A6QK2:~/npgsqlrest-npm-test$ npx npgsqlrest --help
Usages
1: npgsqlrest-[os]
2: npgsqlrest-[os] [path to one or more configuration file(s)]
3: npgsqlrest-[os] [-v | --version | -h | --help]

Where
npgsqlrest-[os] is executable for the specific OS (like npgsqlrest-win64 or npgsqlrest-linux64)
1: run executable with default configuration files: appsettings.json (required) and appsettings.Development.json (optional).
2: run executable with optional configuration files from argument list.
3: show this screen.

Versions
Build 1.0.0.0
Npgsql 2.7.0.0
NpgsqlRest.HttpFiles 1.0.2.0
NpgsqlRest.TsClient 1.6.0.0

vbilopav@DESKTOP-O3A6QK2:~/npgsqlrest-npm-test$
```

- The command expects a list of configuration files in the argument list.
- If no argument is provided, the command will try to load `appsettings.json` from the current location and optionally `appsettings.Development.json`
- When using multiple configuration files, the later configuration will override values from the previous one.
- The [default configuration file](https://github.com/vb-consulting/NpgsqlRest/blob/master/NpgsqlRestTestWebApi/appsettings.json) can be located in `node_modules` -> `/node_modules/npgsqlrest/appsettings.json`.
- The default configuration will try to connect the following database: `"Host=127.0.0.1;Port=5432;Database=test;Username=postgres;Password=postgres"`
- Recommended use:
1) Copy the default configuration into the project root and adjust it to project needs.
2) - OR - use the default configuration and override it with project configuration from the root.

Example, of new override config:

```json
{
"ApplicationName": "MyProject",
"EnvironmentName": "Production",
"Urls": "http://localhost:5001",
NpgsqlRest Client Web App is a command line utility that runs as a configurable Kestrel web server that can:

"ConnectionStrings": {
"Default": "Host=127.0.0.1;Port=5432;Database=test;Username=postgres;Password=postgres"
},
- Create an Automatic REST API for the PostgreSQL Databases.
- Generate TypeScript Code and HTTP files for testing.
- Configure security for use the of either encrypted cookies or JWT Bearer tokens or both.
- Expose REST API endpoints for the PostgreSQL Databases as Login/Logout.
- Use external authentication providers such as Google, LinkedIn or GitHub.
- Server static content.
- Use and configure built-in Serilog structured logging.
- Configure Cross-origin resource sharing (CORS) access, SSL, Server Certificates and more, everything needed for modern Web development.

"Auth": {
"CookieAuth": true,
"BearerTokenAuth": true
},
See the [default configuration file](https://vb-consulting.github.io/npgsqlrest/config/) with descriptions for more information.

"Log": {
"ToConsole": true,
"ToFile": true
},
## Usage

"StaticFiles": {
"Enabled": true
},

"NpgsqlRest": {
"HttpFileOptions": {
"Enabled": true
},

"TsClient": {
"Enabled": true
},
```console
$ npx npgsqlrest --help
Usage:
npgsqlrest Run with the default configuration files: appsettings.json (required) and appsettings.Development.json (optional).
npgsqlrest [files...] Run with the custom configuration files. All configuration files are required.
npgsqlrest [file1 -o file2...] Use the -o switch to mark the next configuration file as optional. The first file after the -o switch is optional.
npgsqlrest [file1 --optional file2...] Use --optional switch to mark the next configuration file as optional. The first file after the --optional switch is optional.

"CrudSource": {
"Enabled": false
}
}
}
```
npgsqlrest -v, --version Show version information.
npgsqlrest -h, --help Show command line help.

Command:
Note: Values in the later file will override the values in the previous one.

```console
vbilopav@DESKTOP-O3A6QK2:~/npgsqlrest-npm-test$ npx npgsqlrest ./node_modules/npgsqlrest/appsettings.json project-config.json
[15:04:49.409 INF] ----> Starting with configuration(s): ["EnvironmentVariablesConfigurationProvider", "JsonConfigurationProvider for 'appsettings.json' (Required)", "JsonConfigurationProvider for 'project-config.json' (Required)"] [Program]
[15:04:49.409 INF] Using Cookie Authentication with scheme Cookies. Cookie expires in 14 days. [Program]
[15:04:49.410 INF] Using Bearer Token Authentication with scheme BearerToken. Token expires in 1 hours and refresh token expires in 14 days. [Program]
[15:04:49.410 INF] Using connection: Host=127.0.0.1;Port=5432;Database=test;Username=postgres;Application Name=MyProject [Program]
[15:04:49.412 INF] Serving static files from /home/vbilopav/npgsqlrest-npm-test/wwwroot [Program]
[15:04:49.574 INF] Created endpoint POST /api/case-return-long-table1 [NpgsqlRest]
[15:04:49.574 INF] Created HTTP file: /home/vbilopav/npgsqlrest-npm-test/test_public.http [NpgsqlRest.HttpFiles]
[15:04:49.582 INF] Started in 00:00:00.1752748 [Program]
[15:04:49.582 INF] Listening on ["http://localhost:5001"] [Program]
Example: npgsqlrest appsettings.json appsettings.Development.json
Example: npgsqlrest appsettings.json -o appsettings.Development.json
```

## Features

- Automatic **generation of the HTTP REST endpoints** from PostgreSQL functions, procedures, tables or views.
- **Customization** of endpoints with comment annotations. You can easily configure any endpoint by adding comment annotation labels to [PostgreSQL Comments](https://www.postgresql.org/docs/current/sql-comment.html).
- **High performance** with or without native AOT, up to 6 times higher throughput than similar solutions.
- Authentication out of the box, encrypted cookies, or, bearer token or both.
- Logging to console or rolling files (Serilog implementation) with fine tuning.
- Serving static files.
- CORS configuration.
- HTTP file automatic generartion.
- TypeScript client automatic generation.
- And more.

## Installation

Install `npgsqlrest` using npm:

```console
npm install npgsqlrest --save-dev
```
```

0 comments on commit 0395a0c

Please sign in to comment.