Skip to content

Commit

Permalink
move ajv to a singleton
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-smith-nz committed Aug 29, 2017
1 parent 0982452 commit 90b9312
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
11 changes: 11 additions & 0 deletions app/schemas.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const Ajv = require('ajv')
const ajv = new Ajv()

const taskPlanSchema = require('../tasks/schemas/taskPlan')
const taskRecipeSchema = require('../tasks/schemas/taskRecipe')
ajv.addSchema([
taskRecipeSchema,
taskPlanSchema
])

export default ajv
5 changes: 1 addition & 4 deletions tasks/services/plans.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
const feathersKnex = require('feathers-knex')
import { isEmpty, ifElse, is, assoc, prop, map, pipe, __ } from 'ramda'
const { iff, validateSchema } = require('feathers-hooks-common')
const Ajv = require('ajv')
const taskPlanSchema = require('../schemas/taskPlan')
const taskRecipeSchema = require('../schemas/taskRecipe')
const ajv = new Ajv({$data: true})
ajv.addSchema([taskRecipeSchema, taskPlanSchema])
import ajv from '../../app/schemas'
import * as taskRecipes from '../../tasks/data/recipes'

module.exports = function () {
Expand Down
6 changes: 1 addition & 5 deletions tasks/util/validateTaskPlan.test.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
import test from 'ava'
import * as mock from '../data/mock'
import ajv from '../../app/schemas'

const Ajv = require('ajv')
const { validateSchema } = require('feathers-hooks-common')
const schema = require('../schemas/taskPlan')
const taskRecipeSchema = require('../schemas/taskRecipe')

let ajv = new Ajv({ $data: true })
ajv.addSchema([taskRecipeSchema, schema])

let hookBefore

Expand Down
2 changes: 1 addition & 1 deletion tasks/util/validateTaskRecipe.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import test from 'ava'
import * as mock from '../data/mock'
import ajv from '../../app/schemas'

const ajv = require('ajv')
const { validateSchema } = require('feathers-hooks-common')
const schema = require('../schemas/taskRecipe')

Expand Down

0 comments on commit 90b9312

Please sign in to comment.