lesca-node-bunnycdn 0.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/type.d.ts ADDED
@@ -0,0 +1,45 @@
1
+ import { Request, Response } from 'express';
2
+ export type Status = 'loading' | 'loaded' | 'error';
3
+ export type SharpConfig = {
4
+ width?: number;
5
+ height?: number;
6
+ quality?: number;
7
+ format?: 'jpeg' | 'png' | 'webp';
8
+ };
9
+ export type Params = {
10
+ req: Request;
11
+ res: Response;
12
+ };
13
+ export type InstallParams = {
14
+ password: string;
15
+ storageZone?: string;
16
+ region?: string;
17
+ folderName?: string;
18
+ };
19
+ export type UploadParams = {
20
+ file?: Express.Multer.File;
21
+ sharpConfig: SharpConfig;
22
+ };
23
+ export type LegacyUploadParams = {
24
+ req: Request;
25
+ res: Response;
26
+ sharpConfig: SharpConfig;
27
+ };
28
+ export type File = {
29
+ Guid: string;
30
+ StorageZoneName: string;
31
+ Path: string;
32
+ ObjectName: string;
33
+ Length: number;
34
+ Checksum: string;
35
+ ReplicatedZones: string;
36
+ LastChanged: string;
37
+ ServerId: number;
38
+ ArrayNumber: number;
39
+ IsDirectory: boolean;
40
+ UserId: string;
41
+ ContentType: string;
42
+ DateCreated: string;
43
+ StorageZoneId: number;
44
+ Url: string;
45
+ };
package/package.json ADDED
@@ -0,0 +1,52 @@
1
+ {
2
+ "name": "lesca-node-bunnycdn",
3
+ "private": false,
4
+ "description": "use bunny CDN api by node",
5
+ "version": "0.0.0",
6
+ "type": "module",
7
+ "keywords": [
8
+ "bunnycdn",
9
+ "lesca"
10
+ ],
11
+ "files": [
12
+ "lib"
13
+ ],
14
+ "main": "./lib/index.cjs",
15
+ "module": "./lib/index.js",
16
+ "exports": {
17
+ ".": {
18
+ "import": "./lib/index.js"
19
+ }
20
+ },
21
+ "scripts": {
22
+ "dev": "concurrently \"npx tsx src/api.ts\" \"NODE_ENV=DEV vite --host\"",
23
+ "build": "NODE_ENV=production tsc -b && vite build",
24
+ "lint": "eslint .",
25
+ "preview": "vite preview",
26
+ "rm": "rm -rf node_modules/ dist/ package-lock.json"
27
+ },
28
+ "devDependencies": {
29
+ "@eslint/js": "^9.39.2",
30
+ "@types/express": "^5.0.6",
31
+ "@types/multer": "^2.0.0",
32
+ "@types/node": "^25.0.9",
33
+ "concurrently": "^9.2.1",
34
+ "eslint": "^9.39.2",
35
+ "express": "^5.2.1",
36
+ "globals": "^17.0.0",
37
+ "multer": "^2.0.2",
38
+ "path": "^0.12.7",
39
+ "prettier": "^3.8.0",
40
+ "prettier-plugin-tailwindcss": "^0.7.2",
41
+ "sharp": "^0.34.5",
42
+ "tsx": "^4.21.0",
43
+ "typescript": "^5.9.3",
44
+ "typescript-eslint": "^8.53.0",
45
+ "vite": "^7.3.1",
46
+ "vite-plugin-css-injected-by-js": "^3.5.2",
47
+ "vite-plugin-dts": "^4.5.4"
48
+ },
49
+ "dependencies": {
50
+ "vite-plugin-node-polyfills": "^0.25.0"
51
+ }
52
+ }
package/readme.md ADDED
@@ -0,0 +1,88 @@
1
+ [![React](https://img.shields.io/badge/-ReactJs-61DAFB?style=for-the-badge&logo=react&logoColor=white)](https://zh-hant.reactjs.org/)
2
+ [![React](https://img.shields.io/badge/Less-1d365d?style=for-the-badge&logo=less&logoColor=white)](https://lesscss.org/)
3
+ [![React](https://img.shields.io/badge/Typescript-4277c0?style=for-the-badge&logo=typescript&logoColor=white)](https://www.typescriptlang.org/)
4
+ [![React](https://img.shields.io/badge/HTML5-E34F26?style=for-the-badge&logo=html5&logoColor=white)](https://www.w3schools.com/html/)
5
+ [![React](https://img.shields.io/badge/-CSS3-1572B6?style=for-the-badge&logo=css3&logoColor=white)](https://www.w3schools.com/css/)
6
+ [![NPM](https://img.shields.io/badge/NPM-ba443f?style=for-the-badge&logo=npm&logoColor=white)](https://www.npmjs.com/)
7
+ [![React](https://img.shields.io/badge/Node.js-43853D?style=for-the-badge&logo=node.js&logoColor=white)](https://nodejs.org/en/)
8
+ [![NPM](https://img.shields.io/badge/DEV-Jameshsu1125-9cf?style=for-the-badge)](https://www.npmjs.com/~jameshsu1125)
9
+
10
+ # Why use it?
11
+
12
+ Use it calculator timestamp for animation.
13
+
14
+ #### [Live Demo](https://jameshsu1125.github.io/lesca-enterframe/)
15
+
16
+ # Installation
17
+
18
+ ```sh
19
+ npm install lesca-node-bunnycdn --save
20
+ ```
21
+
22
+ ## Usage
23
+
24
+ As a Node module:
25
+
26
+ ```TS
27
+ import BunnyCDN from 'lesca-node-bunnycdn';
28
+ import multer from 'multer';
29
+ import express from 'express';
30
+
31
+ BunnyCDN.install({
32
+ password: '7bcc3895-xxxx-xxxxxxxxxxxx-xxxx-xxxx', // storage key
33
+ storageZone: 'npm-demo', // zone
34
+ region: 'SG', // your region setting
35
+ folderName: 'your-folder', // start with folder name
36
+ });
37
+
38
+ const uploadMulter = multer({
39
+ storage: multer.memoryStorage(),
40
+ limits: { fileSize: 5 * 1024 * 1024 },
41
+ });
42
+
43
+ const app = express();
44
+ const port = 3000;
45
+
46
+ app.use(express.json());
47
+
48
+ app.post('/upload', uploadMulter.single('file'), async (req, res) => {
49
+ const response = await BunnyCDN.upload({
50
+ file: req.file,
51
+ sharpConfig: { format: 'webp', quality: 80 },
52
+ });
53
+ if (response) res.json(response);
54
+ else res.json({ res: false, message: 'Upload error' });
55
+ });
56
+
57
+ app.get('/list', async (_, res) => {
58
+ const response = await BunnyCDN.list();
59
+
60
+ if (response) res.json(response);
61
+ else res.json({ res: false, message: 'List error' });
62
+ });
63
+
64
+ app.post('/delete', async (req, res) => {
65
+ const response = await BunnyCDN.deleteFile({ href: req.body.href });
66
+
67
+ if (response) res.json(response);
68
+ else res.json({ res: false, message: 'Delete error' });
69
+ });
70
+
71
+ app.listen(port, () => {
72
+ console.log(`Example app listening on port ${port}`);
73
+ });
74
+
75
+ ```
76
+
77
+ ### Methods
78
+
79
+ | method | description | return |
80
+ | :----------------------- | :----------------------: | -----: |
81
+ | .**install**(options) | extend call func | void |
82
+ | .**upload**(options) | continue calling func | void |
83
+ | .**list**() | stop calling func | void |
84
+ | .**deleteFile**(options) | reverse to last function | void |
85
+
86
+ ### Features
87
+
88
+ - maintain if necessary