Skip to content

Commit 760fffd

Browse files
committed
DX-1239 Autoformat code on commit
1 parent 48e3eaa commit 760fffd

File tree

9 files changed

+39
-38
lines changed

9 files changed

+39
-38
lines changed

.husky/pre-commit

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env sh
2+
. "$(dirname -- "$0")/_/husky.sh"
3+
4+
yarn format

.prettierignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
dist
2+
docs-out

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
"build": "turbo run build",
1414
"dev": "turbo run dev",
1515
"test": "turbo run test",
16-
"format": "prettier -w ./packages"
16+
"format": "prettier -w ./packages",
17+
"prepare": "husky install"
1718
},
1819
"author": "",
1920
"license": "MIT",
@@ -28,6 +29,7 @@
2829
"@types/jest": "^28.1.7",
2930
"esbuild": "^0.15.5",
3031
"esbuild-jest": "^0.5.0",
32+
"husky": "^8.0.1",
3133
"turbo": "^1.4.5"
3234
}
3335
}

packages/typescript-node/docs-theme/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export class MiroThemeContext extends DefaultThemeRenderContext {
5050
title: 'Options',
5151
url: 'classes/index.Options.html',
5252
},
53-
{ title: 'Storage' },
53+
{title: 'Storage'},
5454
]
5555

