diff --git a/Dockerfile b/Dockerfile index 71e61bc..c517598 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,4 +8,6 @@ COPY . . RUN yarn install +WORKDIR /app/packages/app + EXPOSE 8080 diff --git a/Makefile b/Makefile index 7db91ed..056dd59 100644 --- a/Makefile +++ b/Makefile @@ -13,7 +13,7 @@ pull: $(compose) $(dev_env) $(dev_profile) pull build: - $(compose) $(dev_env) $(dev_profile) build + $(compose) $(dev_env) $(dev_profile) build --no-cache up: $(compose) $(dev_env) $(dev_profile) up diff --git a/package.json b/package.json index fba7bfd..263192e 100644 --- a/package.json +++ b/package.json @@ -16,73 +16,7 @@ "start:debug": "nest start --debug --watch", "start:prod": "node dist/main", "lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix", - "test": "jest --testPathIgnorePatterns='/suites/'", - "test:watch": "jest --testPathIgnorePatterns='/suites/' --watch", - "test:cov": "jest --testPathIgnorePatterns='/suites/' --coverage", - "test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand", - "test:e2e": "jest --testPathIgnorePatterns='/suites/' --config ./test/jest-e2e.json", "typecheck": "tsc --noEmit", "prepare": "npm run prepare --workspaces" - }, - "dependencies": { - "@medplum/core": "^3.2.4", - "@nestjs/common": "^10.0.0", - "@nestjs/config": "^3.2.3", - "@nestjs/core": "^10.0.0", - "@nestjs/platform-express": "^10.0.0", - "@nestjs/swagger": "^7.4.0", - "@nestjs/typeorm": "^10.0.2", - "@types/fhir": "^0.0.41", - "axios": "^1.7.4", - "dotenv": "^16.4.5", - "flatted": "^3.3.1", - "http-proxy": "^1.18.1", - "http-proxy-middleware": "^3.0.0", - "pg": "^8.12.0", - "reflect-metadata": "^0.2.2", - "rxjs": "^7.8.1", - "swagger-ui-express": "^5.0.1", - "typeorm": "^0.3.20" - }, - "devDependencies": { - "@nestjs/cli": "^10.0.0", - "@nestjs/schematics": "^10.0.0", - "@nestjs/testing": "^10.0.0", - "@types/express": "^4.17.17", - "@types/jest": "^29.5.2", - "@types/node": "^20.3.1", - "@types/supertest": "^6.0.0", - "@typescript-eslint/eslint-plugin": "^7.0.0", - "@typescript-eslint/parser": "^7.0.0", - "eslint": "^8.42.0", - "eslint-config-prettier": "^9.0.0", - "eslint-plugin-prettier": "^5.0.0", - "jest": "^29.5.0", - "prettier": "^3.0.0", - "source-map-support": "^0.5.21", - "supertest": "^7.0.0", - "ts-jest": "^29.1.0", - "ts-loader": "^9.4.3", - "ts-node": "^10.9.1", - "tsconfig-paths": "^4.2.0", - "typescript": "^5.1.3" - }, - "jest": { - "moduleFileExtensions": [ - "js", - "json", - "ts" - ], - "testTimeout": 30000, - "rootDir": "./", - "testRegex": ".*\\.spec\\.ts$", - "transform": { - "^.+\\.(t|j)s$": "ts-jest" - }, - "collectCoverageFrom": [ - "**/*.(t|j)s" - ], - "coverageDirectory": "../coverage", - "testEnvironment": "node" } } diff --git a/README.md b/packages/app/README.md similarity index 100% rename from README.md rename to packages/app/README.md diff --git a/nest-cli.json b/packages/app/nest-cli.json similarity index 100% rename from nest-cli.json rename to packages/app/nest-cli.json diff --git a/packages/app/package.json b/packages/app/package.json new file mode 100644 index 0000000..fdfe102 --- /dev/null +++ b/packages/app/package.json @@ -0,0 +1,85 @@ +{ + "name": "backend", + "version": "0.0.1", + "description": "", + "author": "", + "private": true, + "license": "UNLICENSED", + "scripts": { + "build": "nest build", + "format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"", + "start": "nest start", + "start:dev": "nest start --watch", + "start:debug": "nest start --debug --watch", + "start:prod": "node dist/main", + "lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix", + "test": "jest --testPathIgnorePatterns='/suites/'", + "test:watch": "jest --testPathIgnorePatterns='/suites/' --watch", + "test:cov": "jest --testPathIgnorePatterns='/suites/' --coverage", + "test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand", + "test:e2e": "jest --testPathIgnorePatterns='/suites/' --config ./test/jest-e2e.json", + "typecheck": "tsc --noEmit", + "prepare": "tsc" + }, + "dependencies": { + "@medplum/core": "^3.2.4", + "@nestjs/common": "^10.0.0", + "@nestjs/config": "^3.2.3", + "@nestjs/core": "^10.0.0", + "@nestjs/platform-express": "^10.0.0", + "@nestjs/swagger": "^7.4.0", + "@nestjs/typeorm": "^10.0.2", + "@types/fhir": "^0.0.41", + "axios": "^1.7.4", + "dotenv": "^16.4.5", + "flatted": "^3.3.1", + "http-proxy": "^1.18.1", + "http-proxy-middleware": "^3.0.0", + "pg": "^8.12.0", + "reflect-metadata": "^0.2.2", + "rxjs": "^7.8.1", + "swagger-ui-express": "^5.0.1", + "typeorm": "^0.3.20" + }, + "devDependencies": { + "@nestjs/cli": "^10.0.0", + "@nestjs/schematics": "^10.0.0", + "@nestjs/testing": "^10.0.0", + "@types/express": "^4.17.17", + "@types/jest": "^29.5.2", + "@types/node": "^20.3.1", + "@types/supertest": "^6.0.0", + "@typescript-eslint/eslint-plugin": "^7.0.0", + "@typescript-eslint/parser": "^7.0.0", + "eslint": "^8.42.0", + "eslint-config-prettier": "^9.0.0", + "eslint-plugin-prettier": "^5.0.0", + "jest": "^29.5.0", + "prettier": "^3.0.0", + "source-map-support": "^0.5.21", + "supertest": "^7.0.0", + "ts-jest": "^29.1.0", + "ts-loader": "^9.4.3", + "ts-node": "^10.9.1", + "tsconfig-paths": "^4.2.0", + "typescript": "^5.1.3" + }, + "jest": { + "moduleFileExtensions": [ + "js", + "json", + "ts" + ], + "testTimeout": 30000, + "rootDir": "./", + "testRegex": ".*\\.spec\\.ts$", + "transform": { + "^.+\\.(t|j)s$": "ts-jest" + }, + "collectCoverageFrom": [ + "**/*.(t|j)s" + ], + "coverageDirectory": "../coverage", + "testEnvironment": "node" + } +} diff --git a/src/app.module.ts b/packages/app/src/app.module.ts similarity index 100% rename from src/app.module.ts rename to packages/app/src/app.module.ts diff --git a/src/custom-reporter.js b/packages/app/src/custom-reporter.js similarity index 100% rename from src/custom-reporter.js rename to packages/app/src/custom-reporter.js diff --git a/src/main.ts b/packages/app/src/main.ts similarity index 100% rename from src/main.ts rename to packages/app/src/main.ts diff --git a/src/modules/proxyapp/proxyapp.controller.ts b/packages/app/src/modules/proxyapp/proxyapp.controller.ts similarity index 96% rename from src/modules/proxyapp/proxyapp.controller.ts rename to packages/app/src/modules/proxyapp/proxyapp.controller.ts index 3ff7b7b..63cd429 100644 --- a/src/modules/proxyapp/proxyapp.controller.ts +++ b/packages/app/src/modules/proxyapp/proxyapp.controller.ts @@ -1,10 +1,10 @@ import { All, Controller, Param, Req, Res } from '@nestjs/common'; import { ApiTags, ApiOperation, ApiParam } from '@nestjs/swagger'; -import { createRequestObject } from 'src/utils/data'; import { captureResponseBody } from '@beda.software/client-testing-proxy-helpers'; import { RequestService } from '../requests/request.service'; import { SessionService } from '../sessions/session.service'; import { Request, Response } from 'express'; +import { createRequestObject } from '../../utils/data'; @ApiTags('proxy') @Controller('proxy') diff --git a/src/modules/proxyapp/proxyapp.module.ts b/packages/app/src/modules/proxyapp/proxyapp.module.ts similarity index 100% rename from src/modules/proxyapp/proxyapp.module.ts rename to packages/app/src/modules/proxyapp/proxyapp.module.ts diff --git a/src/modules/requests/request.controller.ts b/packages/app/src/modules/requests/request.controller.ts similarity index 100% rename from src/modules/requests/request.controller.ts rename to packages/app/src/modules/requests/request.controller.ts diff --git a/src/modules/requests/request.dto.ts b/packages/app/src/modules/requests/request.dto.ts similarity index 98% rename from src/modules/requests/request.dto.ts rename to packages/app/src/modules/requests/request.dto.ts index 4468b9d..0e08a38 100644 --- a/src/modules/requests/request.dto.ts +++ b/packages/app/src/modules/requests/request.dto.ts @@ -1,7 +1,7 @@ import { ApiProperty } from '@nestjs/swagger'; import { Request as RequestType, Response } from 'express'; import { Session } from '../sessions/session.entity'; -import { jsonbType } from 'src/utils/types'; +import { jsonbType } from '../../utils/types'; export class CreateRequestDto { @ApiProperty({ description: 'Session associated with the request' }) diff --git a/src/modules/requests/request.entity.ts b/packages/app/src/modules/requests/request.entity.ts similarity index 98% rename from src/modules/requests/request.entity.ts rename to packages/app/src/modules/requests/request.entity.ts index e6c4303..828d646 100644 --- a/src/modules/requests/request.entity.ts +++ b/packages/app/src/modules/requests/request.entity.ts @@ -1,7 +1,7 @@ import { Response, Request as RequestType } from 'express'; import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, ManyToOne } from 'typeorm'; import { Session } from '../sessions/session.entity'; -import { jsonbType } from 'src/utils/types'; +import { jsonbType } from '../../utils/types'; @Entity() export class Request { diff --git a/src/modules/requests/request.module.ts b/packages/app/src/modules/requests/request.module.ts similarity index 100% rename from src/modules/requests/request.module.ts rename to packages/app/src/modules/requests/request.module.ts diff --git a/src/modules/requests/request.service.ts b/packages/app/src/modules/requests/request.service.ts similarity index 100% rename from src/modules/requests/request.service.ts rename to packages/app/src/modules/requests/request.service.ts diff --git a/src/modules/sessions/interfaces.ts b/packages/app/src/modules/sessions/interfaces.ts similarity index 100% rename from src/modules/sessions/interfaces.ts rename to packages/app/src/modules/sessions/interfaces.ts diff --git a/src/modules/sessions/session.controller.ts b/packages/app/src/modules/sessions/session.controller.ts similarity index 100% rename from src/modules/sessions/session.controller.ts rename to packages/app/src/modules/sessions/session.controller.ts diff --git a/src/modules/sessions/session.dto.ts b/packages/app/src/modules/sessions/session.dto.ts similarity index 100% rename from src/modules/sessions/session.dto.ts rename to packages/app/src/modules/sessions/session.dto.ts diff --git a/src/modules/sessions/session.entity.ts b/packages/app/src/modules/sessions/session.entity.ts similarity index 100% rename from src/modules/sessions/session.entity.ts rename to packages/app/src/modules/sessions/session.entity.ts diff --git a/src/modules/sessions/session.module.ts b/packages/app/src/modules/sessions/session.module.ts similarity index 100% rename from src/modules/sessions/session.module.ts rename to packages/app/src/modules/sessions/session.module.ts diff --git a/src/modules/sessions/session.service.ts b/packages/app/src/modules/sessions/session.service.ts similarity index 100% rename from src/modules/sessions/session.service.ts rename to packages/app/src/modules/sessions/session.service.ts diff --git a/src/modules/test_runs/testRun.controller.ts b/packages/app/src/modules/test_runs/testRun.controller.ts similarity index 96% rename from src/modules/test_runs/testRun.controller.ts rename to packages/app/src/modules/test_runs/testRun.controller.ts index c279793..8c077cb 100644 --- a/src/modules/test_runs/testRun.controller.ts +++ b/packages/app/src/modules/test_runs/testRun.controller.ts @@ -6,11 +6,11 @@ import { runCLI } from '@jest/core'; import { TestRunService } from './testRun.service'; import { SessionService } from '../sessions/session.service'; import { TestRun } from './testRun.entity'; -import { createTestListObject } from 'src/utils/data'; +import { createTestListObject } from '../../utils/data'; const testOptions = { - globalSetup: './src/utils/setup/jest.setup.ts', - globalTeardown: './src/utils/setup/jest.teardown.ts', + globalSetup: './../../utils/setup/jest.setup.ts', + globalTeardown: './../../utils/setup/jest.teardown.ts', rootDir: './', testEnvironment: 'node', moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'], diff --git a/src/modules/test_runs/testRun.dto.ts b/packages/app/src/modules/test_runs/testRun.dto.ts similarity index 96% rename from src/modules/test_runs/testRun.dto.ts rename to packages/app/src/modules/test_runs/testRun.dto.ts index 00d312c..a6012fe 100644 --- a/src/modules/test_runs/testRun.dto.ts +++ b/packages/app/src/modules/test_runs/testRun.dto.ts @@ -1,6 +1,6 @@ import { ApiProperty } from '@nestjs/swagger'; import { json } from 'node:stream/consumers'; -import { jsonbType } from 'src/utils/types'; +import { jsonbType } from '../../utils/types'; import { Session } from '../sessions/session.entity'; export class CreateTestRunDto { diff --git a/src/modules/test_runs/testRun.entity.ts b/packages/app/src/modules/test_runs/testRun.entity.ts similarity index 96% rename from src/modules/test_runs/testRun.entity.ts rename to packages/app/src/modules/test_runs/testRun.entity.ts index dd87a95..feb7208 100644 --- a/src/modules/test_runs/testRun.entity.ts +++ b/packages/app/src/modules/test_runs/testRun.entity.ts @@ -1,6 +1,6 @@ import { Column, CreateDateColumn, Entity, ManyToOne, PrimaryGeneratedColumn } from 'typeorm'; import { Session } from '../sessions/session.entity'; -import { jsonbType } from 'src/utils/types'; +import { jsonbType } from '../../utils/types'; export enum TestRunStatus { NOT_STARTED = 'not-started', diff --git a/src/modules/test_runs/testRun.module.ts b/packages/app/src/modules/test_runs/testRun.module.ts similarity index 100% rename from src/modules/test_runs/testRun.module.ts rename to packages/app/src/modules/test_runs/testRun.module.ts diff --git a/src/modules/test_runs/testRun.service.ts b/packages/app/src/modules/test_runs/testRun.service.ts similarity index 100% rename from src/modules/test_runs/testRun.service.ts rename to packages/app/src/modules/test_runs/testRun.service.ts diff --git a/src/suites/1.0.0-ballot/Patient/patients-2nd.spec.ts b/packages/app/src/suites/1.0.0-ballot/Patient/patients-2nd.spec.ts similarity index 100% rename from src/suites/1.0.0-ballot/Patient/patients-2nd.spec.ts rename to packages/app/src/suites/1.0.0-ballot/Patient/patients-2nd.spec.ts diff --git a/src/suites/1.0.0-ballot/Patient/patients.spec.ts b/packages/app/src/suites/1.0.0-ballot/Patient/patients.spec.ts similarity index 100% rename from src/suites/1.0.0-ballot/Patient/patients.spec.ts rename to packages/app/src/suites/1.0.0-ballot/Patient/patients.spec.ts diff --git a/src/utils/clientTestingHelpers.spec.ts b/packages/app/src/utils/clientTestingHelpers.spec.ts similarity index 100% rename from src/utils/clientTestingHelpers.spec.ts rename to packages/app/src/utils/clientTestingHelpers.spec.ts diff --git a/src/utils/clientTestingHelpers.ts b/packages/app/src/utils/clientTestingHelpers.ts similarity index 97% rename from src/utils/clientTestingHelpers.ts rename to packages/app/src/utils/clientTestingHelpers.ts index 5b0ff92..bf56053 100644 --- a/src/utils/clientTestingHelpers.ts +++ b/packages/app/src/utils/clientTestingHelpers.ts @@ -1,4 +1,4 @@ -import { Request } from 'src/modules/requests/request.entity'; +import { Request } from '../modules/requests/request.entity'; import { Repository } from 'typeorm'; /** diff --git a/src/utils/data.spec.ts b/packages/app/src/utils/data.spec.ts similarity index 100% rename from src/utils/data.spec.ts rename to packages/app/src/utils/data.spec.ts diff --git a/src/utils/data.ts b/packages/app/src/utils/data.ts similarity index 95% rename from src/utils/data.ts rename to packages/app/src/utils/data.ts index ebd42ac..72942a0 100644 --- a/src/utils/data.ts +++ b/packages/app/src/utils/data.ts @@ -1,7 +1,7 @@ import { parseSearchRequest } from '@medplum/core'; import { Request, Response } from 'express'; -import { CreateRequestDto } from 'src/modules/requests/request.dto'; -import { Session } from 'src/modules/sessions/session.entity'; +import { CreateRequestDto } from '../modules/requests/request.dto'; +import { Session } from '../modules/sessions/session.entity'; import { getFHIRAction } from '@beda.software/client-testing-helpers'; export function createRequestObject( diff --git a/src/utils/setup/jest.setup.ts b/packages/app/src/utils/setup/jest.setup.ts similarity index 100% rename from src/utils/setup/jest.setup.ts rename to packages/app/src/utils/setup/jest.setup.ts diff --git a/src/utils/setup/jest.teardown.ts b/packages/app/src/utils/setup/jest.teardown.ts similarity index 100% rename from src/utils/setup/jest.teardown.ts rename to packages/app/src/utils/setup/jest.teardown.ts diff --git a/src/utils/types.ts b/packages/app/src/utils/types.ts similarity index 100% rename from src/utils/types.ts rename to packages/app/src/utils/types.ts diff --git a/packages/app/tsconfig.build.json b/packages/app/tsconfig.build.json new file mode 100644 index 0000000..64f86c6 --- /dev/null +++ b/packages/app/tsconfig.build.json @@ -0,0 +1,4 @@ +{ + "extends": "./tsconfig.json", + "exclude": ["node_modules", "test", "dist", "**/*spec.ts"] +} diff --git a/packages/app/tsconfig.json b/packages/app/tsconfig.json new file mode 100644 index 0000000..95f5641 --- /dev/null +++ b/packages/app/tsconfig.json @@ -0,0 +1,21 @@ +{ + "compilerOptions": { + "module": "commonjs", + "declaration": true, + "removeComments": true, + "emitDecoratorMetadata": true, + "experimentalDecorators": true, + "allowSyntheticDefaultImports": true, + "target": "ES2021", + "sourceMap": true, + "outDir": "./dist", + "baseUrl": "./", + "incremental": true, + "skipLibCheck": true, + "strictNullChecks": false, + "noImplicitAny": false, + "strictBindCallApply": false, + "forceConsistentCasingInFileNames": false, + "noFallthroughCasesInSwitch": false + } +} diff --git a/test/app.e2e-spec.ts b/test/app.e2e-spec.ts deleted file mode 100644 index 42edde7..0000000 --- a/test/app.e2e-spec.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { Test, TestingModule } from '@nestjs/testing'; -import { INestApplication } from '@nestjs/common'; -import * as request from 'supertest'; -import { AppModule } from '../src/app.module'; - -describe('AppController (e2e)', () => { - let app: INestApplication; - - beforeEach(async () => { - const moduleFixture: TestingModule = await Test.createTestingModule({ - imports: [AppModule], - }).compile(); - - app = moduleFixture.createNestApplication(); - await app.init(); - }); - - it('/ (GET)', () => { - return request(app.getHttpServer()).get('/').expect(200).expect('Hello World!'); - }); -}); diff --git a/test/jest-e2e.json b/test/jest-e2e.json deleted file mode 100644 index e9d912f..0000000 --- a/test/jest-e2e.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "moduleFileExtensions": ["js", "json", "ts"], - "rootDir": ".", - "testEnvironment": "node", - "testRegex": ".e2e-spec.ts$", - "transform": { - "^.+\\.(t|j)s$": "ts-jest" - } -}