Skip to content

Commit df3b060

Browse files
Wojciech KrysiakWojciech Krysiak
authored andcommitted
fix: javascript export
1 parent 1c68e2d commit df3b060

File tree

3 files changed

+31
-10
lines changed

3 files changed

+31
-10
lines changed

index.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// This fixes imports for regular javascript files
2+
// in standard tsc build following doesn't work:
3+
//
4+
// const uploadFeature = require('@admin-bro/upload')
5+
//
6+
// because tsc changes that so only following works:
7+
// this is standard way of handling that by both tsc and babel
8+
//
9+
// const { default: uploadFeature } = require('@admin-bro/upload')
10+
//
11+
// Here we fix that so both JavaScript and TypeScript works
12+
13+
/* eslint-disable @typescript-eslint/no-var-requires */
14+
const regularExport = require('./build/index')
15+
16+
const uploadFeature = regularExport.default
17+
const { BaseProvider } = regularExport
18+
19+
module.exports = uploadFeature
20+
module.exports.BaseProvider = BaseProvider
21+
module.exports.default = uploadFeature

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@admin-bro/upload",
33
"version": "1.0.0-beta.3",
4-
"main": "build/index.js",
4+
"main": "index.js",
55
"types": "types/index.d.ts",
66
"private": false,
77
"repository": "[email protected]:SoftwareBrothers/admin-bro-upload.git",

src/index.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*
1919
* ```
2020
* const AdminBro = require('admin-bro')
21-
* const uploadFeature = require('@admin-bro/upload')
21+
* const AdminBroExpress = require('@admin-bro/express')
2222
*
2323
* // part where you load adapter and models
2424
* const User = require('./user')
@@ -86,28 +86,28 @@
8686
* - [create a S3 bucket](https://docs.aws.amazon.com/AmazonS3/latest/user-guide/create-bucket.html)
8787
* - [get your access keys](https://docs.aws.amazon.com/powershell/latest/userguide/pstools-appendix-sign-up.html)
8888
*
89-
* Then fill all these data in {@link module:@admin-bro/upload.AWSOptions AWSOptions}
89+
* Then, fill all these data in {@link module:@admin-bro/upload.AWSOptions AWSOptions}
9090
* and you are ready to go.
9191
*
92-
* By default upload plugin generates urls valid for 24h, if you want them to be public always,
93-
* you need to create `public` bucket. Then set `expires` to `0`.
92+
* By default upload plugin generates urls valid for 24h, if you want them to be always `public`
93+
* (`public-acl`), you need to create a `public` bucket. Then set `expires` to `0`.
9494
*
9595
* ### Local Storage setup
9696
*
9797
* Local storage will save files to the local folder.
9898
*
99-
* There are 2 things which you have to do before using this Provider.
99+
* There are 2 things you have to do before using this Provider.
100100
*
101-
* 1. create folder for the files (i.e. `public`)
101+
* #### 1. create the **folder88 (`bucket`) for the files (i.e. `public`)
102102
*
103103
* ```
104104
* cd your-app
105105
* mkdir public
106106
* ```
107107
*
108-
* 2. tell your http framework to host this folder
108+
* #### 2. tell your http framework to host this folder
109109
*
110-
* This is an example for a [express](https://expressjs.com) server
110+
* This is an example for the [express](https://expressjs.com) server
111111
*
112112
* ```
113113
* app.use('/uploads', express.static('uploads'));
@@ -129,7 +129,7 @@
129129
* ### Custom Provider
130130
*
131131
* Plugin allows you also to pass your own provider. In such case you have to pass to the `provider`
132-
* option an instance of the class extended from {@link module:@admin-bro/upload.BaseProvider}.
132+
* option an instance of the class extended from {@link BaseProvider}.
133133
*
134134
* ```
135135
* const { BaseProvider } = require('@admin-bro/upload')

0 commit comments

Comments
 (0)