Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions mono-repo/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
## Mono-Repo
A one-click template for a Mono repository setup inside Project IDX

## Created By
[Srivats](https://github.com/srivats22)


<a href="https://idx.google.com/new?template=https%3A%2F%2Fgithub.com%2Fsrivats22%2Fmono-idx">
<picture>
<source
media="(prefers-color-scheme: dark)"
srcset="https://cdn.idx.dev/btn/open_dark_32.svg">
<source
media="(prefers-color-scheme: light)"
srcset="https://cdn.idx.dev/btn/open_light_32.svg">
<img
height="32"
alt="Open in IDX"
src="https://cdn.idx.dev/btn/open_purple_32.svg">
</picture>
</a>

## Getting Started
1. Click the IDX menu button on the left-hand side
2. Make the backend port a public Port
![backendport](assets/backendport.png)

3. Open either ```client/src/App.js``` or ```client/src/App.tsx``` based on the template you choose
4. Replace line 10 with the Public Port URL
5. Click the Button in the preview to ensure everything is working as expected
6. You should see the message ```Hello World!``` if the api connection is successful
![running](assets/running.png)
Binary file added mono-repo/assets/backendport.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added mono-repo/assets/running.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
36 changes: 36 additions & 0 deletions mono-repo/dev.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# To learn more about how to use Nix to configure your environment
# see: https://developers.google.com/idx/guides/customize-idx-env
{ pkgs, ... }: {
# Which nixpkgs channel to use.
channel = "stable-23.11"; # or "unstable"
# Use https://search.nixos.org/packages to find packages
packages = [
pkgs.nodejs_20
];
# Sets environment variables in the workspace
env = {};
idx = {
workspace = {
# Runs when a workspace is first created with this `dev.nix` file
onCreate = {
server-npm-install = "cd server && npm ci --no-audit --prefer-offline --no-progress --timing";
client-npm-install = "cd client && npm ci --no-audit --prefer-offline --no-progress --timing";
default.openFiles = ["README.md" "client/src/App.jsx" "client/src/App.tsx"];
};
# Runs when a workspace is (re)started
onStart= {
run-server = "cd server && npm run dev";
};
};
previews = {
enable = true;
previews = {
web = {
cwd = "client";
command = ["npm" "run" "dev" "--" "--port" "$PORT"];
manager = "web";
};
};
};
};
}
19 changes: 19 additions & 0 deletions mono-repo/idx-template.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "React Express Mono Repo",
"description": "A Mono Repo using React and Express",
"categories": ["Backend", "Frontend"],
"icon": "https://www.gstatic.com/monospace/231115/logo_react.svg",
"publisher": "Srivats Venkataraman",
"params": [
{
"id": "language",
"name": "Language",
"type": "enum",
"default": "js",
"options": {
"js": "JavaScript",
"ts": "TypeScript"
}
}
]
}
20 changes: 20 additions & 0 deletions mono-repo/idx-template.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{ pkgs, language ? "js", ... }: {
packages = [
pkgs.nodejs_20
];
bootstrap =
''
mkdir "$out"
mkdir -p "$out/.idx/"
cp -rf ${./dev.nix} "$out/.idx/dev.nix"
cp -r ${./README.md} "$out"
if [ "${language}" == "ts" ]; then
shopt -s dotglob
cp -r ${./monorepo-ts}/* "$out"
else
shopt -s dotglob
cp -r ${./monorepo}/* "$out"
fi
chmod -R +w "$out"
'';
}
54 changes: 54 additions & 0 deletions mono-repo/monorepo-ts/client/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# React + TypeScript + Vite

This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.

Currently, two official plugins are available:

- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh

## Expanding the ESLint configuration

If you are developing a production application, we recommend updating the configuration to enable type-aware lint rules:

```js
export default tseslint.config({
extends: [
// Remove ...tseslint.configs.recommended and replace with this
...tseslint.configs.recommendedTypeChecked,
// Alternatively, use this for stricter rules
...tseslint.configs.strictTypeChecked,
// Optionally, add this for stylistic rules
...tseslint.configs.stylisticTypeChecked,
],
languageOptions: {
// other options...
parserOptions: {
project: ['./tsconfig.node.json', './tsconfig.app.json'],
tsconfigRootDir: import.meta.dirname,
},
},
})
```

You can also install [eslint-plugin-react-x](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-x) and [eslint-plugin-react-dom](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-dom) for React-specific lint rules:

```js
// eslint.config.js
import reactX from 'eslint-plugin-react-x'
import reactDom from 'eslint-plugin-react-dom'

export default tseslint.config({
plugins: {
// Add the react-x and react-dom plugins
'react-x': reactX,
'react-dom': reactDom,
},
rules: {
// other rules...
// Enable its recommended typescript rules
...reactX.configs['recommended-typescript'].rules,
...reactDom.configs.recommended.rules,
},
})
```
28 changes: 28 additions & 0 deletions mono-repo/monorepo-ts/client/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import js from '@eslint/js'
import globals from 'globals'
import reactHooks from 'eslint-plugin-react-hooks'
import reactRefresh from 'eslint-plugin-react-refresh'
import tseslint from 'typescript-eslint'

export default tseslint.config(
{ ignores: ['dist'] },
{
extends: [js.configs.recommended, ...tseslint.configs.recommended],
files: ['**/*.{ts,tsx}'],
languageOptions: {
ecmaVersion: 2020,
globals: globals.browser,
},
plugins: {
'react-hooks': reactHooks,
'react-refresh': reactRefresh,
},
rules: {
...reactHooks.configs.recommended.rules,
'react-refresh/only-export-components': [
'warn',
{ allowConstantExport: true },
],
},
},
)
13 changes: 13 additions & 0 deletions mono-repo/monorepo-ts/client/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + React + TS</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
29 changes: 29 additions & 0 deletions mono-repo/monorepo-ts/client/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"name": "client",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "tsc -b && vite build",
"lint": "eslint .",
"preview": "vite preview"
},
"dependencies": {
"react": "^19.0.0",
"react-dom": "^19.0.0"
},
"devDependencies": {
"@eslint/js": "^9.21.0",
"@types/react": "^19.0.10",
"@types/react-dom": "^19.0.4",
"@vitejs/plugin-react": "^4.3.4",
"eslint": "^9.21.0",
"eslint-plugin-react-hooks": "^5.1.0",
"eslint-plugin-react-refresh": "^0.4.19",
"globals": "^15.15.0",
"typescript": "~5.7.2",
"typescript-eslint": "^8.24.1",
"vite": "^6.2.0"
}
}
1 change: 1 addition & 0 deletions mono-repo/monorepo-ts/client/public/vite.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
42 changes: 42 additions & 0 deletions mono-repo/monorepo-ts/client/src/App.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#root {
max-width: 1280px;
margin: 0 auto;
padding: 2rem;
text-align: center;
}

