@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 CHANGED
@@ -53,7 +53,7 @@ export interface StorageItemMetadata {
53
53
  id: string;
54
54
  immutable: boolean;
55
55
  modifiedAt: Date;
56
- name: string | null;
56
+ name: string;
57
57
  userId: string;
58
58
  parentId: string | null;
59
59
  /** Whether editing the file is restricted to the owner */
package/dist/server.d.ts CHANGED
@@ -1,4 +1,5 @@
1
- import type { Generated } from 'kysely';
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 | null;
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 ((name?.length || 0) > 255)
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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@axium/storage",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "author": "James Prevett <axium@jamespre.dev> (https://jamespre.dev)",
5
5
  "description": "User file storage for Axium",
6
6
  "funding": {