Skip to content

Commit 2288736

Browse files
Chris KhanChris Khan
authored andcommitted
feat: improve local development experience and setup documentation
- Add LOCAL_LAYER, PORT, and HOST configuration to .env.example - Set LOCAL_LAYER=true by default (use vendored injective-ui layer) - Set HOST=127.0.0.1 by default for better security - Rename dev:local to dev:remote (since local is now default) - Expand README with beginner-friendly installation guides - Add Node.js and Yarn installation verification steps - Use collapsible sections to keep README organized - Include troubleshooting for common setup issues
1 parent 872e2b5 commit 2288736

4 files changed

Lines changed: 164 additions & 19 deletions

File tree

.env.example

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
## Development Server Configuration
2+
# Use the local vendored injective-ui layer (set to false to use remote layer)
3+
LOCAL_LAYER=true
4+
# Development server port
5+
PORT=3000
6+
# Development server host (use 127.0.0.1 for localhost-only, 0.0.0.0 for network access)
7+
HOST=127.0.0.1
8+
19
## Public
210

311
# The title of your dex

README.md

Lines changed: 152 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,40 +16,176 @@ _Perp Dex As A Service - Powered by Injective_
1616

1717
This repository is self‑contained and vendors the shared `injective-ui` layer, so you can run it without fetching external layers.
1818

