Skip to content

Commit

Permalink
Merge pull request #1 from ceelogre/topic/users
Browse files Browse the repository at this point in the history
Users UC implementation
  • Loading branch information
ceelogre authored May 26, 2019
2 parents c38e726 + 8290222 commit a1a7dc0
Show file tree
Hide file tree
Showing 28 changed files with 967 additions and 146 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ node_modules
.nyc_output
.vscode
coverage/
.later
5 changes: 4 additions & 1 deletion app.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const logger = require('morgan')
const mongoose = require('mongoose')

const usersRouter = require('./routes/users')
const eventsRouter = require('./routes/events')

const app = express()

Expand All @@ -15,6 +16,7 @@ app.use(cookieParser())
app.use(express.static(path.join(__dirname, 'public')))

app.use('/api/v1/users', usersRouter)
app.use('/api/v1/events', eventsRouter)

// Set the env
if (process.argv[2]) process.env.NODE_ENV = process.argv[2]
Expand All @@ -24,7 +26,8 @@ if (process.env.NODE_ENV === 'test' || process.env.NODE_ENV === 'tests') {
const spinTestDb = require('./utils/testDb')
spinTestDb().then(
db => {
mongoose.connect(db.location, { useNewUrlParser: true }, function (error) {
const options = { useNewUrlParser: true, useCreateIndex: true }
mongoose.connect(db.location, options, function (error) {
if (error) console.log('Error starting db ', error)
})
})
Expand Down
17 changes: 11 additions & 6 deletions client/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"test:unit": "vue-cli-service test:unit"
},
"dependencies": {
"axios": "^0.18.0",
"bulma": "^0.7.4",
"core-js": "^2.6.5",
"vue": "^2.6.10",
Expand Down
2 changes: 1 addition & 1 deletion client/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=2.0">
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.8.2/css/all.css" integrity="sha384-oS3vJWv+0UjzBfQzYUhtDYW+Pj2yciDJxpsK1OYPAYjqT085Qq/1cq5FLXAZQ7Ay" crossorigin="anonymous">
<title>Dista - Fencing service app</title>
</head>
<body>
<noscript>
<strong>We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
</noscript>
<div id="app"></div>
<script defer src="https://cdnjs.com/libraries/bulma"></script>
</body>
</html>
13 changes: 1 addition & 12 deletions client/src/App.vue
Original file line number Diff line number Diff line change
@@ -1,16 +1,5 @@
<template>
<div id="app">
<section id="nav">
<router-link class="button" to="/">Home</router-link> |
<router-link class="button" to="/about">About</router-link>
<div class="columns">
<div class="column">1</div>
<div class="column">2</div>
<div class="column">3</div>
<div class="column">4</div>
<div class="column">5</div>
</div>
</section>
<router-view/>
</div>
</template>
Expand All @@ -23,7 +12,7 @@
-webkit-font-smoothing: antialiased
-moz-osx-font-smoothing: grayscale
text-align: center
color: white
color: hsl(4, 3, 2)
#nav
padding: 30px
Expand Down
Binary file added client/src/assets/chat.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
58 changes: 0 additions & 58 deletions client/src/components/HelloWorld.vue

This file was deleted.

90 changes: 90 additions & 0 deletions client/src/components/Nav.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
<template>
<div>
<nav class="navbar has-shadow" >
<div class="navbar-brand">
<a class="navbar-item" href="#">
<img src="../assets/chat.png" alt="Octopact">
</a>
<div class="navbar-burger burger">
<span></span>
</div>
</div>

<div class="navbar-menu">
<div class="navbar-start">
<div class="navbar-item">
<h3>Dista - Events</h3>
</div>
</div>
<div class="navbar-end">
<div class="navbar-item has-dropdown is-hoverable">
<div class="navbar-link">
{{ handle }}
</div>
<div class="navbar-dropdown">
<a class="navbar-item">
<span class="icon is-small">
<i class="fa fa-user-circle-o"></i>
</span> Profile
</a>
<a @click="endUserSession()" class="navbar-item">
<span class="icon is-small">
<i class="fa fa-sign-out"></i>
</span> Sign Out
</a>
</div>
</div>
</div>
</div>
</nav>
<section class="section">
<div class="columns">
<div class="column is-4-tablet is-3-desktop is-2-widescreen">
<aside class="menu">
<p class="menu-label">Menu</p>
<ul class="menu-list">
<li>
<router-link to="/signup">
<span class="icon">
<i class="fa fa-tachometer"></i>
</span> Register
</router-link>
</li>
<li>
<router-link to="/signin">
<span class="icon">
<i class="fa fa-book"></i>
</span> Login
</router-link>
</li>
</ul>
</aside>
</div>
<main class="column">
<router-view/>
</main>
</div>
</section>
</div>
</template>

<script>
export default {
data() {
return {
handle: window.localStorage.getItem('handle')
}
},
methods: {
endUserSession () {
window.localStorage.removeItem('handle')
window.localStorage.removeItem('uToken')
this.$router.push('/')
}
}
}
</script>

<style>
</style>
33 changes: 29 additions & 4 deletions client/src/router.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import Vue from 'vue'
import Router from 'vue-router'
import Home from './views/Home.vue'
import About from './views/About.vue'
import Signup from './views/Signup.vue'
import Event from './pages/Event.vue'
import Signin from './views/Signin.vue'
import Dashboard from './views/Dashboard.vue'
Vue.use(Router)

export default new Router({
Expand All @@ -14,12 +17,34 @@ export default new Router({
component: Home
},
{
path: '/about',
name: 'about',
path: '/signup',
name: 'signup',
// route level code-splitting
// this generates a separate chunk (about.[hash].js) for this route
// which is lazy-loaded when the route is visited.
component: About
component: Signup
},
{
path: '/signin',
name: 'signin',
component: Signin
},
{
path: '/events',
name: 'events',
component: Event
},
{
path: '/create',
name: 'Add event',
component: Dashboard,
beforeEnter: function (to, from, next) {
if (window.localStorage.getItem('uToken')) {
next()
} else {
next('/signin')
}
}
}
]
})
19 changes: 19 additions & 0 deletions client/src/routes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import axios from 'axios'
const server = '/api/v1/'
const apiClient = axios.create({
baseURL: server,
withCredentials: false,
headers: {
Accept: 'application/json',
'Content-Type': 'application/json'
}
})

export default {
createUser (user) {
return apiClient.post('/users', user)
},
signin (user) {
return apiClient.post('/users/auth', user)
}
}
5 changes: 0 additions & 5 deletions client/src/views/About.vue

This file was deleted.

Loading

0 comments on commit a1a7dc0

Please sign in to comment.