Added schema validation for configs

react_convert
Mark Moffat 2018-01-10 21:20:52 +01:00
parent 2e2e4b3834
commit aabf6c44e3
11 changed files with 533 additions and 3538 deletions

108
config/baseSchema.json Normal file
View File

@ -0,0 +1,108 @@
{
"properties": {
"cartTitle": {
"type": "string",
"default": "expressCart"
},
"cartDescription": {
"type": "string",
"default": "This is my expressCart"
},
"cartLogo": {
"type": "string"
},
"baseUrl": {
"type": "string",
"format": "uri-template",
"default": "http://localhost:1111"
},
"emailHost": {
"format": "uri-template",
"type": "string"
},
"emailPort": {
"type": "number",
"default": 587
},
"emailSecure": {
"type": "boolean",
"default": false
},
"emailUser": {
"type": "string"
},
"emailPassword": {
"type": "string"
},
"emailAddress": {
"type": "string",
"format": "email"
},
"menuEnabled": {
"type": "boolean",
"default": true
},
"flatShipping": {
"type": "number",
"default": 10
},
"freeShippingAmount": {
"type": "number",
"default": 100
},
"productsPerRow": {
"type": "number",
"default": 3
},
"productsPerPage": {
"type": "number",
"default": 6
},
"menuTitle": {
"type": "string",
"default": "Menu"
},
"menuLocation": {
"type": "string",
"default": "side",
"enum": ["top", "side"]
},
"footerHtml": {
"type": "string",
"default": "<h4 class="text-center">Powered by expressCart</h4>"
},
"googleAnalytics": {
"type": "string"
},
"customCss": {
"type": "string"
},
"currencySymbol": {
"type": "string",
"default": "£"
},
"paymentGateway": {
"type": "string",
"enum": ["paypal", "stripe"]
},
"databaseConnectionString": {
"format": "uri-template",
"type": "string"
},
"theme": {
"type": "string"
}
},
"required": [
"baseUrl",
"emailHost",
"emailPort",
"emailSecure",
"emailUser",
"emailPassword",
"emailAddress",
"paymentGateway",
"databaseConnectionString"
],
"additionalProperties": false
}

28
config/paypalSchema.json Normal file
View File

@ -0,0 +1,28 @@
{
"properties": {
"mode": {
"type": "string",
"enum": ["sandbox", "live"]
},
"client_id": {
"type": "string"
},
"client_secret": {
"type": "string"
},
"paypalCartDescription": {
"type": "string"
},
"paypalCurrency": {
"type": "string"
}
},
"required": [
"mode",
"client_id",
"client_secret",
"paypalCartDescription",
"paypalCurrency"
],
"additionalProperties": false
}

View File

@ -4,23 +4,23 @@
"cartLogo": "", "cartLogo": "",
"baseUrl": "http://localhost:1111", "baseUrl": "http://localhost:1111",
"emailHost": "smtp-mail.outlook.com", "emailHost": "smtp-mail.outlook.com",
"emailPort": "587", "emailPort": 587,
"emailSecure": false, "emailSecure": false,
"emailUser": "hi@markmoffat.com", "emailUser": "hi@markmoffat.com",
"emailPassword": "this_is_the_smtp_password", "emailPassword": "this_is_the_smtp_password",
"emailAddress": "hi@markmoffat.com", "emailAddress": "hi@markmoffat.com",
"menuEnabled": "true", "menuEnabled": true,
"flatShipping": "10", "flatShipping": 10,
"freeShippingAmount": "100", "freeShippingAmount": 100,
"productsPerRow": "3", "productsPerRow": 3,
"productsPerPage": "6", "productsPerPage": 6,
"menuTitle": "Menu", "menuTitle": "Menu",
"menuLocation": "side", "menuLocation": "side",
"footerHtml": "<h4 class="text-center">Powered by expressCart</h4>", "footerHtml": "<h4 class="text-center">Powered by expressCart</h4>",
"googleAnalytics": "", "googleAnalytics": "",
"customCss": ".footer{padding-top: 5px;}", "customCss": ".footer{padding-top: 5px;}",
"currencySymbol": "£", "currencySymbol": "£",
"paymentGateway": "paypal", "paymentGateway": "stripe",
"databaseConnectionString": "mongodb://localhost:27017/expresscart", "databaseConnectionString": "mongodb://expresscart:test@ds139909.mlab.com:39909/expresscart",
"theme": "Cloth" "theme": "Cloth"
} }

View File

