Skip to content

Commit

Permalink
Make fetching schema on client init optional
Browse files Browse the repository at this point in the history
You can now start a client by passing a falsy value to the schema
config property. This will prevent the fetching of the schema and
assigning the schema to the "api" object.

Furthermore improved the `client.min.js` file by adding terser.
  • Loading branch information
bas080 committed Jun 20, 2023
1 parent a81074b commit a37d0e2
Show file tree
Hide file tree
Showing 10 changed files with 99 additions and 307 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@ All notable changes to this project will be documented in this file. Dates are d

Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).

#### [v1.0.0](https://github.com/bas080/furver/compare/v0.3.1...v1.0.0)
#### [v1.0.0](https://github.com/bas080/furver/compare/v1.0.0...v1.0.0)

- Make fetching schema on client init optional [`046993d`](https://github.com/bas080/furver/commit/046993d2edbb19fbaae5620e837db50c974e0181)

### [v1.0.0](https://github.com/bas080/furver/compare/v0.3.1...v1.0.0)

> 18 June 2023
- Refactor server module to not include http [`6dff032`](https://github.com/bas080/furver/commit/6dff03274dd27f7de89ea6cca15845556f27b900)
- Remove double bracket array shorthand [`78a8b34`](https://github.com/bas080/furver/commit/78a8b343a89c5475d437fddd28121ee502899a2c)
Expand Down
48 changes: 29 additions & 19 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
# Contributing

<details><summary>Table of Contents</summary>

<!-- toc -->

- [Dependencies](#dependencies)
- [Development](#development)
- [Tests](#tests)
- [Audit](#audit)
- [Formatting](#formatting)
- [Client Bundle](#client-bundle)
- [Documentation](#documentation)

<!-- tocstop -->

</details>

## Dependencies

Lists projects dependencies and the versions.
Expand Down Expand Up @@ -49,15 +65,15 @@ npm t -- -R classic
> tap -j 1 *.test.mjs --no-cov -R classic
cli.test.mjs .......................................... 4/4 2s
client.test.mjs ..................................... 15/15
client.test.mjs ..................................... 16/16
curry.test.mjs ........................................ 4/4
debounce.test.mjs ..................................... 3/3
http.test.mjs ....................................... 10/10
lisp.test.mjs ....................................... 12/12
promises.test.mjs ................................... 10/10
total ............................................... 58/58
total ............................................... 59/59
58 passing (5s)
59 passing (5s)
ok
```
Expand All @@ -84,24 +100,17 @@ npx standard
```bash
set -euo pipefail

npm install rollup @rollup/plugin-node-resolve @rollup/plugin-babel @rollup/plugin-commonjs @rollup/plugin-terser --no-save
npx rollup ./client.mjs -o client.min.js -f iife -n furver -p node-resolve -p babel -p commonjs # -p terser

git add ./client.min.js
```
```
up to date, audited 403 packages in 9s
npm install rollup @rollup/plugin-babel @rollup/plugin-terser --no-save

38 packages are looking for funding
run `npm fund` for details
npx rollup \
./client.mjs \
--name furver \
--file ./client.min.js \
--format iife \
-p babel \
-p terser

found 0 vulnerabilities
```

## Documentation

```bash
# npx rollup ./client.mjs -o client.min.js -f iife -n furver -p node-resolve -p ba```bash
set -euo pipefail

# Spawn a server to demonstrate examples.
Expand All @@ -124,6 +133,7 @@ done
# Add a TOC
chmod +w README.md
npx markdown-toc -i README.md
npx markdown-toc -i CONTRIBUTING.md
chmod -w README.md

# Stop the server
Expand Down
18 changes: 16 additions & 2 deletions CONTRIBUTING.mz
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Contributing

<details><summary>Table of Contents</summary>
<!-- toc -->
</details>

## Dependencies

Lists projects dependencies and the versions.
Expand Down Expand Up @@ -57,8 +61,17 @@ npx standard
```bash bash
set -euo pipefail

npm install rollup @rollup/plugin-node-resolve @rollup/plugin-babel @rollup/plugin-commonjs @rollup/plugin-terser --no-save
npx rollup ./client.mjs -o client.min.js -f iife -n furver -p node-resolve -p babel -p commonjs # -p terser
npm install rollup @rollup/plugin-babel @rollup/plugin-terser --no-save

npx rollup \
./client.mjs \
--name furver \
--file ./client.min.js \
--format iife \
-p babel \
-p terser

# npx rollup ./client.mjs -o client.min.js -f iife -n furver -p node-resolve -p babel -p commonjs # -p terser

git add ./client.min.js
```
Expand Down Expand Up @@ -88,6 +101,7 @@ done
# Add a TOC
chmod +w README.md
npx markdown-toc -i README.md
npx markdown-toc -i CONTRIBUTING.md
chmod -w README.md

# Stop the server
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ Here an working example of the JavaScript client.
})()
```
```javascript
[ 'hello world', 1687104107623, '1.0.0' ]
[ 'hello world', 1687104107629, '1.0.0' ]
[ 'hello world', 1687104107632, '1.0.0' ]
[ 'hello world', 1687130865800, '1.0.0' ]
[ 'hello world', 1687130865806, '1.0.0' ]
[ 'hello world', 1687130865809, '1.0.0' ]
```

All three ways are equivalent and valid ways of writing a furver Lisp program
Expand Down Expand Up @@ -136,9 +136,9 @@ in a single request:

```javascript
(async function() {
const { default: FurverClient } = await import('./client.mjs')
const { default: client } = await import('./client.mjs')

const api = await FurverClient({endpoint: `http://localhost:${process.env.PORT}`})
const api = await client({endpoint: `http://localhost:${process.env.PORT}`})

const { invoiceById, createInvoice } = api

Expand Down
4 changes: 2 additions & 2 deletions README.mz
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,9 @@ in a single request:

```javascript|javascript node
(async function() {
const { default: FurverClient } = await import('./client.mjs')
const { default: client } = await import('./client.mjs')

const api = await FurverClient({endpoint: `http://localhost:${process.env.PORT}`})
const api = await client({endpoint: `http://localhost:${process.env.PORT}`})

const { invoiceById, createInvoice } = api

Expand Down
4 changes: 2 additions & 2 deletions cli.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,10 @@ const argv = yargs(hideBin(process.argv))
const { default: schema } = await import('./schema.mjs')
console.log(JSON.stringify(schema(modules)))
} else {
const { default: FurverClient } = await import('./client.mjs')
const { default: FurverClient, schema } = await import('./client.mjs')
const api = await FurverClient({ endpoint })

return console.log(JSON.stringify(await api.schema()))
return console.log(JSON.stringify(await schema(api)))
}
})
.option('url', {
Expand Down

0 comments on commit a37d0e2

Please sign in to comment.