Skip to content

Commit

Permalink
feat(#4): implement auth0 into initial user service
Browse files Browse the repository at this point in the history
  • Loading branch information
meatwallace committed Apr 27, 2024
1 parent 10c1bbd commit b105a89
Show file tree
Hide file tree
Showing 356 changed files with 8,076 additions and 1,606 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
14 changes: 13 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,24 @@ jobs:
if: ${{ github.ref_name == 'main' }}
uses: superfly/flyctl-actions/setup-flyctl@master

- name: Deploy API service
- name: Deploy Postgres Migrations
if: ${{ github.ref_name == 'main' && contains(steps.record-affected-projects.outputs.affected-projects, 'db-postgres') }}
run: |
echo "${{secrets.DOTENV_DB_POSTGRES }}" > projects/db-postgres/.env.production
yarn postgres:migrations-run:prod
- name: Deploy API Service
if: ${{ github.ref_name == 'main' && contains(steps.record-affected-projects.outputs.affected-projects, 'service-api') }}
run: yarn deploy:service-api --configuration=production
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}

- name: Deploy User Service
if: ${{ github.ref_name == 'main' && contains(steps.record-affected-projects.outputs.affected-projects, 'service-user') }}
run: yarn deploy:service-user --configuration=production
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}

- name: Deploy Web App
if: ${{ github.ref_name == 'main' && contains(steps.record-affected-projects.outputs.affected-projects, 'app-web') }}
run: yarn deploy:app-web --configuration=production
Expand Down
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,8 @@ Thumbs.db

# caches
.cache
.nx/cache
.nx/cache

# secrets
projects/db-postgres/.env.production
projects/service-*/.env.production
4,714 changes: 3,599 additions & 1,115 deletions .pnp.cjs

Large diffs are not rendered by default.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added .yarn/cache/d-npm-1.0.2-7abbb6ae36-3e6ede10cd.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified .yarn/install-state.gz
Binary file not shown.
18 changes: 18 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# node-graphql/docker-compose.yml

