diff --git a/README.md b/README.md index d48df96..4895e59 100644 --- a/README.md +++ b/README.md @@ -123,7 +123,7 @@ File storage currently does not support paste expiration, you can follow [#191]( To use redis storage you must install the `redis` package in npm, and have `redis-server` running on the machine. -`npm install redis` +`yarn install redis` Once you've done that, your config section should look like: @@ -148,7 +148,7 @@ If your Redis server is configured for password authentification, use the `passw To use postgres storage you must install the `pg` package in npm -`npm install pg` +`yarn install pg` Once you've done that, your config section should look like: @@ -175,7 +175,7 @@ All of which are optional except `type` with very logical default values. To use mongodb storage you must install the 'mongodb' package in npm -`npm install mongodb` +`yarn install mongodb` Once you've done that, your config section should look like: @@ -197,7 +197,7 @@ This is off by default, but will constantly kick back expirations on each view o To use memcache storage you must install the `memcached` package via npm -`npm install memcached` +`yarn install memcached` Once you've done that, your config section should look like: @@ -219,7 +219,7 @@ All of which are optional except `type` with very logical default values. To use the RethinkDB storage system, you must install the `rethinkdbdash` package via npm -`npm install rethinkdbdash` +`yarn install rethinkdbdash` Once you've done that, your config section should look like this: @@ -241,7 +241,7 @@ You can optionally add the `user` and `password` properties to use a user system To use the Google Datastore storage system, you must install the `@google-cloud/datastore` package via npm -`npm install @google-cloud/datastore` +`yarn install @google-cloud/datastore` Once you've done that, your config section should look like this: @@ -258,7 +258,7 @@ Authentication is handled automatically by [Google Cloud service account credent To use [Amazon S3](https://aws.amazon.com/s3/) as a storage system, you must install the `aws-sdk` package via npm: -`npm install aws-sdk` +`yarn install aws-sdk` Once you've done that, your config section should look like this: diff --git a/config/jest.config.js b/config/jest.config.js index b7b2420..2e570d6 100644 --- a/config/jest.config.js +++ b/config/jest.config.js @@ -4,5 +4,11 @@ module.exports = { testEnvironment: 'node', rootDir: '../', testRegex: '\\.test\\.ts$', - reporters: ['default'] + reporters: ['default'], + roots: [ + "test" + ], + moduleNameMapper: { + "src/(.*)": "/src/$1" + } } diff --git a/src/lib/document-handler/builder.ts b/src/lib/document-handler/builder.ts index 2dd0571..285ea0f 100644 --- a/src/lib/document-handler/builder.ts +++ b/src/lib/document-handler/builder.ts @@ -1,6 +1,6 @@ -import type { Config } from '../../types/config' -import buildGenerator from '../key-generators/builder' -import buildStore from '../document-stores/builder' +import buildGenerator from 'src/lib/key-generators/builder' +import type { Config } from 'src/types/config' +import buildStore from 'src/lib/document-stores/builder' import DocumentHandler from "./index" const build = async (config: Config) => { diff --git a/src/lib/document-handler/index.ts b/src/lib/document-handler/index.ts index 32caf31..612ff42 100644 --- a/src/lib/document-handler/index.ts +++ b/src/lib/document-handler/index.ts @@ -1,11 +1,11 @@ import { Request, Response } from 'express' import * as winston from 'winston' import Busboy from 'busboy' -import type { Config } from '../../types/config' -import type { Store } from '../../types/store' -import type { KeyGenerator } from '../../types/key-generator' -import type { Document } from '../../types/document' -import constants from '../../constants' +import type { Config } from 'src/types/config' +import type { Store } from 'src/types/store' +import type { KeyGenerator } from 'src/types/key-generator' +import type { Document } from 'src/types/document' +import constants from 'src/constants' class DocumentHandler { keyLength: number diff --git a/src/lib/document-stores/amazon-s3.ts b/src/lib/document-stores/amazon-s3.ts index ea7cadb..061443f 100644 --- a/src/lib/document-stores/amazon-s3.ts +++ b/src/lib/document-stores/amazon-s3.ts @@ -1,7 +1,7 @@ import * as winston from 'winston' import AWS from 'aws-sdk' -import type { Callback, Store } from '../../types/store' -import type { AmazonStoreConfig } from '../../types/config' +import type { Callback, Store } from 'src/types/store' +import type { AmazonStoreConfig } from 'src/types/config' class AmazonS3DocumentStore implements Store { bucket: string | undefined diff --git a/src/lib/document-stores/builder.ts b/src/lib/document-stores/builder.ts index 20ca45b..1f93769 100644 --- a/src/lib/document-stores/builder.ts +++ b/src/lib/document-stores/builder.ts @@ -1,5 +1,5 @@ -import type { Config } from '../../types/config' -import type { Store } from '../../types/store' +import type { Config } from 'src/types/config' +import type { Store } from 'src/types/store' const build = async (config: Config): Promise => { const DocumentStore = ( diff --git a/src/lib/document-stores/file.ts b/src/lib/document-stores/file.ts index 2376d34..bc6caaf 100644 --- a/src/lib/document-stores/file.ts +++ b/src/lib/document-stores/file.ts @@ -2,8 +2,8 @@ import * as winston from 'winston' import * as fs from 'fs' import * as crypto from 'crypto' -import type { Callback, Store } from '../../types/store' -import type { FileStoreConfig } from '../../types/config' +import type { Callback, Store } from 'src/types/store' +import type { FileStoreConfig } from 'src/types/config' // Generate md5 of a string const md5 = (str: string) => { diff --git a/src/lib/document-stores/google-datastore.ts b/src/lib/document-stores/google-datastore.ts index 921c2da..fb2c731 100644 --- a/src/lib/document-stores/google-datastore.ts +++ b/src/lib/document-stores/google-datastore.ts @@ -1,8 +1,8 @@ import { Datastore, PathType } from '@google-cloud/datastore' import * as winston from 'winston' -import type { Callback, Store } from '../../types/store' -import type { GoogleStoreConfig } from '../../types/config' +import type { Callback, Store } from 'src/types/store' +import type { GoogleStoreConfig } from 'src/types/config' class GoogleDatastoreDocumentStore implements Store { kind: string diff --git a/src/lib/document-stores/memcached.ts b/src/lib/document-stores/memcached.ts index 68f6add..bbce7ea 100644 --- a/src/lib/document-stores/memcached.ts +++ b/src/lib/document-stores/memcached.ts @@ -1,8 +1,8 @@ import * as winston from 'winston' import Memcached = require('memcached') -import type { Callback, Store } from '../../types/store' -import type { MemcachedStoreConfig } from '../../types/config' +import type { Callback, Store } from 'src/types/store' +import type { MemcachedStoreConfig } from 'src/types/config' class MemcachedDocumentStore implements Store { expire: number | undefined diff --git a/src/lib/document-stores/mongo.ts b/src/lib/document-stores/mongo.ts index 7fd2e57..9e58014 100644 --- a/src/lib/document-stores/mongo.ts +++ b/src/lib/document-stores/mongo.ts @@ -1,8 +1,8 @@ import * as winston from 'winston' import { MongoClient } from 'mongodb' -import type { Callback, Store } from '../../types/store' -import type { MongoStoreConfig } from '../../types/config' +import type { Callback, Store } from 'src/types/store' +import type { MongoStoreConfig } from 'src/types/config' type ConnectCallback = (error?: Error, db?: MongoClient) => void diff --git a/src/lib/document-stores/postgres.ts b/src/lib/document-stores/postgres.ts index 6e48491..5aab2f4 100644 --- a/src/lib/document-stores/postgres.ts +++ b/src/lib/document-stores/postgres.ts @@ -1,8 +1,8 @@ import * as winston from 'winston' import { Pool, PoolClient } from 'pg' -import type { Callback, Store } from '../../types/store' -import type { PostgresStoreConfig } from '../../types/config' +import type { Callback, Store } from 'src/types/store' +import type { PostgresStoreConfig } from 'src/types/config' type ConnectCallback = ( error?: Error, diff --git a/src/lib/document-stores/redis.ts b/src/lib/document-stores/redis.ts index 0e046e0..9da621d 100644 --- a/src/lib/document-stores/redis.ts +++ b/src/lib/document-stores/redis.ts @@ -1,8 +1,8 @@ import * as winston from 'winston' import { createClient } from 'redis' import { bool } from 'aws-sdk/clients/redshiftdata' -import { Callback, Store } from '../../types/store' -import { RedisStoreConfig } from '../../types/config' +import { Callback, Store } from 'src/types/store' +import { RedisStoreConfig } from 'src/types/config' export type RedisClientType = ReturnType diff --git a/src/lib/document-stores/rethinkdb.ts b/src/lib/document-stores/rethinkdb.ts index 5e9fda0..069e55b 100644 --- a/src/lib/document-stores/rethinkdb.ts +++ b/src/lib/document-stores/rethinkdb.ts @@ -3,8 +3,8 @@ import * as crypto from 'crypto' import rethink, { RethinkClient } from 'rethinkdbdash' -import type { RethinkDbStoreConfig } from '../../types/config' -import type { Callback } from '../../types/store' +import type { RethinkDbStoreConfig } from 'src/types/config' +import type { Callback } from 'src/types/store' const md5 = (str: string) => { const md5sum = crypto.createHash('md5') diff --git a/src/lib/helpers/config.ts b/src/lib/helpers/config.ts index 70a25df..492baca 100644 --- a/src/lib/helpers/config.ts +++ b/src/lib/helpers/config.ts @@ -1,7 +1,7 @@ import * as fs from 'fs' import * as path from 'path' -import { Config } from '../../types/config' +import { Config } from 'src/types/config' const getConfig = (): Config => { const configPath = diff --git a/src/lib/helpers/log.ts b/src/lib/helpers/log.ts index e3e9017..34a6f1e 100644 --- a/src/lib/helpers/log.ts +++ b/src/lib/helpers/log.ts @@ -1,5 +1,5 @@ import * as winston from 'winston' -import type { Config } from '../../types/config' +import type { Config } from 'src/types/config' const addLogging = (config: Config) => { try { diff --git a/src/lib/key-generators/builder.ts b/src/lib/key-generators/builder.ts index e5d24ff..6a61044 100644 --- a/src/lib/key-generators/builder.ts +++ b/src/lib/key-generators/builder.ts @@ -1,5 +1,5 @@ -import type { KeyGenerator } from '../../types/key-generator' -import type { Config } from '../../types/config' +import type { KeyGenerator } from 'src/types/key-generator' +import type { Config } from 'src/types/config' const build = async (config: Config): Promise => { const pwOptions = config.keyGenerator diff --git a/src/lib/key-generators/dictionary.ts b/src/lib/key-generators/dictionary.ts index f092040..0d2eec7 100644 --- a/src/lib/key-generators/dictionary.ts +++ b/src/lib/key-generators/dictionary.ts @@ -1,6 +1,6 @@ import * as fs from 'fs' -import type { KeyGeneratorConfig } from '../../types/config' -import type { KeyGenerator } from '../../types/key-generator' +import type { KeyGeneratorConfig } from 'src/types/config' +import type { KeyGenerator } from 'src/types/key-generator' class DictionaryGenerator implements KeyGenerator { type: string diff --git a/src/lib/key-generators/phonetic.ts b/src/lib/key-generators/phonetic.ts index 201271a..c9b9758 100644 --- a/src/lib/key-generators/phonetic.ts +++ b/src/lib/key-generators/phonetic.ts @@ -1,7 +1,7 @@ // Draws inspiration from pwgen and http://tools.arantius.com/password -import type { KeyGeneratorConfig } from '../../types/config' -import type { KeyGenerator } from '../../types/key-generator' +import type { KeyGeneratorConfig } from 'src/types/config' +import type { KeyGenerator } from 'src/types/key-generator' const randOf = (collection: string) => () => collection[Math.floor(Math.random() * collection.length)] diff --git a/src/lib/key-generators/random.ts b/src/lib/key-generators/random.ts index 66fe91d..e5185b8 100644 --- a/src/lib/key-generators/random.ts +++ b/src/lib/key-generators/random.ts @@ -1,5 +1,5 @@ -import type { KeyGeneratorConfig } from '../../types/config' -import type { KeyGenerator } from '../../types/key-generator' +import type { KeyGeneratorConfig } from 'src/types/config' +import type { KeyGenerator } from 'src/types/key-generator' class RandomKeyGenerator implements KeyGenerator { type: string diff --git a/src/server.ts b/src/server.ts index cc365bd..87eb2da 100644 --- a/src/server.ts +++ b/src/server.ts @@ -4,15 +4,15 @@ import * as winston from 'winston' import uglify from 'uglify-js' import connectSt from 'st' import connectRateLimit from 'connect-ratelimit' -import getConfig from './lib/helpers/config' -import addLogging from './lib/helpers/log' -import buildDocumenthandler from './lib/document-handler/builder' -import DocumentHandler from './lib/document-handler' -import { Config } from './types/config' +import { Config } from 'src/types/config' +import getConfig from 'src/lib/helpers/config' +import addLogging from 'src/lib/helpers/log' +import DocumentHandler from 'src/lib/document-handler' +import buildDocumenthandler from 'src/lib/document-handler/builder' import { getStaticDirectory, getStaticItemDirectory, -} from './lib/helpers/directory' +} from 'src/lib/helpers/directory' const config: Config = getConfig() diff --git a/test/document-handler/document-handler.test.ts b/test/document-handler/document-handler.test.ts index a35cfb0..c1a8977 100644 --- a/test/document-handler/document-handler.test.ts +++ b/test/document-handler/document-handler.test.ts @@ -1,9 +1,9 @@ import { createMock } from 'ts-auto-mock'; -import DocumentHandler from '../../src/lib/document-handler/index' -import Generator from '../../src/lib/key-generators/random' -import constants from '../../src/constants' -import { Store } from '../../src/types/store' -import { Config } from '../../src/types/config' +import DocumentHandler from 'src/lib/document-handler/index' +import Generator from 'src/lib/key-generators/random' +import constants from 'src/constants' +import { Store } from 'src/types/store' +import { Config } from 'src/types/config' const store : Store = createMock(); const config : Config = createMock(); diff --git a/test/document-stores/redis.test.ts b/test/document-stores/redis.test.ts index 0911682..adab84e 100644 --- a/test/document-stores/redis.test.ts +++ b/test/document-stores/redis.test.ts @@ -1,4 +1,4 @@ -import RedisDocumentStore from '../../src/lib/document-stores/redis' +import RedisDocumentStore from 'src/lib/document-stores/redis' describe('Redis document store', () => { let store: RedisDocumentStore diff --git a/test/key-generators/dictionary.test.ts b/test/key-generators/dictionary.test.ts index 262cf9d..291e083 100644 --- a/test/key-generators/dictionary.test.ts +++ b/test/key-generators/dictionary.test.ts @@ -1,11 +1,11 @@ -import Generator from '../../src/lib/key-generators/dictionary' +import Generator from 'src/lib/key-generators/dictionary' jest.mock('fs', () => ({ - readFile: jest.fn().mockImplementation((_, a, callback) => - callback(null, 'cat'), - ) - })) - + readFile: jest + .fn() + .mockImplementation((_, a, callback) => callback(null, 'cat')) +})) + describe('DictionaryGenerator', () => { describe('options', () => { it('should throw an error if given no options or path', () => { diff --git a/test/key-generators/phonetic.test.ts b/test/key-generators/phonetic.test.ts index 15e2a6b..74dcf45 100644 --- a/test/key-generators/phonetic.test.ts +++ b/test/key-generators/phonetic.test.ts @@ -1,5 +1,5 @@ /* eslint-disable jest/no-conditional-expect */ -import Generator from '../../src/lib/key-generators/phonetic' +import Generator from 'src/lib/key-generators/phonetic' const vowels = 'aeiou'; const consonants = 'bcdfghjklmnpqrstvwxyz'; diff --git a/test/key-generators/random.test.ts b/test/key-generators/random.test.ts index 49492c9..13f0f81 100644 --- a/test/key-generators/random.test.ts +++ b/test/key-generators/random.test.ts @@ -1,4 +1,4 @@ -import Generator from '../../src/lib/key-generators/random' +import Generator from 'src/lib/key-generators/random' describe('RandomKeyGenerator', () => { describe('generation', () => { diff --git a/tsconfig.json b/tsconfig.json index 7a2b2b1..0da9627 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -28,9 +28,7 @@ "sourceMap": true, "rootDir": ".", "outDir": "dist", - "paths": { - "~/*": ["/src/*"] - } + "baseUrl": ".", }, "include": ["src", "**/*.ts"], "exclude": ["node_modules"]