Compare commits

...

11 Commits

Author SHA1 Message Date
Szilárd Dóró
d87a9d7c79 Merge pull request #429 from nhost/changeset-release/main
chore: update versions
2022-04-21 10:00:00 +02:00
github-actions[bot]
be7756d4a2 chore: update versions 2022-04-21 07:54:52 +00:00
Szilárd Dóró
ca5e335bff Merge pull request #425 from nhost/fix/broadcast-channel
fix: remove broadcast-channel
2022-04-21 09:53:45 +02:00
Pilou
b9ed794f2b Merge pull request #424 from nhost/docs/graphql-dependency
docs: use docusaurus tabs for npm/yarn commands, and add `graphql` dependency
2022-04-20 16:39:24 +02:00
Pierre-Louis Mercereau
042dc7d27c docs: remove duplicate text 2022-04-20 15:12:22 +02:00
Pierre-Louis Mercereau
db2df3d5b2 docs: remove useless lines 2022-04-20 15:10:57 +02:00
Pierre-Louis Mercereau
0b1cb628f2 fix: remove broadcast-channel 2022-04-20 15:08:30 +02:00
Pierre-Louis Mercereau
912d95d153 docs: add admonitions 2022-04-20 12:14:01 +02:00
Pierre-Louis Mercereau
76059f4738 docs: use docusaurus tabs for npm/yarn commands, and add graphql dependency 2022-04-20 12:06:21 +02:00
Pilou
011572f3ef Merge pull request #423 from nhost/docs/auth-host
docs: notify AUTH_HOST won't be available after hasura-auth `v0.6.0`
2022-04-20 09:22:44 +02:00
Pierre-Louis Mercereau
b727b354dd docs: notify AUTH_HOST won't be available after hasura-auth v0.6.0 2022-04-20 08:37:32 +02:00
25 changed files with 163 additions and 114 deletions

View File

@@ -2,6 +2,9 @@
title: 'Metadata and Serverless Functions'
---
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
In the previous section, we only created a new table; `customers`. Using the CLI you can also do changes to other parts of your backend.
There are three things the CLI and the GitHub integration track and applies to production:
@@ -73,20 +76,25 @@ Serverless functions are placed in the `functions/` folder of your repository. E
Before we create our serverless function we'll install `express`, which is a requirement for serverless functions to work.
<Tabs>
<TabItem value="npm" label="npm" default>
```bash
npm install express
# or with yarn
yarn add express
npm install -d @types/node @types/express
```
We'll use TypeScript so we'll install two type definitions too:
</TabItem>
<TabItem value="yarn" label="Yarn">
```bash
npm install -d @types/node @types/express
# or with yarn
yarn add express
yarn add -D @types/node @types/express
```
</TabItem>
</Tabs>
Then we'll create a file `functions/time.ts`
In the file `time.ts` we'll add the following code to create our serverless function:

View File