version: '3.8'
services:
postgres:
image: postgres:16.2-alpine3.19
restart: always
environment:
- POSTGRES_USER=admin
- POSTGRES_PASSWORD=password
- POSTGRES_DB=campaign
- PGPORT=5433
volumes:
- postgres:/var/lib/postgresql/data
ports:
- '5433:5433'
volumes:
postgres:
15 changes: 2 additions & 13 deletions eslint.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,8 @@ module.exports = tseslint.config(
//
},
rules: {
'unicorn/prevent-abbreviations': [
'error',
{
allowList: {
args: true,
Args: true,
ctx: true,
env: true,
Env: true,
},
},
],
//
'unicorn/no-null': 'off',
'unicorn/prevent-abbreviations': 'off',
},
},
{
Expand Down
2 changes: 1 addition & 1 deletion lint-staged.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ export default {
(files) => `yarn nx affected:lint --files=${files.join(',')}`,
(files) => `yarn nx format:write --files=${files.join(',')}`,
],
'projects/**/*.graphql': ['yarn nx format:write'],
'**/*.graphql': ['yarn nx format:write'],
};
77 changes: 51 additions & 26 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,99 +11,124 @@
"typecheck": "nx run-many -t typecheck",
"e2e": "nx run-many -t e2e",
"codegen:graphql": "graphql-codegen",
"postgres:start": "docker-compose -f ./docker-compose.yml up -d",
"postgres:migrations-generate": "nx migrations-generate db-postgres",
"postgres:migrations-run:dev": "nx migrations-run-dev db-postgres",
"postgres:migrations-run:prod": "nx migrations-run-prod db-postgres",
"---PROJECT-SPECIFIC": "",
"build:app-web": "nx build-remix app-web",
"build:service-api": "nx build service-api",
"build:service-user": "nx build service-user",
"deploy:app-web": "nx deploy service-api",
"deploy:service-api": "nx deploy service-api",
"deploy:service-user": "nx deploy service-user",
"dev:app-web": "nx serve app-web",
"dev:service-api": "nx serve service-api",
"dev:service-api": "dotenvx run -f projects/service-api/.env.development -- yarn run nx serve service-api",
"dev:service-user": "dotenvx run -f projects/service-user/.env.development -- yarn run nx serve service-user",
"e2e:app-web": "nx e2e app-web-e2e",
"test:app-web": "nx test app-web",
"test:service-api": "nx test service-api",
"test:app-web": "nx test-watch app-web",
"test:lib-postgres-schema": "nx test-watch lib-postgres-schema",
"test:lib-service-test-utils": "nx test-watch lib-service-test-utils",
"test:lib-service-utils": "nx test-watch lib-service-utils",
"test:service-api": "nx test-watch service-api",
"test:service-user": "nx test-watch service-user",
"---UTILITY": "",
"postinstall": "husky"
},
"devDependencies": {
"@0no-co/graphqlsp": "1.11.0",
"@commitlint/cli": "19.2.1",
"@dotenvx/dotenvx": "0.35.1",
"@eslint/js": "9.0.0",
"@graphql-codegen/cli": "5.0.2",
"@graphql-codegen/client-preset": "4.2.5",
"@graphql-codegen/schema-ast": "4.0.2",
"@graphql-tools/executor-http": "1.0.9",
"@graphql-typed-document-node/core": "3.2.0",
"@nx/cypress": "18.2.4",
"@nx/devkit": "18.2.4",
"@nx/esbuild": "18.2.4",
"@nx/eslint": "18.2.4",
"@nx/js": "18.2.4",
"@nx/node": "18.2.4",
"@nx/playwright": "18.2.4",
"@nx/react": "18.2.4",
"@nx/vite": "18.2.4",
"@nx/web": "18.2.4",
"@nx/workspace": "18.2.4",
"@nx/devkit": "18.3.3",
"@nx/esbuild": "18.3.3",
"@nx/eslint": "18.3.3",
"@nx/js": "18.3.3",
"@nx/node": "18.3.3",
"@nx/playwright": "18.3.3",
"@nx/react": "18.3.3",
"@nx/vite": "18.3.3",
"@nx/web": "18.3.3",
"@nx/workspace": "18.3.3",
"@parcel/watcher": "2.4.1",
"@playwright/test": "1.43.0",
"@remix-run/dev": "2.8.1",
"@remix-run/testing": "2.8.1",
"@remix-run/dev": "2.9.1",
"@remix-run/testing": "2.9.1",
"@swc-node/register": "1.9.0",
"@swc/cli": "0.3.12",
"@swc/core": "1.4.13",
"@swc/helpers": "0.5.8",
"@testcontainers/postgresql": "10.9.0",
"@testing-library/jest-dom": "6.4.2",
"@testing-library/react": "14.3.0",
"@types/jsonwebtoken": "9.0.6",
"@types/node": "20.12.7",
"@types/react": "18.2.75",
"@types/react-dom": "18.2.24",
"@types/react-is": "18.2.4",
"@types/styled-components": "5.1.34",
"@typescript-eslint/eslint-plugin": "7.6.0",
"@typescript-eslint/parser": "7.6.0",
"@typescript-eslint/utils": "7.7.1",
"@vitejs/plugin-react": "4.2.1",
"@vitest/coverage-v8": "1.4.0",
"@vitest/ui": "1.5.0",
"babel-plugin-styled-components": "2.1.4",
"@vitest/coverage-v8": "1.5.1",
"@vitest/ui": "1.5.1",
"drizzle-kit": "0.20.17",
"esbuild": "0.20.2",
"eslint": "9.0.0",
"eslint-config-prettier": "9.1.0",
"eslint-plugin-drizzle": "0.2.3",
"eslint-plugin-jsx-a11y": "6.8.0",
"eslint-plugin-playwright": "1.6.0",
"eslint-plugin-react": "7.34.1",
"eslint-plugin-react-hooks": "4.6.0",
"eslint-plugin-unicorn": "52.0.0",
"happy-dom": "14.7.1",
"husky": "9.0.11",
"jest-extended": "4.0.2",
"lint-staged": "15.2.2",
"mock-jwks": "3.1.0",
"msw": "2.2.14",
"nx": "18.2.4",
"nx": "18.3.3",
"playwright": "1.43.0",
"prettier": "3.2.5",
"tslib": "2.6.2",
"tsx": "4.7.3",
"typescript": "5.4.5",
"typescript-eslint": "7.6.0",
"vite": "5.2.10",
"vitest": "1.5.0"
"vitest": "1.5.1"
},
"dependencies": {
"@hono/node-server": "1.10.0",
"@pothos/core": "3.41.0",
"@remix-run/node": "2.8.1",
"@remix-run/react": "2.8.1",
"@remix-run/serve": "2.8.1",
"@pothos/core": "3.41.1",
"@remix-run/node": "2.9.1",
"@remix-run/react": "2.9.1",
"@remix-run/serve": "2.9.1",
"auth0": "4.3.1",
"cuid": "3.0.0",
"drizzle-orm": "0.30.9",
"envalid": "8.0.0",
"graphql": "16.8.1",
"graphql-request": "6.1.0",
"graphql-yoga": "5.3.0",
"hono": "4.2.4",
"isbot": "4",
"jsonwebtoken": "9.0.2",
"jwks-rsa": "3.1.0",
"postgres": "3.4.4",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-is": "18.2.0",
"react-router-dom": "6.22.3",
"remix-hono": "0.0.16",
"styled-components": "6.1.8"
"styled-components": "6.1.8",
"tiny-invariant": "1.3.3"
},
"packageManager": "yarn@4.1.1",
"dockerfile": {
Expand Down
13 changes: 7 additions & 6 deletions projects/app-web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
},
"dependencies": {
"@hono/node-server": "1.11.0",
"@remix-run/node": "2.8.1",
"@remix-run/react": "2.8.1",
"@remix-run/node": "2.9.1",
"@remix-run/react": "2.9.1",
"graphql-request": "6.1.0",
"hono": "4.2.4",
"isbot": "4",
Expand All @@ -21,9 +21,9 @@
},
"devDependencies": {
"@graphql-typed-document-node/core": "3.2.0",
"@nx/vite": "18.2.4",
"@remix-run/dev": "2.8.1",
"@remix-run/testing": "2.8.1",
"@nx/vite": "18.3.3",
"@remix-run/dev": "2.9.1",
"@remix-run/testing": "2.9.1",
"@testing-library/jest-dom": "6.4.2",
"@testing-library/react": "14.3.0",
"@types/node": "20.12.7",
Expand All @@ -34,10 +34,11 @@
"eslint-plugin-react": "7.34.1",
"eslint-plugin-react-hooks": "4.6.0",
"graphql": "16.8.1",
"jest-extended": "4.0.2",
"tslib": "2.6.2",
"typescript": "5.4.5",
"vite": "5.2.10",
"vitest": "1.5.0"
"vitest": "1.5.1"
},
"engines": {
"node": "20.12.2"
Expand Down
7 changes: 7 additions & 0 deletions projects/app-web/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@
"flyctl deploy --local-only --dockerfile projects/app-web/Dockerfile --config projects/app-web/fly.toml"
]
}
},
"test-watch": {
"executor": "nx:run-commands",
"options": {
"commands": ["yarn run vitest watch"],
"cwd": "projects/app-web"
}
}
}
}
1 change: 0 additions & 1 deletion projects/app-web/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ installGlobals();

