Skip to content

Commit c2e1632

Browse files
committed
fix: try resolve aws-sdk heroku error
1 parent 0efc313 commit c2e1632

File tree

3 files changed

+17
-13
lines changed

3 files changed

+17
-13
lines changed

package-lock.json

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

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,16 @@
1919
"@feathersjs/feathers": "^4.5.3",
2020
"@feathersjs/socketio": "^4.5.4",
2121
"@feathersjs/transport-commons": "^4.5.3",
22+
"@types/aws-sdk": "^2.6.1",
2223
"@types/bluebird": "^3.5.32",
2324
"@types/cors": "^2.8.6",
2425
"@types/lodash": "^4.14.155",
2526
"@types/mongoose": "^5.7.23",
27+
"@types/node": "^14.0.27",
28+
"@types/uuid": "^8.0.1",
2629
"@typescript-eslint/eslint-plugin": "^3.2.0",
2730
"@typescript-eslint/parser": "^3.2.0",
28-
"aws-sdk": "^2.729.0",
31+
"aws-sdk": "^2.6.1",
2932
"bluebird": "^3.7.2",
3033
"cors": "^2.8.5",
3134
"feathers-hooks-common": "^5.0.3",
@@ -47,8 +50,6 @@
4750
"homepage": "https://github.com/eug-vs/which-api#readme",
4851
"description": "",
4952
"devDependencies": {
50-
"@types/aws-sdk": "^2.7.0",
51-
"@types/uuid": "^8.0.1",
5253
"eslint": "^7.2.0",
5354
"eslint-config-airbnb-typescript": "^8.0.2",
5455
"eslint-plugin-import": "^2.21.2"

services/files/files.class.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,22 @@
11
import { Application } from '@feathersjs/express';
22
import { Params } from '@feathersjs/feathers';
3-
import { S3 } from 'aws-sdk';
4-
import { v4 as uuidv4 } from 'uuid';
3+
import { v4 } from 'uuid';
4+
5+
// Use require to avoid bug
6+
// https://stackoverflow.com/questions/62611373/heroku-crashes-when-importing-aws-sdk
7+
const S3 = require('aws-sdk/clients/s3');
58

69

710
export default class Files {
811
app!: Application;
9-
s3!: S3;
12+
s3!: any;
1013
bucket!: string;
1114

1215
async find(params: Params): Promise<string> {
1316
// Return signed upload URL
1417
return this.s3.getSignedUrl('putObject', {
1518
Bucket: this.bucket,
16-
Key: `${params.user?.username}/${uuidv4()}.png`,
19+
Key: `${params.user?.username}/${v4()}.png`,
1720
ContentType: 'image/*',
1821
Expires: 300,
1922
});

0 commit comments

Comments
 (0)