-
+
diff --git a/client/src/main.js b/client/src/main.js
index 98004e9..db0cc12 100644
--- a/client/src/main.js
+++ b/client/src/main.js
@@ -3,29 +3,37 @@ import Vue from 'vue'
import VueRouter from 'vue-router'
import App from './app.vue'
-import { VueMasonryPlugin } from 'vue-masonry';
+// Auth
+require('dotenv').config()
-import { BootstrapVue } from 'bootstrap-vue'
// Router
import routes from './routes'
+Vue.use(VueRouter)
// Jquery
import jquery from 'jquery'
window.$ = jquery
window.jquery = jquery
+// Global styles
+import './assets/scss/_global.scss'
+
// Bootstrap
import 'bootstrap/dist/css/bootstrap.css'
import 'bootstrap-vue/dist/bootstrap-vue.css'
import 'bootstrap/dist/js/bootstrap.js'
+import { BootstrapVue } from 'bootstrap-vue'
+Vue.use(BootstrapVue)
-// Styles
-import './assets/scss/_global.scss'
+// Masonry
+import { VueMasonryPlugin } from 'vue-masonry';
+Vue.use(VueMasonryPlugin)
+
+// Clipboard plugin
+import clipboard from 'v-clipboard'
+Vue.use(clipboard)
Vue.config.productionTip = false
-Vue.use(VueRouter)
-Vue.use(VueMasonryPlugin)
-Vue.use(BootstrapVue)
var filter = function(text, length, clamp){
clamp = clamp || '...';
diff --git a/client/vue.config.js b/client/vue.config.js
index e180b24..a88cc74 100644
--- a/client/vue.config.js
+++ b/client/vue.config.js
@@ -1,2 +1,3 @@
module.exports = {
+
};
\ No newline at end of file
diff --git a/database/bookshelf.js b/database/bookshelf.js
index 6299281..ddd5b9e 100644
--- a/database/bookshelf.js
+++ b/database/bookshelf.js
@@ -2,19 +2,15 @@
const fs = require('fs')
const mysql = require('mysql')
-// Fetches and parses credentials file
-let credentials_data = fs.readFileSync('./database/credentials.json')
-let credentials = JSON.parse(credentials_data)
-
// Setting up the database connection
const knex = require('knex')({
- client: credentials.client,
+ client: "mysql",
connection: {
- host : credentials.host,
- user : credentials.user,
- password : credentials.password,
- database : credentials.database,
- charset : credentials.charset
+ host : process.env.DB_HOST,
+ user : process.env.DB_USER,
+ password : process.env.DB_PASSWORD,
+ database : "auracle",
+ charset : "utf8"
},
})
const bookshelf = require('bookshelf')(knex)
diff --git a/index.js b/index.js
index 4ae5ffd..17f265e 100644
--- a/index.js
+++ b/index.js
@@ -6,6 +6,7 @@ const bodyParser = require('body-parser')
const helmet = require('helmet')
const morgan = require('morgan')
const cors = require('cors') // module to format the json response
+const dotenv = require('dotenv').config()
// Creates instances of database connections
const connection = require('./database/bookshelf')
@@ -27,6 +28,15 @@ app.use(helmet())
// Serves
const server = app.listen( port, () => {console.log(`App listening on port ${port}`)})
+// Auth
+app.all('*', (req, res, next) => {
+ if (req.headers.auracle_key !== process.env.API_KEY) {
+ return res.status(401).send('The API is either missing or incorrect.')
+ } else {
+ next()
+ }
+})
+
// Routing
app.use('/api/spells', routes.spells)
app.use('/api/schools', routes.schools)
@@ -34,3 +44,4 @@ app.use('/api/meta_schools', routes.meta_schools)
app.use('/api/variables', routes.variables)
app.use('/api/ingredients', routes.ingredients)
app.use('/api/users', routes.users)
+
diff --git a/package-lock.json b/package-lock.json
index 1a368bc..d128861 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -476,6 +476,11 @@
"resolved": "https://registry.npmjs.org/dont-sniff-mimetype/-/dont-sniff-mimetype-1.1.0.tgz",
"integrity": "sha512-ZjI4zqTaxveH2/tTlzS1wFp+7ncxNZaIEWYg3lzZRHkKf5zPT/MnEG6WL0BhHMJUabkh8GeU5NL5j+rEUCb7Ug=="
},
+ "dotenv": {
+ "version": "8.2.0",
+ "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-8.2.0.tgz",
+ "integrity": "sha512-8sJ78ElpbDJBHNeBzUbUVLsqKdccaa/BXF1uPTw3GrvQTBgrQrtObr2mUrE38vzYd8cEv+m/JBfDLioYcfXoaw=="
+ },
"ecdsa-sig-formatter": {
"version": "1.0.11",
"resolved": "https://registry.npmjs.org/ecdsa-sig-formatter/-/ecdsa-sig-formatter-1.0.11.tgz",
diff --git a/package.json b/package.json
index 7e3086c..f707d85 100644
--- a/package.json
+++ b/package.json
@@ -30,6 +30,7 @@
"bcrypt": "^4.0.1",
"bookshelf": "^1.1.1",
"cors": "^2.8.5",
+ "dotenv": "^8.2.0",
"express": "^4.17.1",
"helmet": "^3.22.0",
"jsonschema": "^1.2.6",
diff --git a/routes/auth.js b/routes/auth.js
deleted file mode 100644
index d15e75c..0000000
--- a/routes/auth.js
+++ /dev/null
@@ -1,7 +0,0 @@
-const jwt = require('jsonwebtoken')
-
-const isAuthenticated = (req, res, next) => {
- if (typeof req.headers.authorization !== undefined) {
- let token = req.headers.authorization.split(" ")[1]
- }
-}
\ No newline at end of file