1
0
Fork 0
mirror of https://github.com/seejohnrun/haste-server.git synced 2024-11-01 11:31:22 +00:00

add relative paths

This commit is contained in:
Yusuf Yilmaz 2022-06-06 19:38:20 +02:00
parent ab47249505
commit 21aa23dd28
26 changed files with 71 additions and 67 deletions

View file

@ -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 To use redis storage you must install the `redis` package in npm, and have
`redis-server` running on the machine. `redis-server` running on the machine.
`npm install redis` `yarn install redis`
Once you've done that, your config section should look like: 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 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: 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 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: 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 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: 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 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: 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 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: 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 To use [Amazon S3](https://aws.amazon.com/s3/) as a storage system, you must
install the `aws-sdk` package via npm: 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: Once you've done that, your config section should look like this:

View file

@ -4,5 +4,11 @@ module.exports = {
testEnvironment: 'node', testEnvironment: 'node',
rootDir: '../', rootDir: '../',
testRegex: '\\.test\\.ts$', testRegex: '\\.test\\.ts$',
reporters: ['default'] reporters: ['default'],
roots: [
"test"
],
moduleNameMapper: {
"src/(.*)": "<rootDir>/src/$1"
}
} }

View file

@ -1,6 +1,6 @@
import type { Config } from '../../types/config' import buildGenerator from 'src/lib/key-generators/builder'
import buildGenerator from '../key-generators/builder' import type { Config } from 'src/types/config'
import buildStore from '../document-stores/builder' import buildStore from 'src/lib/document-stores/builder'
import DocumentHandler from "./index" import DocumentHandler from "./index"
const build = async (config: Config) => { const build = async (config: Config) => {

View file

@ -1,11 +1,11 @@
import { Request, Response } from 'express' import { Request, Response } from 'express'
import * as winston from 'winston' import * as winston from 'winston'
import Busboy from 'busboy' import Busboy from 'busboy'
import type { Config } from '../../types/config' import type { Config } from 'src/types/config'
import type { Store } from '../../types/store' import type { Store } from 'src/types/store'
import type { KeyGenerator } from '../../types/key-generator' import type { KeyGenerator } from 'src/types/key-generator'
import type { Document } from '../../types/document' import type { Document } from 'src/types/document'
import constants from '../../constants' import constants from 'src/constants'
class DocumentHandler { class DocumentHandler {
keyLength: number keyLength: number

View file

@ -1,7 +1,7 @@
import * as winston from 'winston' import * as winston from 'winston'
import AWS from 'aws-sdk' import AWS from 'aws-sdk'
import type { Callback, Store } from '../../types/store' import type { Callback, Store } from 'src/types/store'
import type { AmazonStoreConfig } from '../../types/config' import type { AmazonStoreConfig } from 'src/types/config'
class AmazonS3DocumentStore implements Store { class AmazonS3DocumentStore implements Store {
bucket: string | undefined bucket: string | undefined

View file

@ -1,5 +1,5 @@
import type { Config } from '../../types/config' import type { Config } from 'src/types/config'
import type { Store } from '../../types/store' import type { Store } from 'src/types/store'
const build = async (config: Config): Promise<Store> => { const build = async (config: Config): Promise<Store> => {
const DocumentStore = ( const DocumentStore = (

View file

@ -2,8 +2,8 @@ import * as winston from 'winston'
import * as fs from 'fs' import * as fs from 'fs'
import * as crypto from 'crypto' import * as crypto from 'crypto'
import type { Callback, Store } from '../../types/store' import type { Callback, Store } from 'src/types/store'
import type { FileStoreConfig } from '../../types/config' import type { FileStoreConfig } from 'src/types/config'
// Generate md5 of a string // Generate md5 of a string
const md5 = (str: string) => { const md5 = (str: string) => {

View file

@ -1,8 +1,8 @@
import { Datastore, PathType } from '@google-cloud/datastore' import { Datastore, PathType } from '@google-cloud/datastore'
import * as winston from 'winston' import * as winston from 'winston'
import type { Callback, Store } from '../../types/store' import type { Callback, Store } from 'src/types/store'
import type { GoogleStoreConfig } from '../../types/config' import type { GoogleStoreConfig } from 'src/types/config'
class GoogleDatastoreDocumentStore implements Store { class GoogleDatastoreDocumentStore implements Store {
kind: string kind: string

View file

@ -1,8 +1,8 @@
import * as winston from 'winston' import * as winston from 'winston'
import Memcached = require('memcached') import Memcached = require('memcached')
import type { Callback, Store } from '../../types/store' import type { Callback, Store } from 'src/types/store'
import type { MemcachedStoreConfig } from '../../types/config' import type { MemcachedStoreConfig } from 'src/types/config'
class MemcachedDocumentStore implements Store { class MemcachedDocumentStore implements Store {
expire: number | undefined expire: number | undefined

View file

@ -1,8 +1,8 @@
import * as winston from 'winston' import * as winston from 'winston'
import { MongoClient } from 'mongodb' import { MongoClient } from 'mongodb'
import type { Callback, Store } from '../../types/store' import type { Callback, Store } from 'src/types/store'
import type { MongoStoreConfig } from '../../types/config' import type { MongoStoreConfig } from 'src/types/config'
type ConnectCallback = (error?: Error, db?: MongoClient) => void type ConnectCallback = (error?: Error, db?: MongoClient) => void

View file

@ -1,8 +1,8 @@
import * as winston from 'winston' import * as winston from 'winston'
import { Pool, PoolClient } from 'pg' import { Pool, PoolClient } from 'pg'
import type { Callback, Store } from '../../types/store' import type { Callback, Store } from 'src/types/store'
import type { PostgresStoreConfig } from '../../types/config' import type { PostgresStoreConfig } from 'src/types/config'
type ConnectCallback = ( type ConnectCallback = (
error?: Error, error?: Error,

View file

@ -1,8 +1,8 @@
import * as winston from 'winston' import * as winston from 'winston'
import { createClient } from 'redis' import { createClient } from 'redis'
import { bool } from 'aws-sdk/clients/redshiftdata' import { bool } from 'aws-sdk/clients/redshiftdata'
import { Callback, Store } from '../../types/store' import { Callback, Store } from 'src/types/store'
import { RedisStoreConfig } from '../../types/config' import { RedisStoreConfig } from 'src/types/config'
export type RedisClientType = ReturnType<typeof createClient> export type RedisClientType = ReturnType<typeof createClient>

View file

@ -3,8 +3,8 @@ import * as crypto from 'crypto'
import rethink, { RethinkClient } from 'rethinkdbdash' import rethink, { RethinkClient } from 'rethinkdbdash'
import type { RethinkDbStoreConfig } from '../../types/config' import type { RethinkDbStoreConfig } from 'src/types/config'
import type { Callback } from '../../types/store' import type { Callback } from 'src/types/store'
const md5 = (str: string) => { const md5 = (str: string) => {
const md5sum = crypto.createHash('md5') const md5sum = crypto.createHash('md5')

View file

@ -1,7 +1,7 @@
import * as fs from 'fs' import * as fs from 'fs'
import * as path from 'path' import * as path from 'path'
import { Config } from '../../types/config' import { Config } from 'src/types/config'
const getConfig = (): Config => { const getConfig = (): Config => {
const configPath = const configPath =

View file

@ -1,5 +1,5 @@
import * as winston from 'winston' import * as winston from 'winston'
import type { Config } from '../../types/config' import type { Config } from 'src/types/config'
const addLogging = (config: Config) => { const addLogging = (config: Config) => {
try { try {

View file

@ -1,5 +1,5 @@
import type { KeyGenerator } from '../../types/key-generator' import type { KeyGenerator } from 'src/types/key-generator'
import type { Config } from '../../types/config' import type { Config } from 'src/types/config'
const build = async (config: Config): Promise<KeyGenerator> => { const build = async (config: Config): Promise<KeyGenerator> => {
const pwOptions = config.keyGenerator const pwOptions = config.keyGenerator

View file

@ -1,6 +1,6 @@
import * as fs from 'fs' import * as fs from 'fs'
import type { KeyGeneratorConfig } from '../../types/config' import type { KeyGeneratorConfig } from 'src/types/config'
import type { KeyGenerator } from '../../types/key-generator' import type { KeyGenerator } from 'src/types/key-generator'
class DictionaryGenerator implements KeyGenerator { class DictionaryGenerator implements KeyGenerator {
type: string type: string

View file

@ -1,7 +1,7 @@
// Draws inspiration from pwgen and http://tools.arantius.com/password // Draws inspiration from pwgen and http://tools.arantius.com/password
import type { KeyGeneratorConfig } from '../../types/config' import type { KeyGeneratorConfig } from 'src/types/config'
import type { KeyGenerator } from '../../types/key-generator' import type { KeyGenerator } from 'src/types/key-generator'
const randOf = (collection: string) => () => const randOf = (collection: string) => () =>
collection[Math.floor(Math.random() * collection.length)] collection[Math.floor(Math.random() * collection.length)]

View file

@ -1,5 +1,5 @@
import type { KeyGeneratorConfig } from '../../types/config' import type { KeyGeneratorConfig } from 'src/types/config'
import type { KeyGenerator } from '../../types/key-generator' import type { KeyGenerator } from 'src/types/key-generator'
class RandomKeyGenerator implements KeyGenerator { class RandomKeyGenerator implements KeyGenerator {
type: string type: string

View file

@ -4,15 +4,15 @@ import * as winston from 'winston'
import uglify from 'uglify-js' import uglify from 'uglify-js'
import connectSt from 'st' import connectSt from 'st'
import connectRateLimit from 'connect-ratelimit' import connectRateLimit from 'connect-ratelimit'
import getConfig from './lib/helpers/config' import { Config } from 'src/types/config'
import addLogging from './lib/helpers/log' import getConfig from 'src/lib/helpers/config'
import buildDocumenthandler from './lib/document-handler/builder' import addLogging from 'src/lib/helpers/log'
import DocumentHandler from './lib/document-handler' import DocumentHandler from 'src/lib/document-handler'
import { Config } from './types/config' import buildDocumenthandler from 'src/lib/document-handler/builder'
import { import {
getStaticDirectory, getStaticDirectory,
getStaticItemDirectory, getStaticItemDirectory,
} from './lib/helpers/directory' } from 'src/lib/helpers/directory'
const config: Config = getConfig() const config: Config = getConfig()

View file

@ -1,9 +1,9 @@
import { createMock } from 'ts-auto-mock'; import { createMock } from 'ts-auto-mock';
import DocumentHandler from '../../src/lib/document-handler/index' import DocumentHandler from 'src/lib/document-handler/index'
import Generator from '../../src/lib/key-generators/random' import Generator from 'src/lib/key-generators/random'
import constants from '../../src/constants' import constants from 'src/constants'
import { Store } from '../../src/types/store' import { Store } from 'src/types/store'
import { Config } from '../../src/types/config' import { Config } from 'src/types/config'
const store : Store = createMock<Store>(); const store : Store = createMock<Store>();
const config : Config = createMock<Config>(); const config : Config = createMock<Config>();

View file

@ -1,4 +1,4 @@
import RedisDocumentStore from '../../src/lib/document-stores/redis' import RedisDocumentStore from 'src/lib/document-stores/redis'
describe('Redis document store', () => { describe('Redis document store', () => {
let store: RedisDocumentStore let store: RedisDocumentStore

View file

@ -1,10 +1,10 @@
import Generator from '../../src/lib/key-generators/dictionary' import Generator from 'src/lib/key-generators/dictionary'
jest.mock('fs', () => ({ jest.mock('fs', () => ({
readFile: jest.fn().mockImplementation((_, a, callback) => readFile: jest
callback(null, 'cat'), .fn()
) .mockImplementation((_, a, callback) => callback(null, 'cat'))
})) }))
describe('DictionaryGenerator', () => { describe('DictionaryGenerator', () => {
describe('options', () => { describe('options', () => {

View file

@ -1,5 +1,5 @@
/* eslint-disable jest/no-conditional-expect */ /* 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 vowels = 'aeiou';
const consonants = 'bcdfghjklmnpqrstvwxyz'; const consonants = 'bcdfghjklmnpqrstvwxyz';

View file

@ -1,4 +1,4 @@
import Generator from '../../src/lib/key-generators/random' import Generator from 'src/lib/key-generators/random'
describe('RandomKeyGenerator', () => { describe('RandomKeyGenerator', () => {
describe('generation', () => { describe('generation', () => {

View file

@ -28,9 +28,7 @@
"sourceMap": true, "sourceMap": true,
"rootDir": ".", "rootDir": ".",
"outDir": "dist", "outDir": "dist",
"paths": { "baseUrl": ".",
"~/*": ["/src/*"]
}
}, },
"include": ["src", "**/*.ts"], "include": ["src", "**/*.ts"],
"exclude": ["node_modules"] "exclude": ["node_modules"]