Skip to content

Commit 59c3afe

Browse files
committed
(feature) Added code boilerplate; (todo) test functionality
1 parent 7d6bab0 commit 59c3afe

File tree

18 files changed

+10823
-0
lines changed

18 files changed

+10823
-0
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"standard.enable": true,
3+
"standard.autoFixOnSave": true
4+
}

aws-node-vue-nuxt-ssr/api/index.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
const express = require('express')
2+
const app = express()
3+
const bodyParser = require('body-parser')
4+
app.use(bodyParser.json())
5+
app.use(bodyParser.urlencoded({ extended: true }))
6+
const helmet = require('helmet')
7+
app.use(helmet())
8+
9+
const routes = require('./routes')
10+
app.use('/api', routes)
11+
12+
module.exports = app
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
const express = require('express')
2+
const cartController = express.Router()
3+
4+
cartController
5+
.post('/', async (req, res, next) => {
6+
// const item = await MagentoAPI.create(req.body)
7+
res.status(200).send('Added an item to the Cart.')
8+
})
9+
10+
cartController
11+
.put('/:id', async (req, res, next) => {
12+
// const item = await MagentoAPI.findByIdAndUpdate(req.params.id, { $set: req.body }, { $upsert: true, new: true })
13+
res.status(200).send('Updated an item in the Cart.')
14+
})
15+
16+
cartController
17+
.get('/', async (req, res, next) => {
18+
// const items = await MagentoAPI.find()
19+
res.status(200).send('Get all items in the Cart')
20+
})
21+
22+
cartController
23+
.get('/:id', async (req, res, next) => {
24+
// const item = await MagentoAPI.findById(req.params.id)
25+
res.status(200).send('Get one item from the Cart')
26+
})
27+
28+
cartController
29+
.delete('/:id', async (req, res, next) => {
30+
// const item = await MagentoAPI.deleteOne({ _id: req.params.id })
31+
res.status(200).send('Delete an item from the Cart')
32+
})
33+
34+
module.exports = cartController
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
const express = require('express')
2+
const router = express.Router()
3+
// Add all routes here
4+
router.get('/', (req, res, next) => res.status(200).send('Api works!'))
5+
const cart = require('./cart/cart.controller')
6+
router.use('/cart', cart)
7+
module.exports = router
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
module.exports = [
2+
'application/javascript',
3+
'application/json',
4+
'application/octet-stream',
5+
'application/xml',
6+
'font/eot',
7+
'font/opentype',
8+
'font/otf',
9+
'image/jpeg',
10+
'image/png',
11+
'image/svg+xml',
12+
'text/comma-separated-values',
13+
'text/css',
14+
'text/html',
15+
'text/javascript',
16+
'text/plain',
17+
'text/text',
18+
'text/xml'
19+
]
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<template>
2+
<nav class="nav">
3+
<ul>
4+
<li>
5+
<nuxt-link to="/">Home</nuxt-link>
6+
</li>
7+
<li>
8+
<nuxt-link to="/dogs">Dogs</nuxt-link>
9+
</li>
10+
<li>
11+
<nuxt-link to="/dogs/shepherd">Only Shepherds</nuxt-link>
12+
</li>
13+
</ul>
14+
</nav>
15+
</template>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<template>
2+
<div>
3+
<navbar/>
4+
<nuxt/>
5+
</div>
6+
</template>
7+
<script>
8+
import navbar from "~/components/navbar";
9+
10+
export default {
11+
components: { navbar }
12+
};
13+
</script>
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<template>
2+
<div>
3+
<h2>Dog breed: {{ breed }}</h2>
4+
<ul>
5+
<li v-for="dog in dogs" v-bind:key="dog.id">
6+
<img :src="dog.url" alt="">
7+
</li>
8+
</ul>
9+
</div>
10+
</template>
11+
12+
<script>
13+
import axios from "axios";
14+
export default {
15+
async asyncData({ store, route }) {
16+
const { data } = await axios.get(
17+
"https://api.thedogapi.com/v1/images/search?size=thumb&has_breeds=true&limit=50"
18+
);
19+
20+
const reg = new RegExp(route.params.breed, "g");
21+
const filteredDogs = data.filter(dog =>
22+
dog.breeds[0]
23+
.name
24+
.toLowerCase()
25+
.match(reg)
26+
);
27+
28+
return { dogs: filteredDogs, breed: route.params.breed };
29+
},
30+
head() {
31+
return {
32+
title: `${this.breed} Dog`,
33+
meta: [
34+
{
35+
hid: "description",
36+
name: "description",
37+
content: `You are ${this.breed} hello 👋`
38+
}
39+
]
40+
};
41+
}
42+
};
43+
</script>
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<template>
2+
<div>
3+
<h1>Here you have all dogs.</h1>
4+
<ul>
5+
<li v-for="dog in dogs" v-bind:key="dog.id">
6+
<img :src="dog.url" alt="">
7+
</li>
8+
</ul>
9+
</div>
10+
</template>
11+
12+
<script>
13+
import axios from "axios";
14+
export default {
15+
async asyncData({ params }) {
16+
const { data } = await axios.get(
17+
"https://api.thedogapi.com/v1/images/search?size=thumb&limit=10"
18+
);
19+
return { dogs: data };
20+
},
21+
head() {
22+
return {
23+
title: "Show all dogs!",
24+
meta: [
25+
{
26+
hid: "description",
27+
name: "description",
28+
content: `Hello Dogs 👋`
29+
}
30+
]
31+
};
32+
}
33+
};
34+
</script>
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<template>
2+
<div>
3+
<h1>This is the Front Page.</h1>
4+
<h3>Random dog of the day:</h3>
5+
<img :src="dog.url" alt="">
6+
</div>
7+
</template>
8+
9+
<script>
10+
import axios from "axios";
11+
export default {
12+
async asyncData({ params }) {
13+
const { data } = await axios.get(
14+
"https://api.thedogapi.com/v1/images/search?limit=1"
15+
);
16+
return { dog: data[0] };
17+
}
18+
};
19+
</script>

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy