diff options
author | eug-vs <eug-vs@keemail.me> | 2020-08-10 23:47:00 +0300 |
---|---|---|
committer | eug-vs <eug-vs@keemail.me> | 2020-08-11 14:24:47 +0300 |
commit | c2e16321e679d52ad9d6e08b5cdb785b172ad830 (patch) | |
tree | 8af4fdd11808b2620eadbf8321d76da41dbc1ab3 | |
parent | 0efc3134eb348e68e7bf7519e770237e15811900 (diff) | |
download | which-api-c2e16321e679d52ad9d6e08b5cdb785b172ad830.tar.gz |
fix: try resolve aws-sdk heroku error
-rw-r--r-- | package-lock.json | 12 | ||||
-rw-r--r-- | package.json | 7 | ||||
-rw-r--r-- | services/files/files.class.ts | 11 |
3 files changed, 17 insertions, 13 deletions
diff --git a/package-lock.json b/package-lock.json index 3fc07dc..cbc2d25 100644 --- a/package-lock.json +++ b/package-lock.json @@ -301,9 +301,9 @@ } }, "@types/node": { - "version": "14.0.11", - "resolved": "https://registry.npmjs.org/@types/node/-/node-14.0.11.tgz", - "integrity": "sha512-lCvvI24L21ZVeIiyIUHZ5Oflv1hhHQ5E1S25IRlKIXaRkVgmXpJMI3wUJkmym2bTbCe+WoIibQnMVAU3FguaOg==" + "version": "14.0.27", + "resolved": "https://registry.npmjs.org/@types/node/-/node-14.0.27.tgz", + "integrity": "sha512-kVrqXhbclHNHGu9ztnAwSncIgJv/FaxmzXJvGXNdcCpV1b8u1/Mi6z6m0vwy0LzKeXFTPLH0NzwmoJ3fNCIq0g==" }, "@types/qs": { "version": "6.9.3", @@ -527,9 +527,9 @@ "integrity": "sha512-csOlWGAcRFJaI6m+F2WKdnMKr4HhdhFVBk0H/QbJFMCr+uO2kwohwXQPxw/9OCxp05r5ghVBFSyioixx3gfkNQ==" }, "aws-sdk": { - "version": "2.729.0", - "resolved": "https://registry.npmjs.org/aws-sdk/-/aws-sdk-2.729.0.tgz", - "integrity": "sha512-x5q/+9wM37tBYCmYNGMj+aU9qeXqhbUH0Dz3wlSpAW55+N4NwlBbpqhyCV3oF9bePEJtEnxLGWNXpb9BNWNhew==", + "version": "2.730.0", + "resolved": "https://registry.npmjs.org/aws-sdk/-/aws-sdk-2.730.0.tgz", + "integrity": "sha512-hYHplsbgUDP0XuaVJaHx2L/nC0E1i+4dGlkAQpkJz3qQ4NDfLnrbUFsA2g3AyWAsrnjrBNCkexPvwnV82Qng1g==", "requires": { "buffer": "4.9.2", "events": "1.1.1", diff --git a/package.json b/package.json index c034322..3d15a0b 100644 --- a/package.json +++ b/package.json @@ -19,13 +19,16 @@ "@feathersjs/feathers": "^4.5.3", "@feathersjs/socketio": "^4.5.4", "@feathersjs/transport-commons": "^4.5.3", + "@types/aws-sdk": "^2.6.1", "@types/bluebird": "^3.5.32", "@types/cors": "^2.8.6", "@types/lodash": "^4.14.155", "@types/mongoose": "^5.7.23", + "@types/node": "^14.0.27", + "@types/uuid": "^8.0.1", "@typescript-eslint/eslint-plugin": "^3.2.0", "@typescript-eslint/parser": "^3.2.0", - "aws-sdk": "^2.729.0", + "aws-sdk": "^2.6.1", "bluebird": "^3.7.2", "cors": "^2.8.5", "feathers-hooks-common": "^5.0.3", @@ -47,8 +50,6 @@ "homepage": "https://github.com/eug-vs/which-api#readme", "description": "", "devDependencies": { - "@types/aws-sdk": "^2.7.0", - "@types/uuid": "^8.0.1", "eslint": "^7.2.0", "eslint-config-airbnb-typescript": "^8.0.2", "eslint-plugin-import": "^2.21.2" diff --git a/services/files/files.class.ts b/services/files/files.class.ts index 8a104b7..e2f9df3 100644 --- a/services/files/files.class.ts +++ b/services/files/files.class.ts @@ -1,19 +1,22 @@ import { Application } from '@feathersjs/express'; import { Params } from '@feathersjs/feathers'; -import { S3 } from 'aws-sdk'; -import { v4 as uuidv4 } from 'uuid'; +import { v4 } from 'uuid'; + +// Use require to avoid bug +// https://stackoverflow.com/questions/62611373/heroku-crashes-when-importing-aws-sdk +const S3 = require('aws-sdk/clients/s3'); export default class Files { app!: Application; - s3!: S3; + s3!: any; bucket!: string; async find(params: Params): Promise<string> { // Return signed upload URL return this.s3.getSignedUrl('putObject', { Bucket: this.bucket, - Key: `${params.user?.username}/${uuidv4()}.png`, + Key: `${params.user?.username}/${v4()}.png`, ContentType: 'image/*', Expires: 300, }); |