Skip to content

Commit

Permalink
Introduce @tus/utils to simplify building/publishing
Browse files Browse the repository at this point in the history
  • Loading branch information
Murderlon committed Jan 29, 2024
1 parent 436b4a8 commit ef6c269
Show file tree
Hide file tree
Showing 63 changed files with 348 additions and 215 deletions.
48 changes: 0 additions & 48 deletions packages/file-store/configstores/FileConfigstore.ts

This file was deleted.

36 changes: 0 additions & 36 deletions packages/file-store/configstores/MemoryConfigstore.ts

This file was deleted.

40 changes: 0 additions & 40 deletions packages/file-store/configstores/RedisConfigstore.ts

This file was deleted.

9 changes: 0 additions & 9 deletions packages/file-store/configstores/Types.ts

This file was deleted.

10 changes: 6 additions & 4 deletions packages/file-store/configstores/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export {FileConfigstore} from './FileConfigstore'
export {MemoryConfigstore} from './MemoryConfigstore'
export {RedisConfigstore} from './RedisConfigstore'
export {Configstore} from './Types'
export {
FileKvStore as FileConfigstore,
MemoryKvStore as MemoryConfigstore,
RedisKvStore as RedisConfigstore,
KvStore as Configstore,
} from '@tus/utils'
2 changes: 1 addition & 1 deletion packages/file-store/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import http from 'node:http'
import debug from 'debug'

import {Configstore, FileConfigstore} from './configstores'
import {DataStore, Upload, ERRORS} from '@tus/server'
import {DataStore, Upload, ERRORS} from '@tus/utils'

export * from './configstores'

Expand Down
5 changes: 1 addition & 4 deletions packages/file-store/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
"test": "mocha test.ts --exit --extension ts --require ts-node/register"
},
"dependencies": {
"@tus/utils": "workspace:*",
"debug": "^4.3.4"
},
"devDependencies": {
"@tus/server": "workspace:^",
"@types/debug": "^4.1.12",
"@types/mocha": "^10.0.6",
"@types/node": "^20.11.5",
Expand All @@ -34,9 +34,6 @@
"should": "^13.2.3",
"typescript": "^5.3.3"
},
"peerDependencies": {
"@tus/server": "workspace:^"
},
"optionalDependencies": {
"@redis/client": "^1.5.13"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/file-store/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import path from 'node:path'
import sinon from 'sinon'

import {FileStore, FileConfigstore} from './'
import {Upload} from '@tus/server'
import {Upload} from '@tus/utils'

import * as shared from '../../test/stores.test'

Expand Down
3 changes: 1 addition & 2 deletions packages/gcs-store/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ import stream from 'node:stream'
import http from 'node:http'
import debug from 'debug'

import {ERRORS, TUS_RESUMABLE} from '@tus/server'
import {Upload, DataStore} from '@tus/server'
import {ERRORS, TUS_RESUMABLE, Upload, DataStore} from '@tus/utils'

const log = debug('tus-node-server:stores:gcsstore')

Expand Down
4 changes: 2 additions & 2 deletions packages/gcs-store/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"test": "mocha test.ts --timeout 30000 --exit --extension ts --require ts-node/register"
},
"dependencies": {
"@tus/utils": "workspace:*",
"debug": "^4.3.4"
},
"devDependencies": {
Expand All @@ -36,8 +37,7 @@
"typescript": "^5.3.3"
},
"peerDependencies": {
"@google-cloud/storage": "*",
"@tus/server": "workspace:^"
"@google-cloud/storage": "*"
},
"engines": {
"node": ">=16"
Expand Down
2 changes: 1 addition & 1 deletion packages/s3-store/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
TUS_RESUMABLE,
KvStore,
MemoryKvStore,
} from '@tus/server'
} from '@tus/utils'

const log = debug('tus-node-server:stores:s3store')

Expand Down
5 changes: 1 addition & 4 deletions packages/s3-store/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
},
"dependencies": {
"@aws-sdk/client-s3": "^3.490.0",
"@tus/utils": "workspace:*",
"debug": "^4.3.4"
},
"devDependencies": {
"@tus/server": "workspace:^",
"@types/debug": "^4.1.12",
"@types/mocha": "^10.0.6",
"@types/node": "^20.11.5",
Expand All @@ -35,9 +35,6 @@
"should": "^13.2.3",
"typescript": "^5.3.3"
},
"peerDependencies": {
"@tus/server": "workspace:^"
},
"engines": {
"node": ">=16"
}
Expand Down
2 changes: 1 addition & 1 deletion packages/s3-store/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import sinon from 'sinon'

import {S3Store} from './'
import * as shared from '../../test/stores.test'
import {Upload, Uid} from '@tus/server'
import {Upload, Uid} from '@tus/utils'

