@axium/storage 0.1.2 → 0.1.4
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/dist/common.d.ts +1 -1
- package/dist/server.d.ts +4 -2
- package/dist/server.js +4 -2
- package/package.json +1 -1
package/dist/common.d.ts
CHANGED
package/dist/server.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type Schema } from '@axium/server/database';
|
|
2
|
+
import type { Generated, Selectable } from 'kysely';
|
|
2
3
|
import type { StorageItemMetadata, StorageLimits, StorageUsage } from './common.js';
|
|
3
4
|
import './polyfills.js';
|
|
4
5
|
declare module '@axium/server/database' {
|
|
@@ -9,7 +10,7 @@ declare module '@axium/server/database' {
|
|
|
9
10
|
id: Generated<string>;
|
|
10
11
|
immutable: Generated<boolean>;
|
|
11
12
|
modifiedAt: Generated<Date>;
|
|
12
|
-
name: string
|
|
13
|
+
name: string;
|
|
13
14
|
parentId: string | null;
|
|
14
15
|
restricted: Generated<boolean>;
|
|
15
16
|
size: number;
|
|
@@ -48,6 +49,7 @@ declare module '@axium/server/config' {
|
|
|
48
49
|
export interface StorageItem extends StorageItemMetadata {
|
|
49
50
|
data: Uint8Array<ArrayBufferLike>;
|
|
50
51
|
}
|
|
52
|
+
export declare function parseItem(item: Selectable<Schema['storage']>): StorageItemMetadata;
|
|
51
53
|
/**
|
|
52
54
|
* Returns the current usage of the storage for a user in bytes.
|
|
53
55
|
*/
|
package/dist/server.js
CHANGED
|
@@ -31,7 +31,7 @@ addConfigDefaults({
|
|
|
31
31
|
},
|
|
32
32
|
},
|
|
33
33
|
});
|
|
34
|
-
function parseItem(item) {
|
|
34
|
+
export function parseItem(item) {
|
|
35
35
|
return {
|
|
36
36
|
...item,
|
|
37
37
|
hash: item.hash.toHex(),
|
|
@@ -169,7 +169,9 @@ addRoute({
|
|
|
169
169
|
const { userId } = await getSessionAndUser(token).catch(withError('Invalid session token', 401));
|
|
170
170
|
const [usage, limits] = await Promise.all([currentUsage(userId), getLimits(userId)]).catch(withError('Could not fetch usage and/or limits'));
|
|
171
171
|
const name = event.request.headers.get('x-name');
|
|
172
|
-
if (
|
|
172
|
+
if (!name)
|
|
173
|
+
error(400, 'Missing name header');
|
|
174
|
+
if (name.length > 255)
|
|
173
175
|
error(400, 'Name is too long');
|
|
174
176
|
const maybeParentId = event.request.headers.get('x-parent');
|
|
175
177
|
const parentId = maybeParentId
|