Skip to content

Commit

Permalink
Bundle backend as reusable library and create server-doj and server-k…
Browse files Browse the repository at this point in the history
…ansas demos (#231)

* Move doj-demo to packages/server, and create an initial app/server-doj application that imports an Express handler from atj/server. TODO: clean up exports, get typings working.

* App handler serving content, but not 100% working

* Server package rendering existing client-side behavior correctly.

* Add a basic test that confirms the home page is rendered on the DOJ custom server.

* Remove debug logging from layout component

* Server dev tasks - build esm

* Make component signatures in spotlight app consistent with updates for @atj/server

* Update docker config for new server-doj and server-kansas apps.

* Add server-kansas app

* Updates to Terraform to accomodate new server package.

* Temporary: Add `astro-library` to deploy, to test TF updates

* Log deployEnv on error

* Temp: hardcode main deploy for testing

* Update deploy script to use arguments for target environment rather that directly pulling the git ref

* Try to reference via context: env.*. I don't think this will work, but found some suggestions that it might.

* Give up trying to globally declare the deploy env, and pass on each users clause

* Build the server entrypoint as part of standard build

* Use injected site title in header rather than hardcoded DOJ name.

* Remove references to "Spotlight" in the form service

* Update a couple build labels

* Add back FormRouter.stories.ts

* Build before testing. Unfortunate, but we need a build to test the demo servers.

* Add symlinks to sample-documents and storybook build

* Work-around typing issue with svg icons

* mask "no explicit any" eslint warning on svg icon hack

* Fix comment in Astro App.Locals declaration

* Explicitness on context arg passing

* Document new structure in READMEs

* Remove debug deploys on astro-library branch.

* More generic example title

* Autoformat
  • Loading branch information
danielnaab authored Jun 28, 2024
1 parent 30d1af1 commit 69da3eb
Show file tree
Hide file tree
Showing 91 changed files with 906 additions and 521 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/_docker-build-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,12 @@ on:
repo-name:
type: string
default: ${{ github.event.repository.name }}
tag-name:
type: string
default: ${{ github.ref_name }}

env:
TAG_NAME: ${{ github.ref_name }}
TAG_NAME: ${{ inputs.tag-name }}
APP_DIR: ${{ inputs.app-name }}
REGISTRY_PATH: ghcr.io/${{ inputs.org-name }}/${{ inputs.repo-name }}/${{ inputs.app-name }}
COMMIT_SHA: ${{github.sha}}
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/_validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ jobs:
- name: Install dependencies
run: pnpm install

# While most of the test suite is self-contained, the tests for the demo
# servers require a prod build of @atj/server.
- name: Build
run: pnpm build

- name: Lint source code
shell: bash
run: pnpm lint
Expand Down
14 changes: 8 additions & 6 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,19 @@ jobs:
uses: ./.github/workflows/_docker-build-image.yml
secrets: inherit
with:
app-name: doj-demo
app-name: server-doj
#tag-name: main

build-image-spotlight:
build-image-kansas:
uses: ./.github/workflows/_docker-build-image.yml
secrets: inherit
with:
app-name: spotlight
app-name: server-kansas
#tag-name: main

deploy:
needs: [build-image-doj, build-image-spotlight]
needs: [build-image-doj, build-image-kansas]
uses: ./.github/workflows/_terraform-apply.yml
secrets: inherit
with:
deploy-env: ${{ github.ref_name }}
#with:
# deploy-env: main
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ RUN pnpm build
RUN pnpm --filter=$APP_DIR --prod deploy /app/$APP_DIR

FROM base AS app
ARG APP_DIR=doj-demo
ARG APP_DIR

LABEL org.opencontainers.image.description 10x-atj DOJ demo
LABEL org.opencontainers.image.description 10x Access to Justice Form Builder

COPY --from=build /app/$APP_DIR /app/$APP_DIR
COPY --from=build /usr/src/app/apps/$APP_DIR/dist /app/$APP_DIR/dist
Expand All @@ -28,7 +28,7 @@ ENV HOST=0.0.0.0
ENV PORT=4321
EXPOSE 4321

CMD [ "node", "./dist/server/entry.mjs" ]
CMD [ "node", "./dist/index.js" ]

#HEALTHCHECK --interval=5m --timeout=3s \
# CMD curl -f http://localhost:4321/ || exit 1
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ Test bed for ATJ platform tooling, completed as part of the [10x Digital Access

## Overview

The project dependencies within the workspace are:

![workspace project dependencies](./workspace-dependencies.svg)
The workspace dependencies are depicted in this auto-generated [workspace project dependencies graph](./workspace-dependencies.svg).

Additional documentation:

Expand All @@ -26,7 +24,7 @@ The platform is made up of the following high-level terms.

- **Blueprint**: produced by a content author, the blueprint defines the structure of an interactive session between a court and an SRL
- **Conversation**: one instance of a blueprint; the interactive session between a court and an SRL. Other terms for this concept include dialogue or session.
- **Pattern**: the building blocks of a blueprint, patterns implement UX best-practices, defining the content and behavior of the user interface.
- **Pattern/template**: the building blocks of a blueprint, patterns implement UX best-practices, defining the content and behavior of the user interface.
- **Prompt**: produced by a pattern, the prompt defines what is presented to the end user at single point in a conversation.
- **Component**: user interface component that acts as the building block of prompts.

Expand Down
47 changes: 0 additions & 47 deletions apps/doj-demo/README.md

This file was deleted.

26 changes: 0 additions & 26 deletions apps/doj-demo/src/components/AppAvailableFormList.tsx

This file was deleted.

28 changes: 0 additions & 28 deletions apps/doj-demo/src/components/AppFormManager.tsx

This file was deleted.

18 changes: 0 additions & 18 deletions apps/doj-demo/src/components/AppFormRouter.tsx

This file was deleted.

40 changes: 0 additions & 40 deletions apps/doj-demo/src/context.ts

This file was deleted.

1 change: 0 additions & 1 deletion apps/doj-demo/src/env.d.ts

This file was deleted.

8 changes: 0 additions & 8 deletions apps/doj-demo/src/pages/forms/index.astro

This file was deleted.

8 changes: 0 additions & 8 deletions apps/doj-demo/src/pages/index.astro

This file was deleted.

8 changes: 0 additions & 8 deletions apps/doj-demo/src/pages/manage/index.astro

This file was deleted.

31 changes: 0 additions & 31 deletions apps/doj-demo/src/routes.ts

This file was deleted.

1 change: 1 addition & 0 deletions apps/server-doj/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dist/
3 changes: 3 additions & 0 deletions apps/server-doj/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# @atj/server-doj

Web server to demonstrate forms for DOJ's Office of the Pardon Attorney.
22 changes: 22 additions & 0 deletions apps/server-doj/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"name": "@atj/server-doj",
"version": "1.0.0",
"description": "Form server instance for DOJ",
"type": "module",
"license": "CC0",
"main": "src/index.ts",
"scripts": {
"start": "node dist/index.js",
"build": "tsup src/* --format esm",
"dev": "tsup src/* --watch --format esm",
"test": "vitest run --coverage"
},
"dependencies": {
"@atj/server": "workspace:*"
},
"devDependencies": {
"@types/node": "^20.14.8",
"@types/supertest": "^6.0.2",
"supertest": "^7.0.0"
}
}
8 changes: 8 additions & 0 deletions apps/server-doj/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { createCustomServer } from './server';

const port = process.env.PORT || 4321;
const app = await createCustomServer();

app.listen(port, () => {
console.log(`Server running on http://localhost:${port}`);
});
7 changes: 7 additions & 0 deletions apps/server-doj/src/server.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { createServer } from '@atj/server/dist/index.js';

export const createCustomServer = () => {
return createServer({
title: 'DOJ Form Service',
});
};
18 changes: 18 additions & 0 deletions apps/server-doj/tests/integration.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import request from 'supertest';
import { beforeAll, describe, expect, test } from 'vitest';

import { createCustomServer } from '../src/server';

describe('DOJ Form Service', () => {
let app: any;

beforeAll(async () => {
app = await createCustomServer();
});

test('renders the home page', async () => {
const response = await request(app).get('/');
expect(response.ok).toBe(true);
expect(response.text).toMatch(/DOJ Form Service/);
});
});
11 changes: 11 additions & 0 deletions apps/server-doj/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"module": "ESNext",
"emitDeclarationOnly": true,
"outDir": "./dist"
},
"include": ["./src/**/*"],
"exclude": ["./dist"],
"references": []
}
1 change: 1 addition & 0 deletions apps/server-kansas/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dist/
Loading

0 comments on commit 69da3eb

Please sign in to comment.