5656
const Navigation = ({items}: {items: Item[]}) => {

packages/typescript-node/docs/implementing-storage.md

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ In this example we implement a storage that is using Redis as a backend. We use
1313
const redis = require('redis')
1414

1515
class RedisStorage {
16-
1716
// This method will initiate a connection to redis
1817
// On subsequent calls it will return the same redis connection
1918
async _getClient() {
@@ -51,7 +50,7 @@ This class can then be used in the Miro constructor by passing it as a parameter
5150

5251
```javascript
5352
const miro = new Miro({
54-
storage: new RedisStorage()
53+
storage: new RedisStorage(),
5554
})
5655
```
5756

@@ -63,13 +62,10 @@ When using express framework with the session middleware, we can reuse the sessi
6362
// Setup session middlware before: app.use(session({...}))
6463

6564
app.use((req, res, next) => {
66-
6765
// Create a separate Miro instance for each request
6866
req.miro = new Miro({
69-
7067
// Define storage implementation inline
7168
storage: {
72-
7369
// Load Miro state from the session object (if any)
7470
get(_userId) {
7571
return req.session.state
@@ -78,8 +74,8 @@ app.use((req, res, next) => {
7874
// Store Miro state in the session object
7975
set(_userId, state) {
8076
req.session.state = state
81-
}
82-
}
77+
},
78+
},
8379
})
8480

8581
next()

packages/typescript-node/docs/quickstart-auth.md

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,38 @@
1+
# Miro Node.js client quick start guide with OAuth 2.0 and Express
2+
3+
Build a simple app based on the Miro Node.js client library, the OAuth 2.0 code grant flow, and the Express JavaScript web framework.
4+
15
## Goal
26

37
This quick start guide helps you familiarize yourself with the [Miro REST API 2.0](https://developers.miro.com/reference/api-reference) and the [OAuth 2.0 authorization code grant flow](https://www.oauth.com/oauth2-servers/server-side-apps/authorization-code/) by building a simple app that uses the Miro Node.js client library.
48

59
The guide also walks you through setting up a web server based on the [Express](https://expressjs.com/) framework. Express uses the Miro Node.js client library to implement authorization and token management for users.
610

7-
At the end of the guide, you'll have built a simple app that prompts users for installation (this triggers the OAuth authorization flow), and then prints a list of all the boards the current user has access to.
11+
At the end of the guide, you'll have built a simple app that prompts users for installation )this triggers the OAuth authorization flow), and then prints a list of all the boards the current user has access to.
812

913
## Prerequisites
1014

1115
Before you begin, make sure that:
1216

1317
- You have a [Miro account](https://miro.com/signup/).
1418
- You're [signed in to Miro](https://miro.com/login/).
15-
- Your Miro account has a [Developer team](https://developers.miro.com/docs/create-a-developer-team).
19+
- Your Miro account has a [Developer team](https://developers.miro.com/docs/rest-api-build-your-first-hello-world-app#step-1-create-a-developer-team-in-miro).
1620
- Your development environment includes [Node.js 14.15 or a later version](https://nodejs.org/en/download/). \
1721
To check the Node.js version on your system:
1822
1. Open a terminal session.
1923
2. In the terminal, run `node --version`.
2024

21-
It's a good idea to already go through the following steps in your Miro account settings:
25+
It's a good to already go through the following steps in your Miro account settings:
2226

23-
1. [Create your app in Miro](https://developers.miro.com/docs/rest-api-build-your-first-hello-world-app#step-1-create-your-app-in-miro)
24-
2. [Configure your app in Miro](https://developers.miro.com/docs/rest-api-build-your-first-hello-world-app#step-2-configure-your-app-in-miro)
27+
1. [Create your app in Miro](https://developers.miro.com/docs/rest-api-build-your-first-hello-world-app#step-2-create-your-app-in-miro)
28+
2. [Configure your app in Miro](https://developers.miro.com/docs/rest-api-build-your-first-hello-world-app#step-3-configure-your-app-in-miro)
2529
3. In your app settings, go to **Redirect URI for OAuth2.0**; in the input field, enter the following URL: `http://127.0.0.1:4000/auth/miro/callback`; click **Add** to add it to the app [redirect URI list](https://www.oauth.com/oauth2-servers/redirect-uris/).
2630
4. In your app settings, go to **App Credentials**, and save the values assigned to **Client ID** and **Client secret**. \
2731
You'll need to use these values later.
2832

2933
## Build the app
3034

3135
After configuring the options in the previous section, you can start building the app.
32-
3336
### Step 1: create the project directory
3437

3538
1. Open a terminal session.
@@ -54,14 +57,14 @@ npm init -y
5457
Install the Miro Node.js client library, the Express web framework, and its dependencies:
5558

5659
```bash
57-
npm install @mirohq/miro-api express express-session
60+
npm install @mirohq/miro-node express express-session
5861
```
5962

6063
### Step 4: import and initialize dependencies
6164

6265
Now it's time to take care of the initial setup of your project:
6366

64-
- Create an `index.js` file.
67+
- Create the `index.js` file.
6568
- Import the dependencies that the app needs to run.
6669
- Initialize the imported resources.
6770

@@ -70,7 +73,7 @@ Now it's time to take care of the initial setup of your project:
7073
To work with the Miro Node.js client library and the Express web framework, you need to import and initialize the corresponding libraries:
7174

7275
```javascript
73-
const {Miro} = require('@mirohq/miro-api')
76+
const {Miro} = require('@mirohq/miro-node')
7477
const express = require('express')
7578
const session = require('express-session')
7679
```
@@ -100,14 +103,10 @@ app.use(
100103
)
101104
```
102105

103-
> 🚧
104-
>
105-
> In production deployments, replace the secret with a randomly generated string.
106+
⚠️ In production deployments, replace the secret with a randomly generated string. ⚠️
106107

107-
> 📘
108-
>
109-
> For the sake of simplicity, the quick start guide identifies users with session IDs.
110-
> In production deployments, use actual user IDs, separate from session IDs. This avoids repeatedly prompting users to reinstall the app that they already installed in a previous, different session.
108+
ℹ️ For the sake of simplicity, the quick start guide identifies users with session IDs. \
109+
In production deployments, use actual user IDs, separate from session IDs. This avoids repeatedly prompting users to reinstall the app that they already installed in a previous, different session. ℹ️
111110

112111
### Step 5: redirect new users to the authorization page
113112

@@ -203,13 +202,13 @@ Then, execute `index.js` with Node.js to start the app:
203202
node index.js
204203
```
205204

206-
To verify that the app is running, open [http://127.0.0.1:4000](http://127.0.0.1:4000) in a web browser.
205+
To verify that the app is running, open http://127.0.0.1:4000 in a web browser.
207206

208207
## Complete example
209208

210209
```javascript
211210
const express = require('express')
212-
const {Miro} = require('@mirohq/miro-api')
211+
const {Miro} = require('@mirohq/miro-node')
213212
const session = require('express-session')
214213

215214
const miro = new Miro()
@@ -249,9 +248,3 @@ app.get('/auth/miro/callback', async (req, res) => {
249248

250249
app.listen(4000, () => console.log('Started server on http://127.0.0.1:4000'))
251250
```
252-
253-
## See also
254-
255-
- [`Miro` object reference documentation](https://miroapp.github.io/api-clients/classes/index.Miro.html)
256-
- [`MiroApi` object reference documentation](https://miroapp.github.io/api-clients/classes/index.MiroApi.html)
257-
- [`Storage` interface reference documentation](https://miroapp.github.io/api-clients/interfaces/index._internal_.Storage.html)

packages/typescript-node/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import assert from 'assert'
22
import fetch from 'node-fetch'
33
import {HttpError, Logger, MiroApi as MiroLowlevelApi} from './api'
4-
import { InMemoryStorage, Storage } from './storage'
4+
import {InMemoryStorage, Storage} from './storage'
55

66
const defaultBasePath = 'https://api.miro.com'
77

packages/typescript-node/storage.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ExternalUserId } from './index'
1+
import {ExternalUserId} from './index'
22

33
export type Awaitable<T> = Promise<T> | T
44

@@ -15,7 +15,7 @@ export interface Storage {
1515
}
1616

1717
export class InMemoryStorage implements Storage {
18-
storage: Record<string, State|undefined>
18+
storage: Record<string, State | undefined>
1919

2020
constructor() {
2121
this.storage = {}
@@ -25,8 +25,7 @@ export class InMemoryStorage implements Storage {
2525
return this.storage[userId]
2626
}
2727

28-
async set(userId: ExternalUserId, state: State|undefined) {
28+
async set(userId: ExternalUserId, state: State | undefined) {
2929
this.storage[userId] = state
3030
}
3131
}
32-

yarn.lock

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2622,6 +2622,11 @@ human-signals@^2.1.0:
26222622
resolved "https://registry.yarnpkg.com/human-signals/-/human-signals-2.1.0.tgz#dc91fcba42e4d06e4abaed33b3e7a3c02f514ea0"
26232623
integrity sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw==
26242624

2625+
husky@^8.0.1:
2626+
version "8.0.1"
2627+
resolved "https://registry.yarnpkg.com/husky/-/husky-8.0.1.tgz#511cb3e57de3e3190514ae49ed50f6bc3f50b3e9"
2628+
integrity sha512-xs7/chUH/CKdOCs7Zy0Aev9e/dKOMZf3K1Az1nar3tzlv0jfqnYtu235bstsWTmXOR0EfINrPa97yy4Lz6RiKw==
2629+
26252630
[email protected], iconv-lite@^0.4.24:
26262631
version "0.4.24"
26272632
resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.24.tgz#2022b4b25fbddc21d2f524974a474aafe733908b"

0 commit comments

Comments
 (0)