export default defineConfig({
root: __dirname,
cacheDir: '../../node_modules/.vite/apps/app-web',
server: {
port: 4000,
host: 'localhost',
Expand Down
3 changes: 3 additions & 0 deletions projects/app-web/vitest.setup.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import '@testing-library/jest-dom/matchers';
import * as matchers from 'jest-extended';
// import { installGlobals } from '@remix-run/node';
import { server } from './app/mocks/node';

expect.extend(matchers);

// disabled until this becomes an issue. it bricks MSW's graphql response or graphql-request's
// ability to interpret a success - can confirm if needed later.
// installGlobals();
Expand Down
2 changes: 2 additions & 0 deletions projects/db-postgres/.env.development
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
NODE_ENV=development
POSTGRES_URL="postgresql://admin:password@localhost:5433/campaign"
7 changes: 7 additions & 0 deletions projects/db-postgres/drizzle.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import type { Config } from 'drizzle-kit';

export default {
schema: './src/schema.ts',
out: './migrations',
driver: 'pg',
} satisfies Config;
63 changes: 63 additions & 0 deletions projects/db-postgres/fly.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
app = 'campaign-pg'
primary_region = 'syd'

[env]
PRIMARY_REGION = 'syd'

[[mounts]]
source = 'pg_data'
destination = '/data'

[[services]]
protocol = 'tcp'
internal_port = 5432
auto_start_machines = false

[[services.ports]]
port = 5432
handlers = ['pg_tls']

[services.concurrency]
type = 'connections'
hard_limit = 1000
soft_limit = 1000

[[services]]
protocol = 'tcp'
internal_port = 5433
auto_start_machines = false

[[services.ports]]
port = 5433
handlers = ['pg_tls']

[services.concurrency]
type = 'connections'
hard_limit = 1000
soft_limit = 1000

[checks]
[checks.pg]
port = 5500
type = 'http'
interval = '15s'
timeout = '10s'
path = '/flycheck/pg'

[checks.role]
port = 5500
type = 'http'
interval = '15s'
timeout = '10s'
path = '/flycheck/role'

[checks.vm]
port = 5500
type = 'http'
interval = '15s'
timeout = '10s'
path = '/flycheck/vm'

[[metrics]]
port = 9187
path = '/metrics'
7 changes: 7 additions & 0 deletions projects/db-postgres/migrate.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { migrate } from 'drizzle-orm/postgres-js/migrator';
import { db } from './src/db';
import { pg } from './src/pg';

await migrate(db, { migrationsFolder: './migrations' });

await pg.end();
Loading

0 comments on commit b105a89

Please sign in to comment.