@opra/http 1.24.3 → 1.25.1

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/http-context.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { HttpController, HttpMediaType, HttpOperation } from '@opra/common';
2
2
  import { ExecutionContext } from '@opra/core';
3
- import type { HttpAdapter } from './http-adapter';
3
+ import type { HttpAdapter } from './http-adapter.js';
4
4
  import { MultipartReader } from './impl/multipart-reader.js';
5
5
  import type { HttpIncoming } from './interfaces/http-incoming.interface.js';
6
6
  import type { HttpOutgoing } from './interfaces/http-outgoing.interface.js';
package/http-handler.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { HttpOperationResponse, OpraException, OpraHttpError } from '@opra/common';
2
2
  import { AssetCache, kAssetCache } from '@opra/core';
3
- import type { HttpAdapter } from './http-adapter';
3
+ import type { HttpAdapter } from './http-adapter.js';
4
4
  import { HttpContext } from './http-context.js';
5
5
  /**
6
6
  * @namespace
@@ -1,4 +1,3 @@
1
- import { randomFillSync } from 'node:crypto';
2
1
  import fs from 'node:fs';
3
2
  import os from 'node:os';
4
3
  import nodePath from 'node:path';
@@ -7,6 +6,7 @@ import { BadRequestError } from '@opra/common';
7
6
  import busboy from 'busboy';
8
7
  import { EventEmitter } from 'events';
9
8
  import fsPromise from 'fs/promises';
9
+ import { uid } from 'uid';
10
10
  import { isNotNullish } from 'valgen';
11
11
  export class MultipartReader extends EventEmitter {
12
12
  context;
@@ -52,7 +52,7 @@ export class MultipartReader extends EventEmitter {
52
52
  this.emit('item', item);
53
53
  });
54
54
  form.on('file', (field, file, info) => {
55
- const saveTo = nodePath.posix.join(this.tempDirectory, `opra-${generateFileName()}`);
55
+ const saveTo = generateFileName(info, this.tempDirectory);
56
56
  file.pipe(fs.createWriteStream(saveTo));
57
57
  file.once('end', () => {
58
58
  const item = {
@@ -197,13 +197,18 @@ export class MultipartReader extends EventEmitter {
197
197
  this._items.forEach(item => {
198
198
  if (item.kind !== 'file')
199
199
  return;
200
- promises.push(fsPromise.unlink(item.storedPath));
200
+ promises.push(fsPromise.unlink(item.storedPath).catch(() => { }));
201
201
  });
202
202
  return Promise.allSettled(promises);
203
203
  }
204
204
  }
205
- function generateFileName() {
206
- const buf = Buffer.alloc(10);
207
- return (new Date().toISOString().substring(0, 10).replace(/-/g, '') +
208
- randomFillSync(buf).toString('hex'));
205
+ function generateFileName(info, tempDirectory) {
206
+ let filename;
207
+ let prefix = '';
208
+ while (true) {
209
+ filename = nodePath.posix.join(tempDirectory, info.filename ? prefix + info.filename : 'opra-' + uid(12));
210
+ if (!fs.existsSync(filename))
211
+ return filename;
212
+ prefix = uid(6) + '-';
213
+ }
209
214
  }
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@opra/http",
3
- "version": "1.24.3",
3
+ "version": "1.25.1",
4
4
  "description": "Opra Http Server Adapter",
5
5
  "author": "Panates",
6
6
  "license": "MIT",
7
7
  "dependencies": {
8
- "@browsery/antlr4": "^4.13.3-r4",
9
- "@browsery/http-parser": "^0.5.10-r2",
10
- "@browsery/type-is": "^2.0.1",
8
+ "@browsery/antlr4": "^4.13.3-r5",
9
+ "@browsery/http-parser": "^0.5.10-r3",
10
+ "@browsery/type-is": "^2.0.2-r1",
11
11
  "@jsopen/objects": "^2.2.0",
12
12
  "accepts": "^1.3.8",
13
13
  "base64-stream": "^1.0.0",
@@ -24,21 +24,22 @@
24
24
  "iconv-lite": "^0.7.2",
25
25
  "mime-types": "^3.0.2",
26
26
  "node-events-async": "^1.5.2",
27
- "power-tasks": "^1.14.1",
27
+ "power-tasks": "^1.14.2",
28
28
  "putil-varhelpers": "^1.7.0",
29
29
  "range-parser": "^1.2.1",
30
30
  "raw-body": "^3.0.2",
31
31
  "reflect-metadata": "^0.2.2",
32
32
  "super-fast-md5": "^1.0.3",
33
- "toml": "^3.0.0",
33
+ "toml": "^4.1.1",
34
34
  "tslib": "^2.8.1",
35
+ "uid": "^2.0.2",
35
36
  "valgen": "^5.19.5",
36
37
  "vary": "^1.1.2",
37
38
  "yaml": "^2.8.3"
38
39
  },
39
40
  "peerDependencies": {
40
- "@opra/common": "^1.24.3",
41
- "@opra/core": "^1.24.3"
41
+ "@opra/common": "^1.25.1",
42
+ "@opra/core": "^1.25.1"
42
43
  },
43
44
  "optionalDependencies": {
44
45
  "express": "^4.0.0 || ^5.0.0",