const fixturesPath = path.resolve('../', '../', 'test', 'fixtures')
const storePath = path.resolve('../', '../', 'test', 'output')
Expand Down
1 change: 1 addition & 0 deletions packages/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"test": "mocha --timeout 40000 --exit --extension ts --require ts-node/register"
},
"dependencies": {
"@tus/utils": "workspace:*",
"debug": "^4.3.4"
},
"devDependencies": {
Expand Down
6 changes: 2 additions & 4 deletions packages/server/src/handlers/BaseHandler.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import EventEmitter from 'node:events'

import type {ServerOptions} from '../types'
import type {DataStore, CancellationContext} from '../models'
import type {DataStore, CancellationContext} from '@tus/utils'
import type http from 'node:http'
import {Upload} from '../models'
import {ERRORS} from '../constants'
import {ERRORS, Upload, StreamLimiter} from '@tus/utils'
import stream from 'node:stream/promises'
import {addAbortSignal, PassThrough} from 'stream'
import {StreamLimiter} from '../models/StreamLimiter'

const reExtractFileID = /([^/]+)\/?$/
const reForwardedHost = /host="?([^";]+)/
Expand Down
3 changes: 1 addition & 2 deletions packages/server/src/handlers/DeleteHandler.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import {BaseHandler} from './BaseHandler'
import {ERRORS, EVENTS} from '../constants'
import {CancellationContext} from '../models'
import {ERRORS, EVENTS, CancellationContext} from '@tus/utils'

import type http from 'node:http'

Expand Down
2 changes: 1 addition & 1 deletion packages/server/src/handlers/GetHandler.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import stream from 'node:stream'

import {BaseHandler} from './BaseHandler'
import {ERRORS} from '../constants'
import {ERRORS} from '@tus/utils'

import type http from 'node:http'
import type {RouteHandler} from '../types'
Expand Down
3 changes: 1 addition & 2 deletions packages/server/src/handlers/HeadHandler.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {BaseHandler} from './BaseHandler'

import {ERRORS} from '../constants'
import {Metadata, Upload, CancellationContext} from '../models'
import {ERRORS, Metadata, Upload, CancellationContext} from '@tus/utils'

import type http from 'node:http'

Expand Down
2 changes: 1 addition & 1 deletion packages/server/src/handlers/OptionsHandler.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {BaseHandler} from './BaseHandler'
import {ALLOWED_METHODS, MAX_AGE, HEADERS} from '../constants'
import {ALLOWED_METHODS, MAX_AGE, HEADERS} from '@tus/utils'

import type http from 'node:http'

Expand Down
3 changes: 1 addition & 2 deletions packages/server/src/handlers/PatchHandler.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import debug from 'debug'

import {BaseHandler} from './BaseHandler'
import {ERRORS, EVENTS} from '../constants'

import type http from 'node:http'
import {CancellationContext, Upload} from '../models'
import {ERRORS, EVENTS, CancellationContext, Upload} from '@tus/utils'

const log = debug('tus-node-server:handlers:patch')

Expand Down
12 changes: 9 additions & 3 deletions packages/server/src/handlers/PostHandler.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
import debug from 'debug'

import {BaseHandler} from './BaseHandler'
import {Upload, Uid, Metadata} from '../models'
import {
Upload,
Uid,
Metadata,
EVENTS,
ERRORS,
DataStore,
CancellationContext,
} from '@tus/utils'
import {validateHeader} from '../validators/HeaderValidator'
import {EVENTS, ERRORS} from '../constants'

import type http from 'node:http'
import type {ServerOptions, WithRequired} from '../types'
import {DataStore, CancellationContext} from '../models'

const log = debug('tus-node-server:handlers:post')

Expand Down
4 changes: 1 addition & 3 deletions packages/server/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
export {Server} from './server'
export * from './types'
export * from './models'
export * from './lockers'
export * from './constants'
export * from './kvstores'
export * from '@tus/utils'
3 changes: 1 addition & 2 deletions packages/server/src/lockers/MemoryLocker.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {ERRORS} from '../constants'
import {Lock, Locker, RequestRelease} from '../models'
import {ERRORS, Lock, Locker, RequestRelease} from '@tus/utils'

/**
* MemoryLocker is an implementation of the Locker interface that manages locks in memory.
Expand Down
10 changes: 2 additions & 8 deletions packages/server/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,11 @@ import {PostHandler} from './handlers/PostHandler'
import {DeleteHandler} from './handlers/DeleteHandler'
import {validateHeader} from './validators/HeaderValidator'

import {
EVENTS,
ERRORS,
EXPOSED_HEADERS,
REQUEST_METHODS,
TUS_RESUMABLE,
} from './constants'
import {EVENTS, ERRORS, EXPOSED_HEADERS, REQUEST_METHODS, TUS_RESUMABLE} from '@tus/utils'

import type stream from 'node:stream'
import type {ServerOptions, RouteHandler, WithOptional} from './types'
import type {DataStore, Upload, CancellationContext} from './models'
import type {DataStore, Upload, CancellationContext} from '@tus/utils'
import {MemoryLocker} from './lockers'

type Handlers = {
Expand Down
2 changes: 1 addition & 1 deletion packages/server/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type http from 'node:http'

import type {Locker, Upload} from './models'
import type {Locker, Upload} from '@tus/utils'

/**
* Represents the configuration options for a server.
Expand Down
3 changes: 1 addition & 2 deletions packages/server/src/validators/HeaderValidator.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {TUS_VERSION, TUS_RESUMABLE} from '../constants'
import {Metadata} from '../models'
import {TUS_VERSION, TUS_RESUMABLE, Metadata} from '@tus/utils'

type validator = (value?: string) => boolean

Expand Down
Loading

0 comments on commit ef6c269

Please sign in to comment.