19-
> Prerequisites
20-
>
21-
> - Node 20 LTS
22-
> - nvm: `nvm install 20 && nvm use 20` (auto‑selected via `.nvmrc`)
23-
> - asdf: `asdf install` (reads `.tool-versions`/`.node-version`), then `asdf local nodejs 20`
24-
> - Volta: `curl https://get.volta.sh | bash && volta install node@20`
25-
> - Yarn Classic (v1)
26-
> - Using Corepack (recommended): `corepack enable && corepack prepare yarn@1.22.22 --activate`
27-
> - Or install globally: `npm i -g yarn@1.22.22`
19+
### Prerequisites
20+
21+
#### 1. Install Node.js 20 LTS
22+
23+
**First, check if you already have Node.js:**
24+
```bash
25+
node --version
26+
```
27+
28+
If you see a version number starting with `v20.x.x`, you're good! Skip to step 2.
29+
30+
If you see `command not found` or a different version, install Node.js 20 using one of these methods:
31+
32+
<details>
33+
<summary><strong>Method 1: Direct Download (easiest for beginners)</strong></summary>
34+
35+
1. Visit [nodejs.org/download](https://nodejs.org/en/download/)
36+
2. Download the **LTS version 20.x** installer for your operating system:
37+
- **macOS:** Download the `.pkg` file and run it
38+
- **Windows:** Download the `.msi` file and run it
39+
- **Linux:** Use your package manager or download the binary
40+
3. Follow the installation wizard (accept defaults)
41+
4. Verify installation:
42+
```bash
43+
node --version
44+
# Should output: v20.x.x
45+
```
46+
```bash
47+
npm --version
48+
# Should output: 10.x.x (npm comes with Node.js)
49+
```
50+
51+
</details>
52+
53+
<details>
54+
<summary><strong>Method 2: Using nvm (recommended for developers - macOS/Linux)</strong></summary>
55+
56+
nvm lets you easily switch between Node.js versions.
57+
58+
1. Install nvm:
59+
```bash
60+
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash
61+
```
62+
2. Close and reopen your terminal, then run:
63+
```bash
64+
nvm install 20
65+
nvm use 20
66+
```
67+
3. Verify:
68+
```bash
69+
node --version
70+
# Should output: v20.x.x
71+
```
72+
73+
</details>
74+
75+
<details>
76+
<summary><strong>Method 3: Using asdf (for multi-language version management)</strong></summary>
77+
78+
```bash
79+
# Install asdf first if you don't have it
80+
git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.14.0
81+
82+
# Add to your shell profile (~/.bashrc, ~/.zshrc, etc.)
83+
echo '. "$HOME/.asdf/asdf.sh"' >> ~/.zshrc
84+
85+
# Restart terminal, then install Node.js
86+
asdf plugin add nodejs
87+
asdf install nodejs 20
88+
asdf local nodejs 20
89+
```
90+
91+
</details>
92+
93+
<details>
94+
<summary><strong>Method 4: Using Volta (cross-platform version manager)</strong></summary>
95+
96+
```bash
97+
# Install Volta
98+
curl https://get.volta.sh | bash
99+
100+
# Restart terminal, then install Node.js
101+
volta install node@20
102+
```
103+
104+
</details>
105+
106+
#### 2. Install Yarn Classic (v1.22.22)
107+
108+
**First, check if you already have Yarn:**
109+
```bash
110+
yarn --version
111+
```
112+
113+
If you see a version starting with `1.x.x`, you're good! Skip to Installation.
114+
115+
If you see `command not found` or version `2.x`/`3.x`/`4.x`, install Yarn Classic:
116+
117+
<details>
118+
<summary><strong>Method 1: Using Corepack (recommended - built into Node.js 16.9+)</strong></summary>
119+
120+
```bash
121+
# Enable Corepack
122+
corepack enable
123+
124+
# Install Yarn 1.22.22
125+
corepack prepare yarn@1.22.22 --activate
126+
127+
# Verify
128+
yarn --version
129+
# Should output: 1.22.22
130+
```
131+
132+
> **Note:** If `corepack enable` fails with permission errors, try `sudo corepack enable` (macOS/Linux) or run as Administrator (Windows).
133+
134+
</details>
135+
136+
<details>
137+
<summary><strong>Method 2: Using npm (if Corepack doesn't work)</strong></summary>
138+
139+
```bash
140+
# Install globally
141+
npm install -g yarn@1.22.22
142+
143+
# Verify
144+
yarn --version
145+
# Should output: 1.22.22
146+
```
147+
148+
> **Note:** If you get permission errors on macOS/Linux, try `sudo npm install -g yarn@1.22.22`
149+
150+
</details>
151+
152+
### Installation
28153

29154
1. Clone the repository
30155

31156
```bash
32157
git clone git@github.com:InjectiveLabs/pdaas.git
33158
cd pdaas
159+
```
160+
161+
2. Install dependencies
162+
163+
```bash
34164
yarn
35165
```
36166

37-
2. Optional: copy environment variables template and adjust values
167+
> **Note:** If you get `yarn: command not found`, go back to the Prerequisites section above and install Yarn.
168+
169+
3. Copy environment variables template and configure for local development
38170

39171
```bash
40172
cp .env.example .env
41173
```
42174

43-
3. Run the app locally (uses the vendored Injective UI layer)
175+
Edit `.env` and set your configuration. The vendored `injective-ui` layer is used by default (`LOCAL_LAYER=true`).
176+
177+
4. Run the app locally
44178

45179
```bash
46-
LOCAL_LAYER=true PORT=3000 HOST=0.0.0.0 yarn dev
180+
yarn dev
47181
```
48182

49-
Notes:
50-
- `LOCAL_LAYER=true` forces Nuxt to use the vendored `injective-ui` layer in this repo instead of fetching `github:InjectiveLabs/injective-ui/layer#master`.
51-
- You can omit `PORT`/`HOST` if you prefer defaults; they are shown here to bind on `http://localhost:3000`.
52-
- If you previously saw “Cannot extend config from github:InjectiveLabs/injective-ui/layer#master”, ensure `LOCAL_LAYER=true` is set when running locally.
183+
The dev server will start on `http://127.0.0.1:3000` (configurable via `PORT` and `HOST` in `.env`).
184+
185+
**Notes:**
186+
- By default, the app uses the **vendored** `injective-ui` layer from this repo (faster, offline-capable).
187+
- To use the **remote** layer from GitHub instead, set `LOCAL_LAYER=false` in `.env` or run `yarn dev:remote`.
188+
- For security, the dev server binds to `127.0.0.1` (localhost-only). Use `HOST=0.0.0.0` in `.env` if you need network access.
53189

54190
## 📖 Documentation
55191

nuxt.config.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { head, hooks } from './nuxt-config'
22

3-
const isLocalLayer = process.env.LOCAL_LAYER === 'true'
3+
// Default to using the local vendored layer unless explicitly set to 'false'
4+
const isLocalLayer = process.env.LOCAL_LAYER !== 'false'
45
const isProduction = process.env.NODE_ENV === 'production'
56

67
export default defineNuxtConfig({

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"fetch:data": "ts-node -P tsconfig-script.json ./scripts/marketMap.ts && ts-node -P tsconfig-script.json ./scripts/tokens.ts && ts-node -P tsconfig-script.json ./scripts/restriction.ts && ts-node -P tsconfig-script.json ./scripts/swap.ts && ts-node -P tsconfig-script.json ./scripts/denom.ts",
1616
"github:version": "ts-node -P tsconfig-script.json ./scripts/github.ts",
1717
"dev": "nuxi dev",
18-
"dev:local": "LOCAL_LAYER=true nuxi dev",
18+
"dev:remote": "LOCAL_LAYER=false nuxi dev",
1919
"build": "nuxi build",
2020
"start": "nuxi start",
2121
"generate": "NODE_OPTIONS=--max-old-space-size=30720 nuxt generate",
@@ -146,4 +146,4 @@
146146
"**/libsodium-wrappers": "npm:@bangjelkoski/noop",
147147
"@ethereumjs/tx": "^4.1.1"
148148
}
149-
}
149+
}

0 commit comments

Comments
 (0)