.logo {
height: 6em;
padding: 1.5em;
will-change: filter;
transition: filter 300ms;
}
.logo:hover {
filter: drop-shadow(0 0 2em #646cffaa);
}
.logo.react:hover {
filter: drop-shadow(0 0 2em #61dafbaa);
}

@keyframes logo-spin {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}

@media (prefers-reduced-motion: no-preference) {
a:nth-of-type(2) .logo {
animation: logo-spin infinite 20s linear;
}
}

.card {
padding: 2em;
}

.read-the-docs {
color: #888;
}
35 changes: 35 additions & 0 deletions mono-repo/monorepo-ts/client/src/App.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { useState } from 'react'
import reactLogo from './assets/react.svg'
import nodeLogo from './assets/node.svg'
import './App.css'

function App() {
const [count, setCount] = useState(0)

return (
<>
<div>
<a href="https://react.dev" target="_blank">
<img src={reactLogo} className="logo react" alt="React logo" />
</a>
<a href="https://expressjs.com/" target="_blank">
<img src={nodeLogo} className="logo" alt="Vite logo" />
</a>
</div>
<h1>Vite + React</h1>
<div className="card">
<button onClick={() => setCount((count) => count + 1)}>
count is {count}
</button>
<p>
Edit <code>src/App.tsx</code> and save to test HMR
</p>
</div>
<p className="read-the-docs">
Click on the Vite and React logos to learn more
</p>
</>
)
}

export default App
26 changes: 26 additions & 0 deletions mono-repo/monorepo-ts/client/src/assets/node.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions mono-repo/monorepo-ts/client/src/assets/react.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading