-
-
Notifications
You must be signed in to change notification settings - Fork 130
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(api-client): Added API Client package (#346)
- Loading branch information
Showing
27 changed files
with
965 additions
and
222 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
on: | ||
push: | ||
branches: | ||
- '!develop' | ||
- '!main' | ||
paths: | ||
['packages/api-client/**', '.github/workflows/validate-api-client.yaml'] | ||
pull_request: | ||
paths: | ||
['packages/api-client/**', '.github/workflows/validate-api-client.yaml'] | ||
|
||
jobs: | ||
validate: | ||
runs-on: ubuntu-latest | ||
name: Validate API Client | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Install Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: 20 | ||
|
||
- name: Install pnpm | ||
uses: pnpm/action-setup@v4 | ||
with: | ||
version: 9.2.0 | ||
run_install: false | ||
|
||
- name: Get pnpm store directory | ||
shell: bash | ||
run: | | ||
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV | ||
- uses: actions/cache@v4 | ||
name: Setup pnpm cache | ||
with: | ||
path: ${{ env.STORE_PATH }} | ||
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} | ||
restore-keys: | | ||
${{ runner.os }}-pnpm-store- | ||
- name: Install packages | ||
run: | | ||
pnpm i | ||
- name: Lint | ||
run: | | ||
pnpm run lint:api-client | ||
- name: Test | ||
run: | | ||
pnpm run test:api-client | ||
- name: Upload coverage reports to Codecov | ||
uses: codecov/codecov-action@v3 | ||
env: | ||
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} | ||
with: | ||
flags: api-client |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#!/usr/bin/env sh | ||
. "$(dirname -- "$0")/_/husky.sh" | ||
|
||
pnpm lint && pnpm format && pnpm test:api | ||
pnpm lint && pnpm format && pnpm test:api && pnpm test:api-client |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,7 @@ export class UserService { | |
|
||
async onApplicationBootstrap() { | ||
await this.checkIfAdminExistsOrCreate() | ||
await this.createDummyUser() | ||
} | ||
|
||
async getSelf(user: User) { | ||
|
@@ -294,6 +295,24 @@ export class UserService { | |
return userWithWorkspace | ||
} | ||
|
||
private async createDummyUser() { | ||
// @ts-expect-error - This is a test environment | ||
if (process.env.NODE_ENV === 'test' || process.env.NODE_ENV === 'e2e') { | ||
this.log.log('Creating dummy user') | ||
|
||
const user = await this.prisma.user.create({ | ||
data: { | ||
email: '[email protected]', | ||
name: 'John Doe', | ||
isActive: true, | ||
isOnboardingFinished: true | ||
} | ||
}) | ||
|
||
this.log.log('Created dummy user: ', user) | ||
} | ||
} | ||
|
||
private async checkIfAdminExistsOrCreate() { | ||
const parsedEnv = EnvSchema.safeParse(process.env) | ||
let nodeEnv | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,65 +1,64 @@ | ||
{ | ||
"name": "platform", | ||
"version": "1.0.0", | ||
"private": true, | ||
"scripts": { | ||
"dev": "env-cmd -f ../../.env --silent next dev -p 3025", | ||
"build": "next build", | ||
"start": "next start", | ||
"lint": "next lint --fix" | ||
}, | ||
"dependencies": { | ||
"@radix-ui/react-accordion": "^1.2.0", | ||
"@radix-ui/react-avatar": "^1.0.4", | ||
"@radix-ui/react-checkbox": "^1.0.4", | ||
"@radix-ui/react-context-menu": "^2.1.5", | ||
"@radix-ui/react-dialog": "^1.0.5", | ||
"@radix-ui/react-direction": "^1.0.1", | ||
"@radix-ui/react-dropdown-menu": "^2.0.6", | ||
"@radix-ui/react-icons": "^1.3.0", | ||
"@radix-ui/react-label": "^2.0.2", | ||
"@radix-ui/react-menubar": "^1.0.4", | ||
"@radix-ui/react-popover": "^1.0.7", | ||
"@radix-ui/react-scroll-area": "^1.0.5", | ||
"@radix-ui/react-separator": "^1.0.3", | ||
"@radix-ui/react-slot": "^1.0.2", | ||
"@radix-ui/react-switch": "^1.0.3", | ||
"@radix-ui/react-tooltip": "^1.1.2", | ||
"@tanstack/react-table": "^8.16.0", | ||
"avvvatars-react": "^0.4.2", | ||
"class-variance-authority": "^0.7.0", | ||
"clsx": "^2.1.0", | ||
"cmdk": "^1.0.0", | ||
"dayjs": "^1.11.11", | ||
"env-cmd": "^10.1.0", | ||
"framer-motion": "^11.1.7", | ||
"geist": "^1.2.2", | ||
"input-otp": "^1.2.4", | ||
"jotai": "^2.8.0", | ||
"js-cookie": "^3.0.5", | ||
"lucide-react": "^0.340.0", | ||
"next": "^13.5.6", | ||
"next-themes": "^0.3.0", | ||
"react": "^18.3.1", | ||
"react-dom": "^18.3.1", | ||
"sonner": "^1.4.41", | ||
"tailwind-merge": "^2.2.2", | ||
"tailwindcss-animate": "^1.0.7", | ||
"zod": "^3.23.8" | ||
}, | ||
"devDependencies": { | ||
"@next/eslint-plugin-next": "^13.5.6", | ||
"@svgr/webpack": "^8.1.0", | ||
"@tailwindcss/forms": "^0.5.7", | ||
"@types/js-cookie": "^3.0.6", | ||
"@types/node": "^17.0.45", | ||
"@types/react": "^18.3.1", | ||
"@types/react-dom": "^18.3.0", | ||
"autoprefixer": "^10.4.16", | ||
"eslint-config-custom": "workspace:*", | ||
"postcss": "^8.4.31", | ||
"tailwindcss": "^3.3.3", | ||
"tsconfig": "workspace:*", | ||
"typescript": "^4.5.3" | ||
} | ||
} | ||
"name": "platform", | ||
"version": "1.0.0", | ||
"private": true, | ||
"scripts": { | ||
"dev": "env-cmd -f ../../.env --silent next dev -p 3025", | ||
"build": "next build", | ||
"start": "next start", | ||
"lint": "next lint --fix" | ||
}, | ||
"dependencies": { | ||
"@radix-ui/react-accordion": "^1.2.0", | ||
"@radix-ui/react-avatar": "^1.0.4", | ||
"@radix-ui/react-checkbox": "^1.0.4", | ||
"@radix-ui/react-context-menu": "^2.1.5", | ||
"@radix-ui/react-dialog": "^1.0.5", | ||
"@radix-ui/react-direction": "^1.0.1", | ||
"@radix-ui/react-dropdown-menu": "^2.0.6", | ||
"@radix-ui/react-icons": "^1.3.0", | ||
"@radix-ui/react-label": "^2.0.2", | ||
"@radix-ui/react-menubar": "^1.0.4", | ||
"@radix-ui/react-popover": "^1.0.7", | ||
"@radix-ui/react-scroll-area": "^1.0.5", | ||
"@radix-ui/react-separator": "^1.0.3", | ||
"@radix-ui/react-slot": "^1.0.2", | ||
"@radix-ui/react-switch": "^1.0.3", | ||
"@radix-ui/react-tooltip": "^1.1.2", | ||
"@tanstack/react-table": "^8.16.0", | ||
"avvvatars-react": "^0.4.2", | ||
"class-variance-authority": "^0.7.0", | ||
"clsx": "^2.1.0", | ||
"cmdk": "^1.0.0", | ||
"dayjs": "^1.11.11", | ||
"env-cmd": "^10.1.0", | ||
"framer-motion": "^11.1.7", | ||
"geist": "^1.2.2", | ||
"input-otp": "^1.2.4", | ||
"jotai": "^2.8.0", | ||
"js-cookie": "^3.0.5", | ||
"lucide-react": "^0.340.0", | ||
"next": "^13.5.6", | ||
"next-themes": "^0.3.0", | ||
"react": "^18.3.1", | ||
"react-dom": "^18.3.1", | ||
"sonner": "^1.4.41", | ||
"tailwind-merge": "^2.2.2", | ||
"tailwindcss-animate": "^1.0.7", | ||
"zod": "^3.23.8" | ||
}, | ||
"devDependencies": { | ||
"@next/eslint-plugin-next": "^13.5.6", | ||
"@svgr/webpack": "^8.1.0", | ||
"@tailwindcss/forms": "^0.5.7", | ||
"@types/js-cookie": "^3.0.6", | ||
"@types/react": "^18.3.1", | ||
"@types/react-dom": "^18.3.0", | ||
"autoprefixer": "^10.4.16", | ||
"eslint-config-custom": "workspace:*", | ||
"postcss": "^8.4.31", | ||
"tailwindcss": "^3.3.3", | ||
"tsconfig": "workspace:*", | ||
"typescript": "^4.5.3" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.