Move validator into separate package

This commit is contained in:
Jerko Steiner 2019-09-14 11:41:21 +07:00
parent 1eafdf7fd8
commit c14456b606
18 changed files with 90 additions and 29 deletions

View File

@ -16,7 +16,8 @@
"@rondo.dev/redux": "file:packages/redux", "@rondo.dev/redux": "file:packages/redux",
"@rondo.dev/http-client": "file:packages/http-client", "@rondo.dev/http-client": "file:packages/http-client",
"@rondo.dev/test-utils": "file:packages/test-utils", "@rondo.dev/test-utils": "file:packages/test-utils",
"@rondo.dev/http-types": "file:packages/http-types" "@rondo.dev/http-types": "file:packages/http-types",
"@rondo.dev/validator": "file:packages/validator"
}, },
"devDependencies": { "devDependencies": {
"@types/bcrypt": "^3.0.0", "@types/bcrypt": "^3.0.0",

View File

@ -13,7 +13,6 @@ export * from './router'
export * from './routes' export * from './routes'
export * from './services' export * from './services'
export * from './session' export * from './session'
export * from './validator'
import * as rpc from './rpc' import * as rpc from './rpc'
export {rpc} export {rpc}

View File

@ -1,7 +1,7 @@
import {TErrorHandler} from './TErrorHandler' import {TErrorHandler} from './TErrorHandler'
import {ILogger} from '@rondo.dev/logger' import {ILogger} from '@rondo.dev/logger'
import {IMiddleware} from './IMiddleware' import {IMiddleware} from './IMiddleware'
import {ValidationError} from '../validator' import {ValidationError} from '@rondo.dev/validator'
export class ErrorApiHandler implements IMiddleware { export class ErrorApiHandler implements IMiddleware {
constructor(readonly logger: ILogger) {} constructor(readonly logger: ILogger) {}

View File

@ -1,19 +1,11 @@
import {IDatabase} from '../database/IDatabase' import { ITeamAddUserParams, ITeamCreateParams, ITeamRemoveParams, ITeamService, ITeamUpdateParams, trim } from '@rondo.dev/common'
import {Validator} from '../validator'
import {Team} from '../entities/Team'
import {UserTeam} from '../entities/UserTeam'
import {IUserPermissions} from '../services/IUserPermissions'
import {
trim,
entities as e,
ITeamService,
ITeamCreateParams,
ITeamRemoveParams,
ITeamUpdateParams,
ITeamAddUserParams,
} from '@rondo.dev/common'
import { ensureLoggedIn, IContext, RPC } from './RPC'
import { IUserInTeam } from '@rondo.dev/common/lib/team/IUserInTeam' import { IUserInTeam } from '@rondo.dev/common/lib/team/IUserInTeam'
import Validator from '@rondo.dev/validator'
import { IDatabase } from '../database/IDatabase'
import { Team } from '../entities/Team'
import { UserTeam } from '../entities/UserTeam'
import { IUserPermissions } from '../services/IUserPermissions'
import { ensureLoggedIn, IContext, RPC } from './RPC'
@ensureLoggedIn @ensureLoggedIn
export class TeamService implements RPC<ITeamService> { export class TeamService implements RPC<ITeamService> {

View File

@ -1,12 +1,12 @@
import { ICredentials, INewUser, IUser, trim } from '@rondo.dev/common'; import { ICredentials, INewUser, IUser, trim } from '@rondo.dev/common'
import { compare, hash } from 'bcrypt'; import Validator from '@rondo.dev/validator'
import { validate as validateEmail } from 'email-validator'; import { compare, hash } from 'bcrypt'
import createError from 'http-errors'; import { validate as validateEmail } from 'email-validator'
import { IDatabase } from '../database/IDatabase'; import createError from 'http-errors'
import { User } from '../entities/User'; import { IDatabase } from '../database/IDatabase'
import { UserEmail } from '../entities/UserEmail'; import { User } from '../entities/User'
import { Validator } from '../validator'; import { UserEmail } from '../entities/UserEmail'
import { IAuthService } from './IAuthService'; import { IAuthService } from './IAuthService'
const SALT_ROUNDS = 10 const SALT_ROUNDS = 10
const MIN_PASSWORD_LENGTH = 10 const MIN_PASSWORD_LENGTH = 10

View File

@ -11,6 +11,7 @@
{"path": "../config"}, {"path": "../config"},
{"path": "../tasq"}, {"path": "../tasq"},
{"path": "../http-client"}, {"path": "../http-client"},
{"path": "../http-types"} {"path": "../http-types"},
{"path": "../validator"}
] ]
} }

View File

@ -0,0 +1,16 @@
module.exports = {
roots: [
'<rootDir>/src'
],
transform: {
'^.+\\.tsx?$': 'ts-jest'
},
testRegex: '(/__tests__/.*|\\.(test|spec))\\.tsx?$',
moduleFileExtensions: [
'ts',
'tsx',
'js',
'jsx'
],
setupFiles: ['<rootDir>/jest.setup.js']
}

View File

@ -0,0 +1,4 @@
if (!process.env.LOG) {
process.env.LOG = 'sql:warn'
}
process.chdir(__dirname)

4
packages/validator/package-lock.json generated Normal file
View File

@ -0,0 +1,4 @@
{
"name": "@rondo.dev/validator",
"lockfileVersion": 1
}

View File

@ -0,0 +1,14 @@
{
"name": "@rondo.dev/validator",
"private": true,
"scripts": {
"test": "jest",
"lint": "tslint --project .",
"compile": "tsc",
"clean": "rm -rf lib/"
},
"dependencies": {},
"main": "lib/index.js",
"module": "esm/index.js",
"types": "lib/index.d.ts"
}

View File

@ -1,3 +1,6 @@
export * from './IValidationMessage' export * from './IValidationMessage'
export * from './ValidationError' export * from './ValidationError'
export * from './Validator' export * from './Validator'
import {Validator} from './Validator'
export default Validator

View File

@ -0,0 +1,8 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "esm"
},
"references": [
]
}

View File

@ -0,0 +1,9 @@
{
"extends": "../tsconfig.common.json",
"compilerOptions": {
"outDir": "lib",
"rootDir": "src"
},
"references": [
]
}

View File

@ -0,0 +1,10 @@
{
"extends": [
"../tslint.json"
],
"linterOptions": {
"exclude": [
"src/migrations/*.ts"
]
}
}