Skip to content

Commit

Permalink
Merge pull request #1 from 0xjei/chore/monorepo
Browse files Browse the repository at this point in the history
Move to `yarn workspaces` monorepo
  • Loading branch information
cedoor authored Aug 29, 2023
2 parents f47c016 + 7724806 commit 19a7a52
Show file tree
Hide file tree
Showing 18 changed files with 7,851 additions and 3,924 deletions.
4 changes: 4 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
# Client.
PCDPASS_URL="http://localhost:3000"

# Server.
SERVER_PORT=3000
2 changes: 1 addition & 1 deletion .github/workflows/gh-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@ jobs:
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./dist
publish_dir: ./apps/client/dist
cname: pcd-consumer.cedoor.dev
20 changes: 15 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# dependencies
/node_modules
/.pnp
node_modules
.pnp
.pnp.js

# parcel
/.parcel-cache
.parcel-cache

# production
/dist
dist

# misc
.DS_Store
Expand All @@ -18,5 +18,15 @@ npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Yarn 3 files
.pnp.*
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions
yarn-error.log

# local env files
.env
.env
28 changes: 28 additions & 0 deletions .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs

Large diffs are not rendered by default.

874 changes: 874 additions & 0 deletions .yarn/releases/yarn-3.6.3.cjs

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
nodeLinker: node-modules

plugins:
- path: .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs
spec: "@yarnpkg/plugin-workspace-tools"

yarnPath: .yarn/releases/yarn-3.6.3.cjs
14 changes: 9 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
</h1>
</p>

| This repository contains a sample application demonstrating how to utilize the PCD SDK to consume a PCD with a PCD passport. |
| ---------------------------------------------------------------------------------------------------------------------------- |
| This monorepo contains a sample application and server to demonstrate the PCD SDK usage for consuming a PCD with a PCD passport. |
| -------------------------------------------------------------------------------------------------------------------------------- |

## 🛠 Install

Expand All @@ -31,11 +31,15 @@ Copy the `.env.example` file as `.env`:
cp .env.example .env
```

and add your environment variables or run the app in a local network.
And add your environment variables.

### Local server
Run the following command to build (client + server):

You can start your app locally with:
```sh
yarn build
```

Run the following command to start the application (client + server):

```bash
yarn start
Expand Down
31 changes: 31 additions & 0 deletions apps/client/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"name": "client",
"version": "0.1.0",
"source": "src/index.html",
"scripts": {
"start": "parcel --cache-dir .parcel-cache/ --no-cache --open",
"build": "parcel build --cache-dir .parcel-cache/"
},
"dependencies": {
"@pcd/eddsa-pcd": "^0.1.1",
"@pcd/passport-interface": "^0.6.2",
"@pcd/pcd-types": "^0.6.2",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-router-dom": "^6.15.0"
},
"devDependencies": {
"@types/react": "^18.2.21",
"@types/react-dom": "^18.2.7",
"assert": "^2.0.0",
"browserify-zlib": "^0.2.0",
"buffer": "^5.5.0||^6.0.0",
"crypto-browserify": "^3.12.0",
"events": "^3.1.0",
"os-browserify": "^0.3.0",
"parcel": "^2.9.3",
"path-browserify": "^1.0.0",
"process": "^0.11.10",
"stream-browserify": "^3.0.0"
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
21 changes: 21 additions & 0 deletions apps/server/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "server",
"version": "0.1.0",
"main": "src/index.ts",
"packageManager": "[email protected]",
"scripts": {
"build": "npx tsc",
"start": "ts-node src/index.ts"
},
"dependencies": {
"dotenv": "^16.3.1",
"express": "^4.18.2"
},
"devDependencies": {
"@types/dotenv": "^8.2.0",
"@types/express": "^4.17.17",
"@types/node": "^20.5.7",
"ts-node": "^10.9.1",
"typescript": "^5.2.2"
}
}
15 changes: 15 additions & 0 deletions apps/server/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import express, { Express, Request, Response } from 'express';
import dotenv from "dotenv"

dotenv.config({ path: `${process.cwd()}/../../.env` })

const app: Express = express();
const port = process.env.SERVER_PORT || 3000;

app.get('/', (req: Request, res: Response) => {
res.send('Express + TypeScript Server');
});

app.listen(port, () => {
console.log(`⚡️[server]: Server is running at http://localhost:${port}`);
});
21 changes: 21 additions & 0 deletions apps/server/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"compilerOptions": {
"target": "ES5",
"module": "ES6",
"outDir": "dist",
"moduleResolution": "node",
"preserveConstEnums": true,
"resolveJsonModule": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"typeRoots": ["node_modules/@types"],
},
"ts-node": {
"compilerOptions": {
"target": "esnext",
"module": "commonjs"
}
}
}
32 changes: 6 additions & 26 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,32 +1,12 @@
{
"name": "example-consumer",
"version": "0.1.0",
"private": true,
"source": "src/index.html",
"packageManager": "[email protected]",
"scripts": {
"start": "parcel --no-cache --open",
"build": "parcel build"
"build": "yarn workspaces foreach -t run build",
"start": "yarn workspaces foreach -pi run start"
},
"dependencies": {
"@pcd/eddsa-pcd": "^0.1.1",
"@pcd/passport-interface": "^0.6.2",
"@pcd/pcd-types": "^0.6.2",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-router-dom": "^6.15.0"
},
"devDependencies": {
"@types/react": "^18.2.21",
"@types/react-dom": "^18.2.7",
"assert": "^2.0.0",
"browserify-zlib": "^0.2.0",
"buffer": "^5.5.0||^6.0.0",
"crypto-browserify": "^3.12.0",
"events": "^3.1.0",
"os-browserify": "^0.3.0",
"parcel": "^2.9.3",
"path-browserify": "^1.0.0",
"process": "^0.11.10",
"stream-browserify": "^3.0.0"
}
"workspaces": [
"apps/*"
]
}
Loading

0 comments on commit 19a7a52

Please sign in to comment.