routing
This commit is contained in:
parent
f95fe42c7f
commit
e21bc0782c
2
index.js
2
index.js
@ -10,6 +10,7 @@ const crypto = require ('@sapphirecode/crypto-helper');
|
|||||||
const password_helper = require ('@sapphirecode/password-helper');
|
const password_helper = require ('@sapphirecode/password-helper');
|
||||||
const api = require ('./lib/api');
|
const api = require ('./lib/api');
|
||||||
const http_proxy = require ('express-http-proxy');
|
const http_proxy = require ('express-http-proxy');
|
||||||
|
const history_fallback = require ('connect-history-api-fallback');
|
||||||
|
|
||||||
const salt = crypto.create_salt ();
|
const salt = crypto.create_salt ();
|
||||||
const hash = crypto.hash_sha512 ('asd', salt);
|
const hash = crypto.hash_sha512 ('asd', salt);
|
||||||
@ -36,6 +37,7 @@ const user = {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
app.use (api);
|
app.use (api);
|
||||||
|
app.use (history_fallback ());
|
||||||
app.use (http_proxy ('localhost:8080'));
|
app.use (http_proxy ('localhost:8080'));
|
||||||
|
|
||||||
app.listen (3000, () => {
|
app.listen (3000, () => {
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
"@sapphirecode/password-helper": "^1.0.47",
|
"@sapphirecode/password-helper": "^1.0.47",
|
||||||
"@sapphirecode/ui-modules": "^0.1.1",
|
"@sapphirecode/ui-modules": "^0.1.1",
|
||||||
"body-parser": "^1.19.0",
|
"body-parser": "^1.19.0",
|
||||||
|
"connect-history-api-fallback": "^1.6.0",
|
||||||
"cookie-parser": "^1.4.5",
|
"cookie-parser": "^1.4.5",
|
||||||
"core-js": "^3.6.5",
|
"core-js": "^3.6.5",
|
||||||
"express": "^4.17.1",
|
"express": "^4.17.1",
|
||||||
|
@ -3,21 +3,28 @@
|
|||||||
const faker = require ('faker');
|
const faker = require ('faker');
|
||||||
|
|
||||||
function create_log () {
|
function create_log () {
|
||||||
|
const data = {
|
||||||
|
num1: faker.random.number (),
|
||||||
|
num2: faker.random.number (),
|
||||||
|
num3: faker.random.number ()
|
||||||
|
};
|
||||||
return {
|
return {
|
||||||
app: faker.random.word (),
|
app: faker.random.word (),
|
||||||
message: faker.random.words (),
|
message: faker.random.words (),
|
||||||
data: faker.random.objectElement (),
|
data: JSON.stringify (data),
|
||||||
timestamp: faker.date.recent ()
|
timestamp: faker.date.recent ()
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
async function seed (knex) {
|
async function seed (knex) {
|
||||||
console.log ('creating seeds');
|
console.log ('creating seeds');
|
||||||
for (let i = 0; i < 100; i++) {
|
const log = (Array (100))
|
||||||
// eslint-disable-next-line no-await-in-loop
|
.fill (() => null)
|
||||||
await knex ('log')
|
.map (() => create_log ());
|
||||||
.insert (create_log ());
|
await knex ('log')
|
||||||
}
|
.del ();
|
||||||
|
|
||||||
|
await knex.batchInsert ('log', log, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = { seed };
|
module.exports = { seed };
|
||||||
|
@ -1,13 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<div id="app">
|
<div id="app">
|
||||||
<div id="nav">
|
|
||||||
<router-link to="/">
|
|
||||||
Home
|
|
||||||
</router-link> |
|
|
||||||
<router-link to="/about">
|
|
||||||
About
|
|
||||||
</router-link>
|
|
||||||
</div>
|
|
||||||
<router-view />
|
<router-view />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
@ -9,28 +9,31 @@
|
|||||||
|
|
||||||
import Vue from 'vue';
|
import Vue from 'vue';
|
||||||
import VueRouter from 'vue-router';
|
import VueRouter from 'vue-router';
|
||||||
import Home from '../views/Home.vue';
|
import AppView from '../views/AppView.vue';
|
||||||
import About from '../views/About.vue';
|
import NotFound from '../views/NotFound.vue';
|
||||||
|
|
||||||
Vue.use (VueRouter);
|
Vue.use (VueRouter);
|
||||||
|
|
||||||
const routes = [
|
const routes = [
|
||||||
{
|
{
|
||||||
path: '/',
|
path: '/app/:id',
|
||||||
name: 'Home',
|
name: 'AppView',
|
||||||
component: Home
|
component: AppView
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/about',
|
path: '/404',
|
||||||
name: 'About',
|
name: '404',
|
||||||
component: About
|
component: NotFound
|
||||||
}
|
},
|
||||||
|
{ path: '*', redirect: '404' }
|
||||||
];
|
];
|
||||||
|
|
||||||
const router = new VueRouter ({
|
const router = new VueRouter ({
|
||||||
mode: 'history',
|
mode: 'history',
|
||||||
base: process.env.BASE_URL,
|
// eslint-disable-next-line no-process-env
|
||||||
routes
|
base: process.env.BASE_URL,
|
||||||
|
routes,
|
||||||
|
fallback: true
|
||||||
});
|
});
|
||||||
|
|
||||||
export default router;
|
export default router;
|
||||||
|
@ -19,7 +19,7 @@ export default new Vuex.Store ({
|
|||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
async get_log ({ commit }) {
|
async get_log ({ commit }) {
|
||||||
const log = await fetch ('log')
|
const log = await fetch ('/log')
|
||||||
.then ((res) => res.json ());
|
.then ((res) => res.json ());
|
||||||
commit ('set_log', log);
|
commit ('set_log', log);
|
||||||
}
|
}
|
||||||
|
@ -1,9 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div class="about">
|
|
||||||
<h1>This is an about page</h1>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
export default {};
|
|
||||||
</script>
|
|
57
src/views/AppView.vue
Normal file
57
src/views/AppView.vue
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
<template>
|
||||||
|
<div class="grid">
|
||||||
|
<p>test</p>
|
||||||
|
<p>test</p>
|
||||||
|
<p>test</p>
|
||||||
|
<p>test</p>
|
||||||
|
<p>test</p>
|
||||||
|
<p>test</p>
|
||||||
|
<p>test</p>
|
||||||
|
<p>test</p>
|
||||||
|
<p>test</p>
|
||||||
|
<p>test</p>
|
||||||
|
<p>test</p>
|
||||||
|
<p>test</p>
|
||||||
|
<p>test</p>
|
||||||
|
<p>test</p>
|
||||||
|
<p>test</p>
|
||||||
|
<p>test</p>
|
||||||
|
<p>test</p>
|
||||||
|
<p>test</p>
|
||||||
|
<p>test</p>
|
||||||
|
<p>test</p>
|
||||||
|
<p>test</p>
|
||||||
|
<p>test</p>
|
||||||
|
<p>test</p>
|
||||||
|
<p>test</p>
|
||||||
|
<p>test</p>
|
||||||
|
<p>test</p>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import Vuex from 'vuex';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
computed: { ...Vuex.mapState ({ log: (state) => state.log }) },
|
||||||
|
mounted () {
|
||||||
|
this.get_log ();
|
||||||
|
},
|
||||||
|
methods: { ...Vuex.mapActions ({ get_log: 'get_log' }) }
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.grid {
|
||||||
|
display: grid;
|
||||||
|
grid-auto-columns: 2in;
|
||||||
|
grid-auto-rows: 1in;
|
||||||
|
grid-auto-flow: dense;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
p {
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
</style>
|
@ -1,19 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div class="home">
|
|
||||||
<TableView :items="log" />
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
import Vuex from 'vuex';
|
|
||||||
import TableView from '../components/TableView.vue';
|
|
||||||
|
|
||||||
export default {
|
|
||||||
components: { TableView },
|
|
||||||
computed: { ...Vuex.mapState ({ log: (state) => state.log }) },
|
|
||||||
mounted () {
|
|
||||||
this.get_log ();
|
|
||||||
},
|
|
||||||
methods: { ...Vuex.mapActions ({ get_log: 'get_log' }) }
|
|
||||||
};
|
|
||||||
</script>
|
|
11
src/views/NotFound.vue
Normal file
11
src/views/NotFound.vue
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
<template>
|
||||||
|
<div>not found</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
|
||||||
|
</style>
|
Loading…
x
Reference in New Issue
Block a user