@@ -2,6 +2,9 @@
title: 'JavaScript client'
---
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
In the previous section, you used the Hasura Console to fetch a list of todos. Now, you will write a small JavaScript client to interact and retrieve todos from your Nhost app.
### Frontend frameworks
@@ -14,40 +17,36 @@ In this guide, we'll keep the example simple. We're not using a frontend framewo
## Setup
> Make sure you have [Node.js](https://nodejs.org) and [npm](https://docs.npmjs.com/getting-started) installed.
:::info
Create a new folder called `nhost-todos`, and initialize a new JavaScript app there:
Make sure you have [Node.js](https://nodejs.org) and [npm](https://docs.npmjs.com/getting-started) or [Yarn](https://classic.yarnpkg.com/lang/en/docs/install) installed.
Using npm package manager
:::
Create a new folder called `nhost-todos`, initialize a new JavaScript app there, and install the Nhost JavaScript SDK:
<Tabs>
<TabItem value="npm" label="npm" default>
```bash
npm init -y
yarn add @nhost/nhost-js graphql
```
or
Using Yarn package manager
</TabItem>
<TabItem value="yarn" label="Yarn">
```bash
yarn init -y
npm install @nhost/nhost-js graphql
```
> You might have to edit the `package.json` file and add/change the `type` object to `module` (`"type": "module"`).
</TabItem>
</Tabs>
Install Nhost JavaScript SDK:
Using npm package manager
```bash
npm install @nhost/nhost-js
```
or
Using Yarn package manager
```bash
yarn add @nhost/nhost-js
```
:::caution attention
You might have to edit the `package.json` file and add/change the `type` object to `module` (`"type": "module"`).
:::
---

View File

@@ -3,6 +3,9 @@ title: 'Nhost CLI'
sidebar_position: 3
---
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
Nhost CLI lets you run Nhost's development environment locally on macOS, Linux and Windows.
---
@@ -28,10 +31,23 @@ To run serverless functions locally, you must have the appropriate runtimes inst
For Node.js, you will also need to have [express](https://www.npmjs.com/package/express) installed in your repository:
<Tabs>
<TabItem value="npm" label="npm" default>
```bash
npm install --save-dev express @types/express
```
</TabItem>
<TabItem value="yarn" label="Yarn">
```bash
yarn add -D express @types/express
```
</TabItem>
</Tabs>
[Read more about runtimes](/platform/serverless-functions)
---

View File

@@ -11,7 +11,7 @@ sidebar_position: 3
| HASURA_GRAPHQL_DATABASE_URL**\*** | [PostgreSQL connection URI](https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNSTRING). Required to inject the `auth` schema into the database. | |
| HASURA_GRAPHQL_GRAPHQL_URL**\*** | Hasura GraphQL endpoint. Required to manipulate account data. For instance: `https://graphql-engine:8080/v1/graphql` | |
| HASURA_GRAPHQL_ADMIN_SECRET**\*** | Hasura GraphQL Admin Secret. Required to manipulate account data. | |
| AUTH_HOST | Server host. [Docs](http://expressjs.com/en/5x/api.html#app.listen) | `0.0.0.0` |
| AUTH_HOST | Server host. This option is available until Hasura-auth `v0.6.0`. [Docs](http://expressjs.com/en/5x/api.html#app.listen) | `0.0.0.0` |
| AUTH_PORT | Server port. [Docs](http://expressjs.com/en/5x/api.html#app.listen) | `4000` |
| AUTH_SERVER_URL | Server URL of where Hasura Backend Plus is running. This value is to used as a callback in email templates and for the OAuth authentication process. | |
| AUTH_CLIENT_URL | URL of your frontend application. Used to redirect users to the right page once actions based on emails or OAuth succeed. | |

View File

@@ -3,20 +3,28 @@ title: 'Configuration'
sidebar_position: 2
---
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
## Installation
With yarn:
<Tabs>
<TabItem value="npm" label="npm" default>
```bash
yarn add @nhost/react @nhost/nextjs
npm install @nhost/react @nhost/nextjs graphql
```
With Npm:
</TabItem>
<TabItem value="yarn" label="Yarn">
```bash
npm install @nhost/react @nhost/nextjs
yarn add @nhost/react @nhost/nextjs graphql
```
</TabItem>
</Tabs>
---
## Configuration

View File

@@ -3,20 +3,28 @@ title: 'Apollo GraphQL'
sidebar_position: 4
---
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
## Installation
With Yarn:
<Tabs>
<TabItem value="npm" label="npm" default>
```bash
yarn add @nhost/react @nhost/react-apollo @apollo/client
npm install @nhost/react @nhost/react-apollo @apollo/client graphql
```
With Npm:
</TabItem>
<TabItem value="yarn" label="Yarn">
```bash
npm install @nhost/react @nhost/react-apollo @apollo/client
yarn add @nhost/react @nhost/react-apollo @apollo/client graphql
```
</TabItem>
</Tabs>
## Configuration
Let's add a `NhostApolloProvider`. Make sure the Apollo Provider is nested into `NhostReactProvider`, as it will need the Nhost context to determine the authentication headers to be sent to the GraphQL endpoint.

View File

@@ -3,20 +3,28 @@ title: 'Getting started'
sidebar_position: 1
---
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
## Installation
With Yarn:
<Tabs>
<TabItem value="npm" label="npm" default>
```bash
yarn add @nhost/react
npm install @nhost/react graphql
```
With npm:
</TabItem>
<TabItem value="yarn" label="Yarn">
```bash
npm install @nhost/react
yarn add @nhost/react graphql
```
</TabItem>
</Tabs>
---
## Configuration

View File

@@ -3,6 +3,9 @@ title: 'Overview'
sidebar_position: 1
---
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
Nhost SDK is the primary way of interacting with your Nhost app. It exposes a standard interface for each of the following services:
- GraphQL
@@ -14,10 +17,23 @@ Nhost SDK is the primary way of interacting with your Nhost app. It exposes a st
Install the dependency:
<Tabs>
<TabItem value="npm" label="npm" default>
```bash
npm install @nhost/nhost-js
npm install @nhost/nhost-js graphql
```
</TabItem>
<TabItem value="yarn" label="Yarn">
```bash
yarn add @nhost/nhost-js graphql
```
</TabItem>
</Tabs>
Then import and initialize a single `nhost` instance in your code:
```js

View File

@@ -1,5 +1,12 @@
# @nhost/apollo
## 0.4.1
### Patch Changes
- Updated dependencies [0b1cb62]
- @nhost/core@0.3.11
## 0.4.0
### Minor Changes

View File

@@ -1,6 +1,6 @@
{
"name": "@nhost/apollo",
"version": "0.4.0",
"version": "0.4.1",
"description": "Nhost Apollo Client library",
"license": "MIT",
"keywords": [

View File

@@ -1,5 +1,14 @@
# @nhost/core
## 0.3.11
### Patch Changes
- 0b1cb62: Use native `BroadcastChannel` instead of the `broadcast-channel` package
The `broadcast-channel` depends on `node-gyp-build`, which can cause issues when deploying on Vercel as it is a native dependency.
The added value of `broadcast-channel` is to be able to communicate the change of authentication state accross processes in a NodeJs / Electron environment, but this is considered an edge case for now.
See [Vercel official documentation](https://vercel.com/support/articles/why-does-my-serverless-function-work-locally-but-not-when-deployed#native-dependencies).
## 0.3.10
### Patch Changes

View File

@@ -1,6 +1,6 @@
{
"name": "@nhost/core",
"version": "0.3.10",
"version": "0.3.11",
"description": "Nhost core client library",
"license": "MIT",
"keywords": [
@@ -50,7 +50,6 @@
],
"dependencies": {
"axios": "^0.25.0",
"broadcast-channel": "^4.10.0",
"js-cookie": "^3.0.1",
"xstate": "^4.30.5"
}

View File

@@ -1,4 +1,3 @@
import { BroadcastChannel } from 'broadcast-channel'
import { interpret } from 'xstate'
import { MIN_TOKEN_REFRESH_INTERVAL } from './constants'
@@ -45,11 +44,11 @@ export class AuthClient {
}
if (typeof window !== 'undefined' && autoSignIn) {
this._channel = new BroadcastChannel<string>('nhost')
this._channel = new BroadcastChannel('nhost')
this._channel.addEventListener('message', (token) => {
const existingToken = this.interpreter?.state.context.refreshToken
if (this.interpreter && token !== existingToken) {
this.interpreter.send({ type: 'TRY_TOKEN', token })
if (this.interpreter && token.data !== existingToken) {
this.interpreter.send({ type: 'TRY_TOKEN', token: token.data })
}
})
}

View File

@@ -1,5 +1,4 @@
import type { AxiosRequestConfig, AxiosResponse } from 'axios'
import { BroadcastChannel } from 'broadcast-channel'
import { assign, createMachine, send } from 'xstate'
import {

View File

@@ -1,5 +1,12 @@
# @nhost/hasura-auth-js
## 1.0.12
### Patch Changes
- Updated dependencies [0b1cb62]
- @nhost/core@0.3.11
## 1.0.11
### Patch Changes

View File

@@ -1,6 +1,6 @@
{
"name": "@nhost/hasura-auth-js",
"version": "1.0.11",
"version": "1.0.12",
"description": "Hasura-auth client",
"license": "MIT",
"keywords": [

View File

@@ -1,5 +1,12 @@
# @nhost/nextjs
## 1.0.15
### Patch Changes
- @nhost/nhost-js@1.1.1
- @nhost/react@0.5.4
## 1.0.14
### Patch Changes

View File

@@ -1,6 +1,6 @@
{
"name": "@nhost/nextjs",
"version": "1.0.14",
"version": "1.0.15",
"description": "Nhost NextJS library",
"license": "MIT",
"keywords": [

View File

@@ -1,5 +1,11 @@
# @nhost/nhost-js
## 1.1.1
### Patch Changes
- @nhost/hasura-auth-js@1.0.12
## 1.1.0
### Minor Changes

View File

@@ -1,6 +1,6 @@
{
"name": "@nhost/nhost-js",
"version": "1.1.0",
"version": "1.1.1",
"description": "Nhost JavaScript SDK",
"license": "MIT",
"keywords": [

View File

@@ -1,5 +1,12 @@
# @nhost/react-apollo
## 4.0.14
### Patch Changes
- @nhost/apollo@0.4.1
- @nhost/react@0.5.4
## 4.0.13
### Patch Changes

View File

@@ -1,6 +1,6 @@
{
"name": "@nhost/react-apollo",
"version": "4.0.13",
"version": "4.0.14",
"description": "Nhost React Apollo client",
"license": "MIT",
"keywords": [

View File

@@ -1,5 +1,11 @@
# @nhost/react
## 0.5.4
### Patch Changes
- @nhost/nhost-js@1.1.1
## 0.5.3
### Patch Changes

View File

@@ -1,6 +1,6 @@
{
"name": "@nhost/react",
"version": "0.5.3",
"version": "0.5.4",
"description": "Nhost React library",
"license": "MIT",
"keywords": [

62
pnpm-lock.yaml generated
View File

@@ -134,12 +134,10 @@ importers:
packages/core:
specifiers:
axios: ^0.25.0
broadcast-channel: ^4.10.0
js-cookie: ^3.0.1
xstate: ^4.30.5
dependencies:
axios: 0.25.0
broadcast-channel: 4.10.0
js-cookie: 3.0.1
xstate: 4.30.6
@@ -2901,6 +2899,7 @@ packages:
engines: {node: '>=6.9.0'}
dependencies:
regenerator-runtime: 0.13.9
dev: true
/@babel/runtime/7.17.8:
resolution: {integrity: sha512-dQpEpK0O9o6lj6oPu0gRDbbnk+4LeHlNcBpspf6Olzt3GIX4P1lWF1gS+pHLDFlaJvbR6q7jCfQ08zA4QJBnmA==}
@@ -5808,11 +5807,6 @@ packages:
is-windows: 1.0.2
dev: true
/big-integer/1.6.51:
resolution: {integrity: sha512-GPEid2Y9QU1Exl1rpO9B2IPJGHPSupF5GnVIP0blYvNOMer2bTvSWs1jGOUg04hTmu67nmLsQ9TBo1puaotBHg==}
engines: {node: '>=0.6'}
dev: false
/big.js/5.2.2:
resolution: {integrity: sha512-vyL2OymJxmarO8gxMr0mhChsO9QGwhynfuu4+MHTAW6czfq9humCB7rKpUjDd9YUiDPU4mzpyupFSvOClAwbmQ==}
dev: false
@@ -5900,19 +5894,6 @@ packages:
wcwidth: 1.0.1
dev: true
/broadcast-channel/4.10.0:
resolution: {integrity: sha512-hOUh312XyHk6JTVyX9cyXaH1UYs+2gHVtnW16oQAu9FL7ALcXGXc/YoJWqlkV8vUn14URQPMmRi4A9q4UrwVEQ==}
dependencies:
'@babel/runtime': 7.17.2
detect-node: 2.1.0
microseconds: 0.2.0
nano-time: 1.0.0
oblivious-set: 1.0.0
p-queue: 6.6.2
rimraf: 3.0.2
unload: 2.3.1
dev: false
/browser-process-hrtime/1.0.0:
resolution: {integrity: sha512-9o5UecI3GhkpM6DrXr69PblIuWxPKk9Y0jHBRhdocZ2y7YECBFCsHm79Pr3OyR2AvjhDkabFJaDJMYRazHgsow==}
dev: true
@@ -11099,10 +11080,6 @@ packages:
picomatch: 2.3.1
dev: false
/microseconds/0.2.0:
resolution: {integrity: sha512-n7DHHMjR1avBbSpsTBj6fmMGh2AGrifVV4e+WYc3Q9lO+xnSZ3NyhcBND3vzzatt05LFhoKFRxrIyklmLlUtyA==}
dev: false
/microsoft-capitalize/1.0.5:
resolution: {integrity: sha512-iqDMU9J643BHg8Zp7EMZNLTp6Pgs2f1S2SMnCW2VlUqMs17xCZ5vwVjalBJEGVcUfG+/1ePqeEGcMW3VfzHK5A==}
engines: {node: '>= 10'}
@@ -11305,12 +11282,6 @@ packages:
resolution: {integrity: sha512-8ZtvEnA2c5aYCZYd1cvgdnU6cqwixRoYg70xPLWUws5ORTa/lnw+u4amixRS/Ac5U5mQVgp9pnlSUnbNWFaWZQ==}
dev: true
/nano-time/1.0.0:
resolution: {integrity: sha1-sFVPaa2J4i0JB/ehKwmTpdlhN+8=}
dependencies:
big-integer: 1.6.51
dev: false
/nanoid/3.3.1:
resolution: {integrity: sha512-n6Vs/3KGyxPQd6uO0eH4Bv0ojGSUvuLlIHtC3Y0kEO23YRge8H9x1GCzLn28YX0H66pMkxuaeESFq4tKISKwdw==}
engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1}
@@ -11574,10 +11545,6 @@ packages:
es-abstract: 1.19.1
dev: true
/oblivious-set/1.0.0:
resolution: {integrity: sha512-z+pI07qxo4c2CulUHCDf9lcqDlMSo72N/4rLUpRXf6fu+q8vjt8y0xS+Tlf8NTJDdTXHbdeO1n3MlbctwEoXZw==}
dev: false
/obuf/1.1.2:
resolution: {integrity: sha512-PX1wu0AmAdPqOL1mWhqmlOd8kOIZQwGZw6rh7uby9fTc5lhaOWFLX3I6R1hrF9k3zUY40e6igsLGkDXK92LJNg==}
dev: false
@@ -11671,11 +11638,6 @@ packages:
p-map: 2.1.0
dev: true
/p-finally/1.0.0:
resolution: {integrity: sha1-P7z7FbiZpEEjs0ttzBi3JDNqLK4=}
engines: {node: '>=4'}
dev: false
/p-limit/1.3.0:
resolution: {integrity: sha512-vvcXsLAJ9Dr5rQOPk7toZQZJApBl2K4J6dANSsEuh6QI41JYcsS/qhTGa9ErIUUgK3WNQoJYvylxvjqmiqEA9Q==}
engines: {node: '>=4'}
@@ -11732,14 +11694,6 @@ packages:
dependencies:
aggregate-error: 3.1.0
/p-queue/6.6.2:
resolution: {integrity: sha512-RwFpb72c/BhQLEXIZ5K2e+AhgNVmIejGlTgiB9MzZ0e93GRvqZ7uSi0dvRF7/XIXDeNkra2fNHBxTyPDGySpjQ==}
engines: {node: '>=8'}
dependencies:
eventemitter3: 4.0.7
p-timeout: 3.2.0
dev: false
/p-retry/4.6.1:
resolution: {integrity: sha512-e2xXGNhZOZ0lfgR9kL34iGlU8N/KO0xZnQxVEwdeOvpqNDQfdnxIYizvWtK8RglUa3bGqI8g0R/BdfzLMxRkiA==}
engines: {node: '>=8'}
@@ -11748,13 +11702,6 @@ packages:
retry: 0.13.1
dev: false
/p-timeout/3.2.0:
resolution: {integrity: sha512-rhIwUycgwwKcP9yTOOFK/AKsAopjjCakVqLHePO3CC6Mir1Z99xT+R63jZxAT5lFZLa2inS5h+ZS2GvR99/FBg==}
engines: {node: '>=8'}
dependencies:
p-finally: 1.0.0
dev: false
/p-try/1.0.0:
resolution: {integrity: sha1-y8ec26+P1CKOE/Yh8rGiN8GyB7M=}
engines: {node: '>=4'}
@@ -14712,13 +14659,6 @@ packages:
resolution: {integrity: sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ==}
engines: {node: '>= 10.0.0'}
/unload/2.3.1:
resolution: {integrity: sha512-MUZEiDqvAN9AIDRbbBnVYVvfcR6DrjCqeU2YQMmliFZl9uaBUjTkhuDQkBiyAy8ad5bx1TXVbqZ3gg7namsWjA==}
dependencies:
'@babel/runtime': 7.17.2
detect-node: 2.1.0
dev: false
/unpipe/1.0.0:
resolution: {integrity: sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=}
engines: {node: '>= 0.8'}