@m11s-io/s3-upload-proxy 0.1.0 → 0.1.2

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.
Files changed (2) hide show
  1. package/dist/index.js +33 -11
  2. package/package.json +5 -2
package/dist/index.js CHANGED
@@ -1,11 +1,33 @@
1
1
  #!/usr/bin/env node
2
- #!/usr/bin/env node
2
+ "use strict";
3
+ var __create = Object.create;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
18
+ // If the importer is in node compatibility mode or this is not an ESM
19
+ // file that has been converted to a CommonJS file using a Babel-
20
+ // compatible transform (i.e. "__esModule" has not been set), then set
21
+ // "default" to the CommonJS "module.exports" for node compatibility.
22
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
23
+ mod
24
+ ));
3
25
 
4
26
  // src/index.ts
5
- import express from "express";
6
- import multer from "multer";
7
- import cors from "cors";
8
- import { S3Client, PutObjectCommand } from "@aws-sdk/client-s3";
27
+ var import_express = __toESM(require("express"));
28
+ var import_multer = __toESM(require("multer"));
29
+ var import_cors = __toESM(require("cors"));
30
+ var import_client_s3 = require("@aws-sdk/client-s3");
9
31
  var {
10
32
  S3_ENDPOINT,
11
33
  S3_ACCESS_KEY,
@@ -20,16 +42,16 @@ if (!S3_ENDPOINT || !S3_ACCESS_KEY || !S3_SECRET_KEY || !S3_BUCKET || !S3_PUBLIC
20
42
  console.error("Missing required env: S3_ENDPOINT, S3_ACCESS_KEY, S3_SECRET_KEY, S3_BUCKET, S3_PUBLIC_URL");
21
43
  process.exit(1);
22
44
  }
23
- var s3 = new S3Client({
45
+ var s3 = new import_client_s3.S3Client({
24
46
  endpoint: S3_ENDPOINT,
25
47
  region: S3_REGION,
26
48
  credentials: { accessKeyId: S3_ACCESS_KEY, secretAccessKey: S3_SECRET_KEY },
27
49
  forcePathStyle: true
28
50
  });
29
- var app = express();
30
- app.use(cors());
31
- var upload = multer({ storage: multer.memoryStorage() });
32
- app.post("/upload/:tenant?", upload.single("file"), async (req, res) => {
51
+ var app = (0, import_express.default)();
52
+ app.use((0, import_cors.default)());
53
+ var upload = (0, import_multer.default)({ storage: import_multer.default.memoryStorage() });
54
+ app.post("/upload/:tenant", upload.single("file"), async (req, res) => {
33
55
  if (!req.file) {
34
56
  res.status(400).json({ error: "No file provided" });
35
57
  return;
@@ -39,7 +61,7 @@ app.post("/upload/:tenant?", upload.single("file"), async (req, res) => {
39
61
  const prefix = [S3_KEY_PREFIX, tenant].filter(Boolean).join("/");
40
62
  const key = `${prefix ? prefix + "/" : ""}${Date.now()}-${originalname}`;
41
63
  try {
42
- await s3.send(new PutObjectCommand({
64
+ await s3.send(new import_client_s3.PutObjectCommand({
43
65
  Bucket: S3_BUCKET,
44
66
  Key: key,
45
67
  Body: buffer,
package/package.json CHANGED
@@ -1,8 +1,7 @@
1
1
  {
2
2
  "name": "@m11s-io/s3-upload-proxy",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "HTTP-to-S3 upload proxy — accepts multipart file uploads and stores them in any S3-compatible store",
5
- "type": "module",
6
5
  "main": "dist/index.js",
7
6
  "bin": {
8
7
  "s3-upload-proxy": "dist/index.js"
@@ -20,6 +19,10 @@
20
19
  "upload",
21
20
  "proxy"
22
21
  ],
22
+ "repository": {
23
+ "type": "git",
24
+ "url": "https://github.com/m11s-io/js"
25
+ },
23
26
  "license": "MIT",
24
27
  "dependencies": {
25
28
  "@aws-sdk/client-s3": "^3",