-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #314 from blocklet/master
chore: release to production store
- Loading branch information
Showing
39 changed files
with
694 additions
and
257 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
0.11.48 | ||
0.11.52 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import path from "path"; | ||
|
||
export default { | ||
root: true, | ||
extends: ["@arcblock/eslint-config-ts/base"], | ||
parserOptions: { | ||
project: path.resolve(__dirname, "tsconfig.eslint.json"), | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"printWidth": 120, | ||
"useTabs": false, | ||
"tabWidth": 2, | ||
"trailingComma": "es5", | ||
"bracketSameLine": true, | ||
"semi": true, | ||
"singleQuote": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
## 0.1.50 (October 30, 2024) | ||
|
||
- chore: remove useless deps | ||
|
||
## 0.1.49 (October 30, 2024) | ||
|
||
- chore: re-bump version | ||
|
||
## 0.1.48 (October 30, 2024) | ||
|
||
- chore: split @blocklet/uploader lib | ||
|
||
## 0.1.47 (October 29, 2024) | ||
|
||
- feat: initial release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
# @blocklet/uploader-server-server | ||
|
||
**@blocklet/uploader-server** is a package that integrates the **uppy** service to provide universal upload capability for blocklets. For more information about uppy, refer to the [official documentation](https://uppy.io/docs/quick-start/). | ||
|
||
## Package Structure | ||
|
||
The package is composed of both frontend and backend components. The backend code can be found in the `middlewares` folder. | ||
|
||
## Development | ||
|
||
### Install In Blocklet | ||
|
||
``` | ||
# You can use npm / yarn | ||
pnpm add @blocklet/uploader-server | ||
``` | ||
|
||
### Install Dependencies | ||
|
||
To install the required dependencies, run the following command: | ||
|
||
``` | ||
pnpm i | ||
``` | ||
|
||
### Build Packages | ||
|
||
To build the packages, execute the following command: | ||
|
||
``` | ||
pnpm build | ||
``` | ||
|
||
### Build, Watch, and Run Development Server | ||
|
||
For building, watching changes, and running the development server, use the following command: | ||
|
||
``` | ||
pnpm run dev | ||
``` | ||
|
||
## Backend Example | ||
|
||
```javascript | ||
const { initLocalStorageServer, initCompanion } = require('@blocklet/uploader-server'); | ||
|
||
// init uploader server | ||
const localStorageServer = initLocalStorageServer({ | ||
path: env.uploadDir, | ||
express, | ||
onUploadFinish: async (req, res, uploadMetadata) => { | ||
const { | ||
id: filename, | ||
size, | ||
metadata: { filename: originalname, filetype: mimetype }, | ||
} = uploadMetadata; | ||
|
||
const obj = new URL(env.appUrl); | ||
obj.protocol = req.get('x-forwarded-proto') || req.protocol; | ||
obj.pathname = joinUrl(req.headers['x-path-prefix'] || '/', '/uploads', filename); | ||
|
||
const doc = await Upload.insert({ | ||
mimetype, | ||
originalname, | ||
filename, | ||
size, | ||
remark: req.body.remark || '', | ||
tags: (req.body.tags || '') | ||
.split(',') | ||
.map((x) => x.trim()) | ||
.filter(Boolean), | ||
folderId: req.componentDid, | ||
createdAt: new Date().toISOString(), | ||
updatedAt: new Date().toISOString(), | ||
createdBy: req.user.did, | ||
updatedBy: req.user.did, | ||
}); | ||
|
||
const resData = { url: obj.href, ...doc }; | ||
|
||
return resData; | ||
}, | ||
}); | ||
|
||
router.use('/uploads', user, auth, ensureComponentDid, localStorageServer.handle); | ||
|
||
// if you need to load file from remote | ||
// companion | ||
const companion = initCompanion({ | ||
path: env.uploadDir, | ||
express, | ||
providerOptions: env.providerOptions, | ||
uploadUrls: [env.appUrl], | ||
}); | ||
|
||
router.use('/companion', user, auth, ensureComponentDid, companion.handle); | ||
``` | ||
|
||
## License | ||
|
||
This package is licensed under the MIT license. |
Oops, something went wrong.