Skip to content

Commit 1b73742

Browse files
committed
chore: move credentials to env
1 parent 8951068 commit 1b73742

File tree

6 files changed

+56
-20
lines changed

6 files changed

+56
-20
lines changed

examples/getting-started/.env.example

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
NG_CLIENT_ID=<YOUR_NAVIGRAPH_CLIENT_ID>
2+
NG_CLIENT_SECRET=<YOUR_NAVIGRAPH_CLIENT_SECRET>

examples/getting-started/.gitignore

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,9 @@
11
# Logs
2-
logs
3-
*.log
4-
npm-debug.log*
52
yarn-debug.log*
63
yarn-error.log*
7-
pnpm-debug.log*
8-
lerna-debug.log*
94

105
node_modules
116
dist
12-
dist-ssr
137
*.local
148

159
# Editor directories and files

examples/getting-started/README.md

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,34 @@
11
# Navigraph SDK Example
22

3-
WIP - more coming soon
3+
## Installation
4+
5+
Clone this repository to your local machine:
6+
7+
```bash
8+
git clone https://github.com/Navigraph/navigraph-js-sdk.git
9+
10+
cd navigraph-js-sdk/examples/getting-started
11+
```
12+
13+
Install project dependencies using Yarn:
14+
15+
```bash
16+
yarn
17+
```
18+
19+
Create an `.env.local` file in the root of your project and add the following environment variables:
20+
21+
```env
22+
NG_CLIENT_ID=your_client_id
23+
NG_CLIENT_SECRET=your_client_secret
24+
```
25+
26+
Make sure to replace `your_client_id` and `your_client_secret` with your real credentials. These variables are required for the project to function correctly.
27+
28+
## Running the Project
29+
30+
To start the development server, run the following command:
31+
32+
```bash
33+
yarn dev
34+
```
Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
import { initializeApp, Scope, NavigraphApp } from "@navigraph/app";
2-
import { getAuth } from "@navigraph/auth";
3-
import { getChartsAPI } from "@navigraph/charts";
1+
import { initializeApp, NavigraphApp, Scope } from "@navigraph/app"
2+
import { getAuth } from "@navigraph/auth"
3+
import { getChartsAPI } from "@navigraph/charts"
44

55
const config: NavigraphApp = {
6-
clientId: "<YOUR_NAVIGRAPH_CLIENT_ID>",
7-
clientSecret: "<YOUR_NAVIGRAPH_CLIENT_SECRET>",
6+
clientId: import.meta.env.NG_CLIENT_ID,
7+
clientSecret: import.meta.env.NG_CLIENT_SECRET,
88
scopes: [Scope.CHARTS, Scope.FMSDATA],
9-
};
9+
}
1010

1111
if (config.clientId.includes("<")) {
12-
alert("Please add your client credentials in lib/navigraph.ts.");
12+
alert("Please add your client credentials in lib/navigraph.ts.")
1313
}
1414

15-
initializeApp(config);
15+
initializeApp(config)
1616

17-
export const auth = getAuth();
18-
export const charts = getChartsAPI();
17+
export const auth = getAuth()
18+
export const charts = getChartsAPI()
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,10 @@
11
/// <reference types="vite/client" />
2+
3+
interface ImportMetaEnv {
4+
readonly NG_CLIENT_ID: string
5+
readonly NG_CLIENT_SECRET: string
6+
}
7+
8+
interface ImportMeta {
9+
readonly env: ImportMetaEnv
10+
}
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { defineConfig } from 'vite'
2-
import react from '@vitejs/plugin-react'
1+
import react from "@vitejs/plugin-react"
2+
import { defineConfig } from "vite"
33

4-
// https://vitejs.dev/config/
54
export default defineConfig({
65
plugins: [react()],
6+
envPrefix: "NG_",
77
})

0 commit comments

Comments
 (0)