Skip to content

Commit

Permalink
Merge pull request #80 from rtjord/dev
Browse files Browse the repository at this point in the history
Deploy to production
  • Loading branch information
rtjord authored Dec 3, 2024
2 parents b90f0e1 + 4171bdf commit 265b984
Show file tree
Hide file tree
Showing 93 changed files with 12,907 additions and 4,339 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/deploy_dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ jobs:

- name: Build
working-directory: backend
run: npm run build && sam build --use-container
run: npm run build:linux

- name: Configure AWS Credentials for Development Account
uses: aws-actions/[email protected]
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy_prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:

- name: Build
working-directory: backend
run: npm run build && sam build --use-container
run: npm run build:linux

- name: Configure AWS Credentials for Production Account
uses: aws-actions/[email protected]
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/test_backend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,6 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
LOG_FILE: test.log
LOG_LEVEL: 2
COMMON_PATH: '../../common'
SERVICES_PATH: '../../services/rate'

1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
.env
*.zip

# amplify
node_modules
Expand Down
24 changes: 24 additions & 0 deletions backend/copy_package_json.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import * as fs from 'fs';
import * as path from 'path';

function copyFile(src, dest) {
const destDir = path.dirname(dest);
if (!fs.existsSync(destDir)) {
fs.mkdirSync(destDir, { recursive: true });
}
fs.copyFileSync(src, dest);
console.log(`Copied ${src} to ${dest}`);
}

// For each handler subdirectory in src/handlers, copy the package.json file to dist/handlers
const handlersDir = 'src/handlers';
const destBaseDir = 'dist/handlers';

for (const handler of fs.readdirSync(handlersDir)) {
const src = path.join(handlersDir, handler, 'package.json');
const dest = path.join(destBaseDir, handler, 'package.json');

if (fs.existsSync(src)) {
copyFile(src, dest);
}
}
12 changes: 9 additions & 3 deletions backend/eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,19 @@ import globals from "globals";
import pluginJs from "@eslint/js";
import tseslint from "typescript-eslint";


/** @type {import('eslint').Linter.Config[]} */
export default [
{files: ["**/*.{js,mjs,cjs,ts}"]},
{files: ["**/*.js"], languageOptions: {sourceType: "commonjs"}},
{languageOptions: { globals: globals.browser }},
pluginJs.configs.recommended,
...tseslint.configs.recommended,
{ignores: ["**/node_modules/**", "**/dist/**", "**/build/**"]},
];
{ignores: ["**/node_modules/**", "**/dist/**", "**/build/**", "**/services/**", "**layers/dependencies/**", "**/coverage/**"]},
{
rules: {
"@typescript-eslint/no-explicit-any": "error",
"@typescript-eslint/no-unused-vars": "error",
"@typescript-eslint/no-require-imports": "off"
}
}
];
11 changes: 11 additions & 0 deletions backend/events/ByName.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

{
"pathParameters": {
"name": "example1"
},
"httpMethod": "GET",
"requestContext": {
"resourcePath": "/package/byName/{name}",
"httpMethod": "GET"
}
}
12 changes: 12 additions & 0 deletions backend/events/Create.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"body": "{\"metadata\":{\"Name\":\"Underscore\",\"Version\":\"1.0.0\"},\"data\":{\"Content\":\"<base64_encoded_content>\",\"PackageRating\":{\"RampUp\":0.7,\"Correctness\":0.8,\"BusFactor\":0.9,\"ResponsiveMaintainer\":0.85,\"LicenseScore\":0.95,\"GoodPinningPractice\":0.8,\"PullRequest\":0.9,\"NetScore\":0.85}},\"user\":{\"name\":\"John Doe\",\"isAdmin\":true}}",
"headers": {
"Content-Type": "application/json"
},
"requestContext": {
"httpMethod": "POST",
"path": "/package"
}
}


10 changes: 10 additions & 0 deletions backend/events/Delete.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"pathParameters": {
"id": "underscore:1.0.0"
},
"requestContext": {
"httpMethod": "DELETE",
"path": "/package/underscore:1.0.0"
}
}

22 changes: 22 additions & 0 deletions backend/events/Retrieve.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"resource": "/package/{id}",
"path": "/package/underscore:1.0.0",
"httpMethod": "GET",
"headers": {
"Content-Type": "application/json"
},
"pathParameters": {
"id": "underscore:1.0.0"
},
"requestContext": {
"authorizer": {
"claims": {
"name": "John Doe",
"isAdmin": true
}
}
},
"body": null,
"isBase64Encoded": false
}

10 changes: 10 additions & 0 deletions backend/events/Update.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"pathParameters": {
"id": "Underscore:1.0.0"
},
"body": "{\n \"metadata\": {\n \"Name\": \"underscore\",\n \"Version\": \"1.0.0\"\n },\n \"data\": {\n \"Content\": \"UEsDBBQAAAAIAAeLbUst1IfSAgAAAAIAAAALABwAaW5kZXguanNVVAkAA2FkZGOWP6NpX3V4CwABBPUBAAAEFAAAAGlmIChwcm9jZXNzLmFyZ3YubGVuZ3RoID09PSA3KSB7XG4gICAgY29uc29sZS5sb2coJ1N1Y2Nlc3MnKTtcbiAgICBwcm9jZXNzLmV4aXQoMCk7XG59IGVsc2Uge1xuICAgIGNvbnNvbGUubG9nKCdGYWlsZWQnKTtcbiAgICBwcm9jZXNzLmV4aXQoMSk7XG59XG4=\",\n \"URL\": null,\n \"JSProgram\": \"if (process.argv.length === 7) { console.log('Success'); process.exit(0); } else { console.log('Failed'); process.exit(1); }\"\n }\n}",
"headers": {
"Content-Type": "application/json"
}
}

5 changes: 3 additions & 2 deletions backend/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ export default {
preset: 'ts-jest',
testEnvironment: 'node',
// Add other options here, like test match patterns, coverage, etc.
testMatch: ['**/*.test.ts']
};
testMatch: ['**/*.test.ts'],
setupFiles: ['./jest.setup.ts'], // Ensure the setup file is loaded
};
3 changes: 3 additions & 0 deletions backend/jest.setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import * as dotenv from 'dotenv';

dotenv.config(); // Load environment variables from .env
Loading

0 comments on commit 265b984

Please sign in to comment.