Skip to content

Commit

Permalink
Update dependencies, fix issue with dev server mode not working, rena…
Browse files Browse the repository at this point in the history
…me DatabaseService to DatabaseGateway
  • Loading branch information
danielnaab committed Aug 6, 2024
1 parent 446c62f commit 361deb6
Show file tree
Hide file tree
Showing 17 changed files with 3,757 additions and 3,304 deletions.
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v20.15.0
v20.16.0
6 changes: 3 additions & 3 deletions apps/server-doj/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@ import { fileURLToPath } from 'url';
const getDirname = () => dirname(fileURLToPath(import.meta.url));

export const createCustomServer = async (): Promise<any> => {
const { createDevDatabaseContext, createDatabaseService } = await import(
const { createDevDatabaseContext, createDatabaseGateway } = await import(
'@atj/database'
);
const { createServer } = await import('@atj/server');

const dbCtx = await createDevDatabaseContext(
path.join(getDirname(), '../doj.db')
);
const database = createDatabaseService(dbCtx);
const db = createDatabaseGateway(dbCtx);

return createServer({
title: 'DOJ Form Service',
database,
db,
loginGovOptions: {
loginGovUrl: 'https://idp.int.identitysandbox.gov',
clientId:
Expand Down
6 changes: 3 additions & 3 deletions apps/server-kansas/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@ import { fileURLToPath } from 'url';
const getDirname = () => dirname(fileURLToPath(import.meta.url));

export const createCustomServer = async (): Promise<any> => {
const { createDevDatabaseContext, createDatabaseService } = await import(
const { createDevDatabaseContext, createDatabaseGateway } = await import(
'@atj/database'
);
const { createServer } = await import('@atj/server');

const dbCtx = await createDevDatabaseContext(
path.join(getDirname(), '../doj.db')
);
const database = createDatabaseService(dbCtx);
const db = createDatabaseGateway(dbCtx);

return createServer({
title: 'KS Courts Form Service',
database,
db,
loginGovOptions: {
loginGovUrl: 'https://idp.int.identitysandbox.gov',
clientId:
Expand Down
19 changes: 7 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,25 +22,20 @@
"pre-commit": "pnpm format"
},
"devDependencies": {
"@types/node": "^20.11.16",
"@vitest/coverage-c8": "^0.33.0",
"@types/node": "^20.14.8",
"@vitest/coverage-v8": "^2.0.5",
"@vitest/ui": "^2.0.5",
"esbuild": "^0.20.2",
"esbuild": "^0.23.0",
"eslint": "^8.56.0",
"husky": "^9.0.11",
"husky": "^9.1.4",
"npm-run-all": "^4.1.5",
"prettier": "^3.2.5",
"prettier": "^3.3.3",
"ts-node": "^10.9.2",
"tsup": "^8.0.1",
"tsup": "^8.2.4",
"turbo": "^1.12.3",
"type-fest": "^4.10.2",
"typescript": "^5.3.3",
"typescript": "^5.5.4",
"vitest": "^2.0.5",
"vitest-mock-extended": "^2.0.0"
},
"dependencies": {
"@vitest/ui": "^2.0.5",
"astro": "^4.3.5"
}
"dependencies": {}
}
6 changes: 3 additions & 3 deletions packages/auth/src/context/dev.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Cookie, Lucia } from 'lucia';

import { type DatabaseService } from '@atj/database';
import { type DatabaseGateway } from '@atj/database';

import { type AuthContext, type UserSession } from '..';
import { createTestLuciaAdapter } from '../lucia';
Expand All @@ -10,7 +10,7 @@ export class DevAuthContext implements AuthContext {
private lucia?: Lucia;

constructor(
public database: DatabaseService,
public db: DatabaseGateway,
public provider: LoginGov,
public getCookie: (name: string) => string | undefined,
public setCookie: (cookie: Cookie) => void,
Expand All @@ -19,7 +19,7 @@ export class DevAuthContext implements AuthContext {

async getLucia() {
const sqlite3Adapter = createTestLuciaAdapter(
await (this.database.getContext() as any).getSqlite3()
await (this.db.getContext() as any).getSqlite3()
);
if (!this.lucia) {
this.lucia = new Lucia(sqlite3Adapter, {
Expand Down
10 changes: 5 additions & 5 deletions packages/auth/src/context/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { Cookie, Lucia } from 'lucia';
import { vi } from 'vitest';

import {
type DatabaseService,
type DatabaseGateway,
createTestDatabaseContext,
createDatabaseService,
createDatabaseGateway,
} from '@atj/database';

import { type AuthContext, type UserSession } from '..';
Expand All @@ -24,7 +24,7 @@ export const createTestAuthContext = async (opts?: Partial<Options>) => {
setUserSession: opts?.setUserSession || vi.fn(),
};
const dbContext = await createTestDatabaseContext();
const database = createDatabaseService(dbContext);
const database = createDatabaseGateway(dbContext);
return new TestAuthContext(
database,
new LoginGov({
Expand All @@ -44,15 +44,15 @@ export class TestAuthContext implements AuthContext {
private lucia?: Lucia;

constructor(
public database: DatabaseService,
public db: DatabaseGateway,
public provider: LoginGov,
public getCookie: (name: string) => string | undefined,
public setCookie: (cookie: Cookie) => void,
public setUserSession: (userSession: UserSession) => void
) {}

async getLucia() {
const sqlite3 = await (this.database.getContext() as any).getSqlite3();
const sqlite3 = await (this.db.getContext() as any).getSqlite3();
const sqlite3Adapter = createTestLuciaAdapter(sqlite3);
if (!this.lucia) {
this.lucia = new Lucia(sqlite3Adapter, {
Expand Down
4 changes: 2 additions & 2 deletions packages/auth/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { type Cookie, type User, type Session, type Lucia } from 'lucia';

import { type DatabaseService } from '@atj/database';
import { type DatabaseGateway } from '@atj/database';

export { DevAuthContext } from './context/dev';
import { type LoginGovOptions, LoginGov } from './provider';
Expand All @@ -17,7 +17,7 @@ export type UserSession = {
};

export type AuthContext = {
database: DatabaseService;
db: DatabaseGateway;
provider: LoginGov;
getCookie: (name: string) => string | undefined;
setCookie: (cookie: Cookie) => void;
Expand Down
3 changes: 1 addition & 2 deletions packages/auth/src/services/process-provider-callback.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ describe('processProviderCallback', () => {

// Create test auth context with a test user in the db
ctx = await createTestAuthContext();
const user = await ctx.database.createUser('[email protected]');
const user = await ctx.db.createUser('[email protected]');
if (!user) {
expect.fail('error creating test user');
}
Expand All @@ -37,7 +37,6 @@ describe('processProviderCallback', () => {
aal: 'ignored',
});
} else if (request.url.includes('openid_connect/authorize')) {
console.error('********');
throw new Error('authorize endpoint: todo');
}
throw new Error(`unexpected url: ${request.url}`);
Expand Down
4 changes: 2 additions & 2 deletions packages/auth/src/services/process-provider-callback.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ export const processProviderCallback = async (
if (!userDataResult.success) {
return userDataResult;
}
let userId = await ctx.database.getUserId(userDataResult.data.email);
let userId = await ctx.db.getUserId(userDataResult.data.email);
if (!userId) {
const newUser = await ctx.database.createUser(userDataResult.data.email);
const newUser = await ctx.db.createUser(userDataResult.data.email);
if (!newUser) {
return r.failure({ status: 500, message: 'error creating new user' });
}
Expand Down
4 changes: 2 additions & 2 deletions packages/auth/src/services/process-session-cookie.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,11 @@ const setUpTest = async (sessionExpirationDate: Date) => {
setUserSession: vi.fn(),
};
const ctx = await createTestAuthContext(mocks);
const user = await ctx.database.createUser('[email protected]');
const user = await ctx.db.createUser('[email protected]');
if (!user) {
expect.fail('error creating test user');
}
const sessionId = await ctx.database.createSession({
const sessionId = await ctx.db.createSession({
id: randomUUID(),
expiresAt: addOneDay(sessionExpirationDate),
sessionToken: 'my-token',
Expand Down
3 changes: 3 additions & 0 deletions packages/common/src/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ export const createService = <
}
const propKey = prop as keyof Functions;
const originalFn = target[propKey];
if (originalFn === undefined) {
return undefined;
}
return (...args: any[]) =>
(originalFn as Function).call(null, ctx, ...args);
},
Expand Down
4 changes: 2 additions & 2 deletions packages/database/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ export { type Database } from './clients/kysely';
export { type DatabaseContext } from './context/types';
export { migrateDatabase } from './management/migrate-database';

export const createDatabaseService = (ctx: DatabaseContext) =>
export const createDatabaseGateway = (ctx: DatabaseContext) =>
createService(ctx, {
createSession,
createUser,
getUserId,
});

export type DatabaseService = ReturnType<typeof createDatabaseService>;
export type DatabaseGateway = ReturnType<typeof createDatabaseGateway>;
57 changes: 28 additions & 29 deletions packages/design/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,39 +23,38 @@
"dist/**/*"
],
"devDependencies": {
"@playwright/test": "^1.43.1",
"@storybook/addon-a11y": "^7.6.10",
"@storybook/addon-coverage": "^1.0.0",
"@storybook/addon-essentials": "^7.6.10",
"@storybook/addon-interactions": "^7.6.10",
"@storybook/addon-links": "^7.6.10",
"@storybook/blocks": "^7.6.10",
"@storybook/preview-api": "^7.6.10",
"@storybook/react": "^7.6.10",
"@storybook/react-vite": "^7.6.10",
"@storybook/test": "^7.6.10",
"@playwright/test": "^1.46.0",
"@storybook/addon-a11y": "^7.6.20",
"@storybook/addon-coverage": "^1.0.4",
"@storybook/addon-essentials": "^7.6.20",
"@storybook/addon-interactions": "^7.6.20",
"@storybook/addon-links": "^7.6.20",
"@storybook/blocks": "^7.6.20",
"@storybook/preview-api": "^7.6.20",
"@storybook/react": "^7.6.20",
"@storybook/react-vite": "^7.6.20",
"@storybook/test": "^7.6.20",
"@storybook/test-runner": "^0.16.0",
"@storybook/types": "^7.6.10",
"@storybook/types": "^7.6.20",
"@testing-library/react": "^15.0.7",
"@types/deep-equal": "^1.0.4",
"@types/prop-types": "^15.7.12",
"@types/react": "^18.2.79",
"@typescript-eslint/eslint-plugin": "^7.7.0",
"@typescript-eslint/parser": "^7.7.0",
"@types/react": "^18.3.3",
"@typescript-eslint/eslint-plugin": "^7.18.0",
"@typescript-eslint/parser": "^7.18.0",
"@uswds/compile": "1.1.0",
"@vitejs/plugin-react": "^4.3.0",
"@vitejs/plugin-react": "^4.3.1",
"concurrently": "^8.2.2",
"eslint": "^8.56.0",
"eslint-plugin-react": "^7.34.1",
"glob": "^10.3.12",
"eslint": "^8.57.0",
"eslint-plugin-react": "^7.35.0",
"gulp": "^5.0.0",
"http-server": "^14.1.1",
"install": "^0.13.0",
"jsdom": "^24.1.0",
"jsdom": "^24.1.1",
"prop-types": "^15.8.1",
"react-dom": "^18.2.0",
"vite": "^5.2.11",
"vite-plugin-dts": "^3.9.1",
"react-dom": "^18.3.1",
"vite": "^5.3.5",
"vite-plugin-dts": "^4.0.0",
"wait-on": "^7.2.0"
},
"dependencies": {
Expand All @@ -64,14 +63,14 @@
"@dnd-kit/core": "^6.1.0",
"@dnd-kit/sortable": "^8.0.0",
"@dnd-kit/utilities": "^3.2.2",
"@uswds/uswds": "^3.8.0",
"@uswds/uswds": "^3.8.1",
"classnames": "^2.5.1",
"deep-equal": "^2.2.3",
"react": "^18.2.0",
"react-hook-form": "^7.51.3",
"react-router-dom": "^6.22.3",
"storybook": "^7.6.10",
"zustand": "^4.5.2",
"react": "^18.3.1",
"react-hook-form": "^7.52.2",
"react-router-dom": "^6.26.0",
"storybook": "^7.6.20",
"zustand": "^4.5.4",
"zustand-utils": "^1.3.2"
}
}
18 changes: 9 additions & 9 deletions packages/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,25 @@
"astro": "astro"
},
"dependencies": {
"@astrojs/check": "^0.7.0",
"@astrojs/node": "^8.3.1",
"@astrojs/react": "^3.6.0",
"@astrojs/check": "^0.9.1",
"@astrojs/node": "^8.3.2",
"@astrojs/react": "^3.6.1",
"@atj/auth": "workspace:^",
"@atj/common": "workspace:*",
"@atj/database": "workspace:*",
"@atj/design": "workspace:*",
"@atj/forms": "workspace:*",
"astro": "^4.10.3",
"astro": "^4.13.1",
"express": "^4.19.2",
"jwt-decode": "^4.0.0",
"lucia": "^3.2.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-error-boundary": "^4.0.12",
"typescript": "^5.3.3"
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-error-boundary": "^4.0.13",
"typescript": "^5.5.4"
},
"devDependencies": {
"@types/express": "^4.17.21",
"@types/react": "^18.2.62"
"@types/react": "^18.3.3"
}
}
Loading

0 comments on commit 361deb6

Please sign in to comment.