From 7d5a99d9d3f51dfbbee086e133b640c7c97bba25 Mon Sep 17 00:00:00 2001 From: Alicia Sykes Date: Sat, 5 Jun 2021 20:21:15 +0100 Subject: [PATCH] Calls config validator when serve starts, and adds documentation in readme --- README.md | 11 ++++++++--- package.json | 4 +++- server.js | 2 ++ 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index c7f27b2f..7c4ad024 100644 --- a/README.md +++ b/README.md @@ -42,6 +42,8 @@ ### Deploying from Docker Hub 🐳 +You will need [Docker](https://docs.docker.com/get-docker/) installed on your system + ```docker docker run -d \ -p 8080:80 \ @@ -50,16 +52,19 @@ docker run -d \ --restart=always \ lissy93/dashy:latest ``` -After making changes to your configuration file, you will need to run: `docker exec -it [container-id] yarn build` to rebuild. Container ID can be found by running `docker ps` - +After making changes to your configuration file, you will need to run: `docker exec -it [container-id] yarn build` to rebuild. You can also run other commands, such as `yarn validate-config` this way too. Container ID can be found by running `docker ps`. ### Deploying from Source 🚀 + +You will need both [git](https://git-scm.com/downloads) and the latest or LTS version of [Node.js](https://nodejs.org/) installed on your system + - Get Code: `git clone git@github.com:Lissy93/dashy.git` and `cd dashy` - Configuration: Fill in you're settings in `./public/conf.yml` - Install dependencies: `yarn` - Build: `yarn build` - Run: `yarn start` -After making changes to your configuration file, you will need to run: `yarn build` to rebuild +After making changes to your configuration file, you will need to run: `yarn build` to rebuild. +You can check that your config is valid, and matches the schema by running `yarn validate-config` ### Developing 🧱 - Get Code: `git clone git@github.com:Lissy93/dashy.git` and `cd dashy` diff --git a/package.json b/package.json index 40c4173d..32992561 100644 --- a/package.json +++ b/package.json @@ -8,9 +8,11 @@ "build": "vue-cli-service build", "lint": "vue-cli-service lint --fix", "build-watch": "vue-cli-service build --watch", - "build-and-start": "npm-run-all --parallel build start" + "build-and-start": "npm-run-all --parallel build start", + "validate-config": "node src/utils/ConfigValidator" }, "dependencies": { + "ajv": "^8.5.0", "axios": "^0.21.1", "connect": "^3.7.0", "crypto-js": "^4.0.0", diff --git a/server.js b/server.js index bc9872ec..0e0c0016 100644 --- a/server.js +++ b/server.js @@ -5,6 +5,8 @@ const util = require('util'); const dns = require('dns'); const os = require('os'); +require('./src/utils/ConfigValidator'); + const port = process.env.PORT || 80; /* eslint no-console: 0 */