@ -1,7 +1,7 @@
{ {
"secretKey": "sk_test_this_is_not_real", "secretKey": "sk_test_this_is_not_real",
"publicKey": "pk_test_this_is_not_real", "publicKey": "pk_test_this_is_not_real",
"stripeCurrency": "aud", "stripeCurrency": "usd",
"stripeDescription": "expressCart payment", "stripeDescription": "expressCart payment",
"stripeLogoURL": "http://localhost:1111/images/stripelogo.png" "stripeLogoURL": "http://localhost:1111/images/stripelogo.png"
} }

29
config/stripeSchema.json Normal file
View File

@ -0,0 +1,29 @@
{
"properties": {
"secretKey": {
"type": "string",
"default": "sandbox"
},
"publicKey": {
"type": "string"
},
"stripeCurrency": {
"type": "string"
},
"stripeDescription": {
"type": "string"
},
"stripeLogoURL": {
"type": "string",
"format": "uri-template"
}
},
"required": [
"secretKey",
"publicKey",
"stripeCurrency",
"stripeDescription",
"stripeLogoURL"
],
"additionalProperties": false
}

3860
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -8,6 +8,7 @@
"deploy": "gulp deploy" "deploy": "gulp deploy"
}, },
"dependencies": { "dependencies": {
"ajv": "^6.0.0",
"async": "^2.6.0", "async": "^2.6.0",
"bcrypt-nodejs": "0.0.3", "bcrypt-nodejs": "0.0.3",
"body-parser": "^1.17.2", "body-parser": "^1.17.2",
@ -25,6 +26,7 @@
"lunr": "^2.1.5", "lunr": "^2.1.5",
"moment": "^2.15.2", "moment": "^2.15.2",
"mongodb": "^3.0.1", "mongodb": "^3.0.1",
"mongodb-uri": "^0.9.7",
"morgan": "^1.9.0", "morgan": "^1.9.0",
"multer": "^1.1.0", "multer": "^1.1.0",
"nodemailer": "^4.4.1", "nodemailer": "^4.4.1",

View File

@ -2,7 +2,7 @@
<div class="row"> <div class="row">
<form action="/search" id="search_form" method="post"> <form action="/search" id="search_form" method="post">
<div class="row"> <div class="row">
{{#ifCond config.menuEnabled '==' "true"}} {{#ifCond config.menuEnabled '==' 'true'}}
{{#ifCond config.menuLocation '==' "side"}} {{#ifCond config.menuLocation '==' "side"}}
<div class="col-md-offset-2 col-lg-offset-2 col-xl-9 col-xl-offset-3 search-bar col-md-10 search-bar"> <div class="col-md-offset-2 col-lg-offset-2 col-xl-9 col-xl-offset-3 search-bar col-md-10 search-bar">
{{else}} {{else}}
@ -23,7 +23,7 @@
</form> </form>
</div> </div>
<div class="row"> <div class="row">
{{#ifCond config.menuEnabled '==' "true"}} {{#ifCond config.menuEnabled '==' 'true'}}
{{#ifCond config.menuLocation '==' "side"}} {{#ifCond config.menuLocation '==' "side"}}
<div class="col-xl-3 col-md-2"> <div class="col-xl-3 col-md-2">
<ul class="list-group menu-side"> <ul class="list-group menu-side">

View File

@ -1,7 +1,7 @@
<div class="col-xl-8 col-xl-offset-2 col-xs-12"> <div class="col-xl-8 col-xl-offset-2 col-xs-12">
<div class="row"> <div class="row">
<form> <form>
{{#ifCond config.menuEnabled '==' "true"}} {{#ifCond config.menuEnabled '==' 'true'}}
{{#ifCond config.menuLocation '==' "side"}} {{#ifCond config.menuLocation '==' "side"}}
<div class="col-md-offset-2 col-lg-offset-2 col-xl-9 col-xl-offset-3 search-bar col-md-10 search-bar"> <div class="col-md-offset-2 col-lg-offset-2 col-xl-9 col-xl-offset-3 search-bar col-md-10 search-bar">
{{else}} {{else}}
@ -21,7 +21,7 @@
</form> </form>
</div> </div>
<div class="row"> <div class="row">
{{#ifCond config.menuEnabled '==' "true"}} {{#ifCond config.menuEnabled '==' 'true'}}
{{#ifCond config.menuLocation '==' "side"}} {{#ifCond config.menuLocation '==' "side"}}
<div class="col-xl-3 col-md-2"> <div class="col-xl-3 col-md-2">
<ul class="list-group menu-side"> <ul class="list-group menu-side">
@ -78,7 +78,7 @@
</h3> </h3>
</a> </a>
</div> </div>
{{else}} {{else}}
<a href="/product/{{this._id}}"> <a href="/product/{{this._id}}">
<div class="vertical-center thumbnail-image-container"> <div class="vertical-center thumbnail-image-container">
{{#if productImage}} {{#if productImage}}

View File

@ -2,7 +2,7 @@
<div class="row"> <div class="row">
<form action="/search" id="search_form" method="post"> <form action="/search" id="search_form" method="post">
<div class="row"> <div class="row">
{{#ifCond config.menuEnabled '==' "true"}} {{#ifCond config.menuEnabled '==' 'true'}}
{{#ifCond config.menuLocation '==' "side"}} {{#ifCond config.menuLocation '==' "side"}}
<div class="col-md-offset-2 col-lg-offset-2 col-xl-9 col-xl-offset-3 search-bar col-md-10 search-bar"> <div class="col-md-offset-2 col-lg-offset-2 col-xl-9 col-xl-offset-3 search-bar col-md-10 search-bar">
{{else}} {{else}}
@ -23,7 +23,7 @@
</form> </form>
</div> </div>
<div class="row"> <div class="row">
{{#ifCond config.menuEnabled '==' "true"}} {{#ifCond config.menuEnabled '==' 'true'}}
{{#ifCond config.menuLocation '==' "side"}} {{#ifCond config.menuLocation '==' "side"}}
<div class="col-xl-3 col-md-2"> <div class="col-xl-3 col-md-2">
<ul class="list-group menu-side"> <ul class="list-group menu-side">

View File

@ -1,6 +1,6 @@
<div class="col-xl-8 col-xl-offset-2 col-xs-12"> <div class="col-xl-8 col-xl-offset-2 col-xs-12">
<div class="row"> <div class="row">
{{#ifCond config.menuEnabled '==' "true"}} {{#ifCond config.menuEnabled '==' 'true'}}
{{#ifCond config.menuLocation '==' "side"}} {{#ifCond config.menuLocation '==' "side"}}
<div class="col-xl-3 col-md-2"> <div class="col-xl-3 col-md-2">
<ul class="list-group menu-side"> <ul class="list-group menu-side">
@ -92,13 +92,13 @@
{{{productDescription}}} {{{productDescription}}}
</p> </p>
</div> </div>
<div class="col-xs-12 col-md-6 pull-left"> <div class="col-xs-12 col-md-6 pull-left">
{{#if result.productImage}} {{#if result.productImage}}
<div class="title-image-container"> <div class="title-image-container">
<div class="image-prev image-button"> <i class="fa fa-chevron-left" aria-hidden="true"></i></div> <div class="image-prev image-button"> <i class="fa fa-chevron-left" aria-hidden="true"></i></div>
<img src="{{result.productImage}}" id="product-title-image" class="product-title-image img-responsive" alt="..."> <img src="{{result.productImage}}" id="product-title-image" class="product-title-image img-responsive" alt="...">
<div class="image-next image-button"> <i class="fa fa-chevron-right" aria-hidden="true"></i></div> <div class="image-next image-button"> <i class="fa fa-chevron-right" aria-hidden="true"></i></div>
</div> </div>
{{else}} {{else}}
<div class="title-image-container"> <div class="title-image-container">
<img src="/uploads/placeholder.png" id="product-title-image" class="product-title-image img-responsive" alt="..."> <img src="/uploads/placeholder.png" id="product-title-image" class="product-title-image img-responsive" alt="...">
@ -106,16 +106,16 @@
{{/if}} {{/if}}
{{#ifCond images.length '>' 1}} {{#ifCond images.length '>' 1}}
<div class="row"> <div class="row">
{{#each images}} {{#each images}}
<div class="vertical-center top-pad-20 col-xs-6 col-lg-6 col-xl-6"> <div class="vertical-center top-pad-20 col-xs-6 col-lg-6 col-xl-6">
<img src="{{this.path}}" class="thumbnail-image img-responsive"> <img src="{{this.path}}" class="thumbnail-image img-responsive">
</div> </div>
{{/each}} {{/each}}
</div> </div>
{{/ifCond}} {{/ifCond}}
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<input type="hidden" id="productId" value="{{result._id}}"> <input type="hidden" id="productId" value="{{result._id}}">