Skip to content

Commit 52b19cb

Browse files
authored
Backend webpack (#1264)
Switch to webpack on the backend. serverless-plugin-typescript is deprecated and has some bizarre conflict with publishing lambda layers, which will be needed by #1263
1 parent df6fbf6 commit 52b19cb

20 files changed

+8278
-21746
lines changed

backend/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ jspm_packages
55
# Serverless directories
66
.serverless
77
.build
8+
.webpack
89

910
secrets.*.yml
1011
tsoa-build

backend/appHandler.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
import 'reflect-metadata';
12
import serverlessHttp from 'serverless-http';
2-
import app from './src/app';
33
import 'source-map-support/register';
4-
import 'reflect-metadata';
4+
import app from './src/app';
55

66
export const handler = serverlessHttp(app);

backend/convertImage.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,9 @@ export const handler = async (event: S3Event): Promise<unknown> => {
5959
throw new Error('Source object not found');
6060
}
6161

62-
let inputBuffer = Buffer.from(await inputObject.Body.transformToByteArray());
62+
let inputBuffer: Buffer = Buffer.from(
63+
await inputObject.Body.transformToByteArray()
64+
);
6365

6466
// Crop laserdisc video frames to eliminate borders and superimposed banner
6567
if (await LaserdiscUtils.isLaserdiscVideoFrame(inputBuffer)) {
23.6 MB
Binary file not shown.

backend/package-lock.json

Lines changed: 8059 additions & 21702 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

backend/package.json

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"@aws-sdk/client-s3": "^3.741.0",
2424
"@hey-api/openapi-ts": "^0.64.1",
2525
"@sparticuz/chromium": "^132.0.0",
26+
"@tsoa/cli": "^4.1.3",
2627
"@types/aws-lambda": "^8.10.147",
2728
"@types/cookie-parser": "^1.4.3",
2829
"@types/cors": "^2.8.17",
@@ -42,6 +43,7 @@
4243
"@types/source-map-support": "^0.5.6",
4344
"@typescript-eslint/eslint-plugin": "^5.61.0",
4445
"@typescript-eslint/parser": "^5.61.1",
46+
"copy-webpack-plugin": "^13.0.1",
4547
"eslint": "^8.52.0",
4648
"eslint-config-jboolean": "^0.1.0",
4749
"eslint-config-prettier": "^8.5.0",
@@ -53,14 +55,18 @@
5355
"serverless-lambda-edge-pre-existing-cloudfront": "^1.2.0",
5456
"serverless-offline": "^13.8.3",
5557
"serverless-plugin-select": "^2.0.0-rc.1",
56-
"serverless-plugin-typescript": "^2.1.5",
57-
"typescript": "^5.2.2"
58+
"serverless-webpack": "^5.15.2",
59+
"ts-loader": "^9.5.4",
60+
"typescript": "^5.2.2",
61+
"webpack": "^5.101.3",
62+
"webpack-node-externals": "^3.0.0"
5863
},
5964
"dependencies": {
6065
"@hey-api/client-axios": "^0.6.1",
6166
"@sentry/integrations": "^7.36.0",
6267
"@sentry/node": "^7.36.0",
6368
"@sentry/tracing": "^7.36.0",
69+
"@tsoa/runtime": "^4.1.3",
6470
"@types/multer": "^1.4.11",
6571
"axios": "^1.7.4",
6672
"cookie-parser": "^1.4.6",
@@ -85,7 +91,6 @@
8591
"sharp": "^0.31.3",
8692
"source-map-support": "^0.5.21",
8793
"stripe": "^17.7.0",
88-
"tsoa": "^4.1.3",
8994
"typeorm": "^0.3.17",
9095
"typeorm-naming-strategies": "^4.1.0"
9196
},

backend/serverless.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
service: fourtiesnyc
22
package:
33
individually: false
4-
include:
5-
- certs/*
4+
patterns:
5+
- 'certs/**'
6+
- '!chromium/**'
67

78
provider:
89
name: aws
@@ -37,7 +38,7 @@ provider:
3738
PRINTFUL_SK: ${ssm:/${self:service}-${sls:stage}-printful-sk}
3839
plugins:
3940
- serverless-plugin-select
40-
- serverless-plugin-typescript
41+
- serverless-webpack
4142
- serverless-domain-manager
4243
- serverless-offline
4344

@@ -118,6 +119,8 @@ functions:
118119
handler: registerPrintfulWebhooks.handler
119120
# Invoked manually
120121
custom:
122+
webpack:
123+
webpackConfig: 'webpack.config.js'
121124
bucket: fourties-photos
122125
domain:
123126
production: api.1940s.nyc

backend/src/api/AuthenticationController.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import * as express from 'express';
2-
import { BadRequest } from 'http-errors';
31
import {
42
Body,
53
Controller,
@@ -9,7 +7,9 @@ import {
97
Request,
108
Route,
119
Security,
12-
} from 'tsoa';
10+
} from '@tsoa/runtime';
11+
import * as express from 'express';
12+
import { BadRequest } from 'http-errors';
1313
import * as UserService from '../business/users/UserService';
1414
import required from '../business/utils/required';
1515
import LoginOutcome from '../enum/LoginOutcome';

backend/src/api/ColorizationController.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
import * as express from 'express';
2-
import { BadRequest } from 'http-errors';
3-
import Stripe from 'stripe';
41
import {
52
Body,
63
Controller,
@@ -10,7 +7,10 @@ import {
107
Request,
118
Route,
129
Security,
13-
} from 'tsoa';
10+
} from '@tsoa/runtime';
11+
import * as express from 'express';
12+
import { BadRequest } from 'http-errors';
13+
import Stripe from 'stripe';
1414
import * as ColorService from '../business/color/ColorService';
1515
import * as UserService from '../business/users/UserService';
1616
import isProduction from '../business/utils/isProduction';

backend/src/api/CorrectionsController.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
import { Body, Post, Request, Route, Security } from '@tsoa/runtime';
12
import * as express from 'express';
23
import { Forbidden } from 'http-errors';
3-
import { Body, Post, Request, Route, Security } from 'tsoa';
44
import { getRepository } from 'typeorm';
55
import * as UserService from '../business/users/UserService';
66
import AddressCorrection from '../entities/AddressCorrection';

0 commit comments

Comments
 (0)