From d7074a166f7c78942e77b0857f681e52a4481c18 Mon Sep 17 00:00:00 2001 From: Patrick Brandt Date: Thu, 1 Oct 2020 17:28:15 -0400 Subject: [PATCH] WIP: moving files out of lib and into requisite package directories - renaming file path references where neccessary --- cdk.json | 2 +- lib/functions/package-lock.json | 18 ------------------ lib/functions/package.json | 15 --------------- {lib => packages}/functions/checkout.ts | 2 +- {lib => packages}/functions/index.ts | 0 packages/functions/package.json | 6 +++++- {lib => packages}/functions/ping.ts | 0 {lib => packages}/functions/response.ts | 0 .../reactshoppe-api}/reactshoppe-api.ts | 2 +- .../reactshoppe-database.ts | 0 {bin => packages/stack/bin}/reactshoppe-api.ts | 2 +- .../stack}/reactshoppe-api-stack.ts | 4 ++-- test/reactshoppe-api.test.ts | 2 +- 13 files changed, 12 insertions(+), 41 deletions(-) delete mode 100644 lib/functions/package-lock.json delete mode 100644 lib/functions/package.json rename {lib => packages}/functions/checkout.ts (92%) rename {lib => packages}/functions/index.ts (100%) rename {lib => packages}/functions/ping.ts (100%) rename {lib => packages}/functions/response.ts (100%) rename {lib => packages/reactshoppe-api}/reactshoppe-api.ts (87%) rename {lib => packages/reactshoppe-database}/reactshoppe-database.ts (100%) rename {bin => packages/stack/bin}/reactshoppe-api.ts (78%) rename {lib => packages/stack}/reactshoppe-api-stack.ts (73%) diff --git a/cdk.json b/cdk.json index f438c23..023df4d 100644 --- a/cdk.json +++ b/cdk.json @@ -1,5 +1,5 @@ { - "app": "npx ts-node bin/reactshoppe-api.ts", + "app": "npx ts-node packages/stack/bin/reactshoppe-api.ts", "context": { "@aws-cdk/core:enableStackNameDuplicates": "true", "aws-cdk:enableDiffNoFail": "true" diff --git a/lib/functions/package-lock.json b/lib/functions/package-lock.json deleted file mode 100644 index cd6d1b6..0000000 --- a/lib/functions/package-lock.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "name": "functions", - "version": "1.0.0", - "lockfileVersion": 1, - "requires": true, - "dependencies": { - "@types/uuid": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-8.0.0.tgz", - "integrity": "sha512-xSQfNcvOiE5f9dyd4Kzxbof1aTrLobL278pGLKOZI6esGfZ7ts9Ka16CzIN6Y8hFHE1C7jIBZokULhK1bOgjRw==" - }, - "uuid": { - "version": "8.1.0", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.1.0.tgz", - "integrity": "sha512-CI18flHDznR0lq54xBycOVmphdCYnQLKn8abKn7PXUiKUGdEd+/l9LWNJmugXel4hXq7S+RMNl34ecyC9TntWg==" - } - } -} diff --git a/lib/functions/package.json b/lib/functions/package.json deleted file mode 100644 index 6ae46d3..0000000 --- a/lib/functions/package.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "name": "functions", - "version": "1.0.0", - "description": "", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "author": "", - "license": "ISC", - "dependencies": { - "@types/uuid": "^8.0.0", - "uuid": "^8.1.0" - } -} diff --git a/lib/functions/checkout.ts b/packages/functions/checkout.ts similarity index 92% rename from lib/functions/checkout.ts rename to packages/functions/checkout.ts index 4a715b7..10ff111 100644 --- a/lib/functions/checkout.ts +++ b/packages/functions/checkout.ts @@ -1,7 +1,7 @@ import { APIGatewayProxyEvent } from 'aws-lambda'; import * as AWS from 'aws-sdk'; import { v4 as uuidv4 } from 'uuid'; -import { TableNames } from '../reactshoppe-database'; +import { TableNames } from '../reactshoppe-database/reactshoppe-database'; import { success, failure } from './response'; export default async (event: APIGatewayProxyEvent) => { diff --git a/lib/functions/index.ts b/packages/functions/index.ts similarity index 100% rename from lib/functions/index.ts rename to packages/functions/index.ts diff --git a/packages/functions/package.json b/packages/functions/package.json index fce4c42..61193dd 100644 --- a/packages/functions/package.json +++ b/packages/functions/package.json @@ -6,5 +6,9 @@ "author": "Patrick Brandt ", "homepage": "https://github.com/patrick-fs/reactshoppe-api#readme", "license": "ISC", - "main": "lib/functions.js" + "main": "functions.js", + "dependencies": { + "@types/uuid": "^8.0.0", + "uuid": "^8.1.0" + } } diff --git a/lib/functions/ping.ts b/packages/functions/ping.ts similarity index 100% rename from lib/functions/ping.ts rename to packages/functions/ping.ts diff --git a/lib/functions/response.ts b/packages/functions/response.ts similarity index 100% rename from lib/functions/response.ts rename to packages/functions/response.ts diff --git a/lib/reactshoppe-api.ts b/packages/reactshoppe-api/reactshoppe-api.ts similarity index 87% rename from lib/reactshoppe-api.ts rename to packages/reactshoppe-api/reactshoppe-api.ts index 52bb98a..84b4717 100644 --- a/lib/reactshoppe-api.ts +++ b/packages/reactshoppe-api/reactshoppe-api.ts @@ -9,7 +9,7 @@ export class ReactshoppeApi extends core.Construct { this.handler = new lambda.Function(this, 'ApiHandler', { runtime: lambda.Runtime.NODEJS_10_X, - code: lambda.Code.fromAsset('./lib/functions'), // this path is relative to the project root + code: lambda.Code.fromAsset('./packages/functions'), // this path is relative to the project root handler: 'index.main', }); diff --git a/lib/reactshoppe-database.ts b/packages/reactshoppe-database/reactshoppe-database.ts similarity index 100% rename from lib/reactshoppe-database.ts rename to packages/reactshoppe-database/reactshoppe-database.ts diff --git a/bin/reactshoppe-api.ts b/packages/stack/bin/reactshoppe-api.ts similarity index 78% rename from bin/reactshoppe-api.ts rename to packages/stack/bin/reactshoppe-api.ts index a36b757..8b0d6de 100644 --- a/bin/reactshoppe-api.ts +++ b/packages/stack/bin/reactshoppe-api.ts @@ -1,7 +1,7 @@ #!/usr/bin/env node import 'source-map-support/register'; import * as cdk from '@aws-cdk/core'; -import { ReactshoppeApiStack } from '../lib/reactshoppe-api-stack'; +import { ReactshoppeApiStack } from '../reactshoppe-api-stack'; const app = new cdk.App(); new ReactshoppeApiStack(app, 'ReactshoppeApiStack', { description: 'Simple sample ecommerce service with New Relic' }); diff --git a/lib/reactshoppe-api-stack.ts b/packages/stack/reactshoppe-api-stack.ts similarity index 73% rename from lib/reactshoppe-api-stack.ts rename to packages/stack/reactshoppe-api-stack.ts index 8ede0ee..12fceac 100644 --- a/lib/reactshoppe-api-stack.ts +++ b/packages/stack/reactshoppe-api-stack.ts @@ -1,6 +1,6 @@ import * as cdk from '@aws-cdk/core'; -import { ReactshoppeDatabase } from './reactshoppe-database'; -import { ReactshoppeApi } from './reactshoppe-api'; +import { ReactshoppeDatabase } from '../reactshoppe-database/reactshoppe-database'; +import { ReactshoppeApi } from '../reactshoppe-api/reactshoppe-api'; export class ReactshoppeApiStack extends cdk.Stack { constructor(scope: cdk.Construct, id: string, props?: cdk.StackProps) { diff --git a/test/reactshoppe-api.test.ts b/test/reactshoppe-api.test.ts index 1623a91..1ce4932 100644 --- a/test/reactshoppe-api.test.ts +++ b/test/reactshoppe-api.test.ts @@ -1,6 +1,6 @@ import { expect as expectCDK, matchTemplate, MatchStyle } from '@aws-cdk/assert'; import * as cdk from '@aws-cdk/core'; -import * as ReactshoppeApi from '../lib/reactshoppe-api-stack'; +import * as ReactshoppeApi from '../packages/stack/reactshoppe-api-stack'; test('Empty Stack', () => { const app = new cdk.App();