├── .eslintrc.js ├── .gitignore ├── CODE_OF_CONDUCT.md ├── LICENSE ├── README.md ├── assets ├── css │ └── main.css └── img │ └── logo.png ├── backpack.config.js ├── components ├── CreateArticle.vue ├── EditArticle.vue ├── GetArticles.vue ├── ListArticles.vue ├── NavigationBar.vue ├── SignIn.vue ├── ViewArticle.vue └── mixins │ └── ArticleMixin.js ├── layouts └── default.vue ├── middleware └── authenticated.js ├── nuxt.config.js ├── package.json ├── pages ├── administration │ ├── create.vue │ ├── edit │ │ └── _id.vue │ └── list.vue ├── index.vue ├── sign-in.vue └── view │ └── _id.vue ├── plugins ├── axios.js └── filters.js ├── server ├── api │ ├── create-article.js │ ├── delete-article.js │ ├── edit-article.js │ ├── get-article.js │ ├── get-articles.js │ ├── index.js │ ├── services │ │ └── CryptographyService.js │ └── sign-in.js ├── db │ ├── article │ └── user └── index.js ├── static └── favicon.ico ├── store ├── article │ ├── article.actions.js │ ├── article.getters.js │ ├── article.module.js │ ├── article.mutations.js │ └── article.state.js ├── articles │ ├── articles.actions.js │ ├── articles.getters.js │ ├── articles.module.js │ ├── articles.mutations.js │ └── articles.state.js └── index.js └── yarn.lock /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root: true, 3 | parser: 'babel-eslint', 4 | env: { 5 | browser: true, 6 | node: true 7 | }, 8 | extends: 'standard', 9 | // required to lint *.vue files 10 | plugins: [ 11 | 'html' 12 | ], 13 | // add your custom rules here 14 | rules: {}, 15 | globals: {} 16 | } 17 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # dependencies 2 | node_modules 3 | 4 | # logs 5 | npm-debug.log 6 | 7 | # Nuxt build 8 | .nuxt 9 | 10 | # Nuxt generate 11 | dist 12 | 13 | # Backpack build 14 | build 15 | 16 | # WebStorm 17 | .idea 18 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation. 6 | 7 | ## Our Standards 8 | 9 | Examples of behavior that contributes to creating a positive environment include: 10 | 11 | * Using welcoming and inclusive language 12 | * Being respectful of differing viewpoints and experiences 13 | * Gracefully accepting constructive criticism 14 | * Focusing on what is best for the community 15 | * Showing empathy towards other community members 16 | 17 | Examples of unacceptable behavior by participants include: 18 | 19 | * The use of sexualized language or imagery and unwelcome sexual attention or advances 20 | * Trolling, insulting/derogatory comments, and personal or political attacks 21 | * Public or private harassment 22 | * Publishing others' private information, such as a physical or electronic address, without explicit permission 23 | * Other conduct which could reasonably be considered inappropriate in a professional setting 24 | 25 | ## Our Responsibilities 26 | 27 | Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. 28 | 29 | Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. 30 | 31 | ## Scope 32 | 33 | This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. 34 | 35 | ## Enforcement 36 | 37 | Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at kontakt@julian-claus.de. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. 38 | 39 | Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. 40 | 41 | ## Attribution 42 | 43 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version] 44 | 45 | [homepage]: http://contributor-covenant.org 46 | [version]: http://contributor-covenant.org/version/1/4/ 47 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Julian Claus 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # NOT MAINTAINED Nuxt.js with Express.js example project 2 | 3 | This is an example project investigating Nuxt.js. It's is a simple Markdown blog. 4 | 5 | ## Features 6 | 7 | - Real time save to data base 8 | - instant results 9 | - simple management 10 | 11 | ## Installation 12 | 13 | ```bash 14 | $ npm install 15 | ``` 16 | 17 | ## Usage 18 | 19 | First, start the server. 20 | 21 | ```bash 22 | $ npm run dev 23 | ``` 24 | 25 | You can now navigate to [http://localhost:3000](http://localhost:3000). To login, use Alfarr as first name and 123456 as password. 26 | 27 | ## Author 28 | 29 | [Julian Claus](https://www.julian-claus.de) and contributors. 30 | 31 | ## License 32 | 33 | MIT 34 | -------------------------------------------------------------------------------- /assets/css/main.css: -------------------------------------------------------------------------------- 1 | html, body 2 | { 3 | background-color: #fff; 4 | color: #000; 5 | letter-spacing: 0.5px; 6 | font-family: "Source Sans Pro", Arial, sans-serif; 7 | height: 100vh; 8 | margin: 0; 9 | } 10 | 11 | footer 12 | { 13 | padding: 20px; 14 | text-align: center; 15 | border-top: 1px solid #ddd; 16 | } 17 | 18 | a, a:hover, a:focus, a:visited 19 | { 20 | color: #000; 21 | } 22 | 23 | .logo { 24 | width: 100%; 25 | height: auto; 26 | max-width: 400px; 27 | max-height: 289px; 28 | } 29 | -------------------------------------------------------------------------------- /assets/img/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ndabAP/nuxt-express-example/12ccd2c429b87093bd9eed6f6644b2f3e8da2369/assets/img/logo.png -------------------------------------------------------------------------------- /backpack.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | webpack: (config, options, webpack) => { 3 | config.entry.main = './server/index.js' 4 | return config 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /components/CreateArticle.vue: -------------------------------------------------------------------------------- 1 | 28 | 29 | 43 | 44 | 49 | -------------------------------------------------------------------------------- /components/EditArticle.vue: -------------------------------------------------------------------------------- 1 | 28 | 29 | 36 | 37 | 42 | -------------------------------------------------------------------------------- /components/GetArticles.vue: -------------------------------------------------------------------------------- 1 | 35 | 36 | 77 | -------------------------------------------------------------------------------- /components/ListArticles.vue: -------------------------------------------------------------------------------- 1 | 17 | 18 | 29 | -------------------------------------------------------------------------------- /components/NavigationBar.vue: -------------------------------------------------------------------------------- 1 | 19 | 20 | 31 | -------------------------------------------------------------------------------- /components/SignIn.vue: -------------------------------------------------------------------------------- 1 | 30 | 31 | 56 | -------------------------------------------------------------------------------- /components/ViewArticle.vue: -------------------------------------------------------------------------------- 1 | 13 | 14 | 25 | -------------------------------------------------------------------------------- /components/mixins/ArticleMixin.js: -------------------------------------------------------------------------------- 1 | import {mapMutations} from 'vuex' 2 | import { 3 | markdown 4 | } from 'markdown' 5 | import debounce from 'lodash/debounce' 6 | 7 | export default { 8 | data () { 9 | return { 10 | isLoading: false 11 | } 12 | }, 13 | 14 | computed: { 15 | article: { 16 | get () { 17 | return this.$store.state.Article.article 18 | } 19 | }, 20 | 21 | formattedTitle: { 22 | get () { 23 | return markdown.toHTML(`# ${this.article.title}`) 24 | } 25 | }, 26 | 27 | formattedText: { 28 | get () { 29 | return markdown.toHTML(this.article.text) 30 | } 31 | } 32 | }, 33 | 34 | watch: { 35 | article: { 36 | handler () { 37 | this.isLoading = true 38 | if (this.article.title || this.article.text) this.saveArticle() 39 | }, 40 | 41 | deep: true 42 | } 43 | }, 44 | 45 | methods: { 46 | saveArticle: debounce(async function () { 47 | await this.$store.dispatch('Article/patchArticle') 48 | this.isLoading = false 49 | }, 2000), 50 | 51 | ...mapMutations({ 52 | setTitle: 'Article/SET_TITLE', 53 | setText: 'Article/SET_TEXT' 54 | }) 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /layouts/default.vue: -------------------------------------------------------------------------------- 1 | 7 | 8 | 17 | -------------------------------------------------------------------------------- /middleware/authenticated.js: -------------------------------------------------------------------------------- 1 | const authenticated = ({ store, redirect }) => { 2 | if (!store.state.user.isUserAuthenticated) return redirect('/sign-in') 3 | } 4 | 5 | export default authenticated 6 | -------------------------------------------------------------------------------- /nuxt.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | modules: ['@nuxtjs/bootstrap-vue'], 3 | 4 | plugins: ['~plugins/filters.js'], 5 | 6 | head: { 7 | title: 'Nuxt.js with Express.js example project', 8 | meta: [ 9 | { charset: 'utf-8' }, 10 | { name: 'viewport', content: 'width=device-width, initial-scale=1' }, 11 | { hid: 'description', name: 'description', content: 'Nuxt.js with Express.js example project.' } 12 | ], 13 | link: [ 14 | { rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' } 15 | ] 16 | }, 17 | 18 | css: ['~/assets/css/main.css'], 19 | 20 | build: { 21 | vendor: ['axios', 'lodash/debounce'], 22 | 23 | extend (config, ctx) { 24 | if (ctx.isClient) { 25 | config.module.rules.push({ 26 | enforce: 'pre', 27 | test: /\.(js|vue)$/, 28 | loader: 'eslint-loader', 29 | exclude: /(node_modules)/ 30 | }) 31 | } 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "nuxt-express", 3 | "version": "1.0.0", 4 | "description": "Nuxt.js project", 5 | "author": "Julian Claus ", 6 | "scripts": { 7 | "dev": "backpack dev", 8 | "build": "nuxt build && backpack build", 9 | "start": "cross-env NODE_ENV=production node build/main.js", 10 | "precommit": "npm run lint", 11 | "lint": "eslint --ext .js,.vue --ignore-path .gitignore .", 12 | "vuex-scaffold": "NODE_PATH=. node ./node_modules/vuex-cli-scaffold/src/index.js" 13 | }, 14 | "dependencies": { 15 | "@nuxtjs/bootstrap-vue": "^2.0.4", 16 | "aws-sdk": "^2.630.0", 17 | "axios": "^0.19.2", 18 | "bcrypt": "^1.0.3", 19 | "body-parser": "^1.19.0", 20 | "cross-env": "^5.2.1", 21 | "express": "^4.17.1", 22 | "handlebars": "^4.4.0", 23 | "js-yaml": "^3.13.1", 24 | "lodash": "^4.17.15", 25 | "markdown": "^0.5.0", 26 | "nedb-core": "^3.0.6", 27 | "nuxt": "^1.4.2", 28 | "source-map-support": "^0.5.16" 29 | }, 30 | "devDependencies": { 31 | "babel-eslint": "^7.2.3", 32 | "backpack-core": "^0.8.3", 33 | "eslint": "^4.19.1", 34 | "eslint-config-standard": "^10.2.1", 35 | "eslint-loader": "^1.9.0", 36 | "eslint-plugin-html": "^3.1.1", 37 | "eslint-plugin-import": "^2.20.0", 38 | "eslint-plugin-node": "^5.1.1", 39 | "eslint-plugin-promise": "^3.8.0", 40 | "eslint-plugin-standard": "^3.1.0", 41 | "vuex-cli-scaffold": "^1.0.8" 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /pages/administration/create.vue: -------------------------------------------------------------------------------- 1 | 12 | 13 | 30 | -------------------------------------------------------------------------------- /pages/administration/edit/_id.vue: -------------------------------------------------------------------------------- 1 | 11 | 12 | 42 | -------------------------------------------------------------------------------- /pages/administration/list.vue: -------------------------------------------------------------------------------- 1 | 11 | 12 | 29 | -------------------------------------------------------------------------------- /pages/index.vue: -------------------------------------------------------------------------------- 1 | 7 | 8 | 29 | -------------------------------------------------------------------------------- /pages/sign-in.vue: -------------------------------------------------------------------------------- 1 | 8 | 9 | 24 | -------------------------------------------------------------------------------- /pages/view/_id.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 27 | -------------------------------------------------------------------------------- /plugins/axios.js: -------------------------------------------------------------------------------- 1 | import * as axios from 'axios' 2 | 3 | let options = {} 4 | if (process.server) { 5 | options.baseURL = `http://${process.env.HOST || 'localhost'}:${process.env.PORT || 3000}` 6 | } 7 | 8 | export default axios.create(options) 9 | -------------------------------------------------------------------------------- /plugins/filters.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import { 3 | markdown 4 | } from 'markdown' 5 | 6 | Vue.filter('markdown', text => markdown.toHTML(text)) 7 | Vue.filter('date', date => date.slice(0, 10)) 8 | -------------------------------------------------------------------------------- /server/api/create-article.js: -------------------------------------------------------------------------------- 1 | import { 2 | Router 3 | } from 'express' 4 | import * as Datastore from 'nedb-core' 5 | 6 | const router = Router() 7 | 8 | router.post('/administration/create', function(req, res, next) { 9 | let db = new Datastore({ 10 | filename: __dirname + '/../db/article', 11 | autoload: true 12 | }) 13 | 14 | let title = '' 15 | let text = '' 16 | let createdDate = new Date() 17 | 18 | db 19 | .insert({ 20 | title, 21 | text, 22 | createdDate 23 | }, (error, article) => { 24 | db.persistence.compactDatafile() 25 | if (!error) return res.json(article) 26 | }) 27 | }) 28 | 29 | export default router 30 | -------------------------------------------------------------------------------- /server/api/delete-article.js: -------------------------------------------------------------------------------- 1 | import { 2 | Router 3 | } from 'express' 4 | import * as Datastore from 'nedb-core' 5 | 6 | const router = Router() 7 | 8 | router.delete('/delete-article', function(req, res, next) { 9 | let db = new Datastore({ 10 | filename: __dirname + '/../db/article', 11 | autoload: true 12 | }) 13 | 14 | let id = req.query.id 15 | 16 | let article = db 17 | .remove({ 18 | _id: id 19 | }, error => { 20 | if (!error) res.sendStatus(200) 21 | }) 22 | }) 23 | 24 | export default router 25 | -------------------------------------------------------------------------------- /server/api/edit-article.js: -------------------------------------------------------------------------------- 1 | import { 2 | Router 3 | } from 'express' 4 | import * as Datastore from 'nedb-core' 5 | 6 | const router = Router() 7 | 8 | router.patch('/administration/edit', function(req, res, next) { 9 | let db = new Datastore({ 10 | filename: __dirname + '/../db/article', 11 | autoload: true 12 | }) 13 | 14 | let id = req.body.id 15 | let title = req.body.title 16 | let text = req.body.text 17 | 18 | db 19 | .update({ 20 | _id: id 21 | }, { 22 | $set: { 23 | title, 24 | text 25 | } 26 | }, error => { 27 | db.persistence.compactDatafile() 28 | if (!error) return res.sendStatus(200) 29 | }) 30 | }) 31 | 32 | export default router 33 | -------------------------------------------------------------------------------- /server/api/get-article.js: -------------------------------------------------------------------------------- 1 | import { 2 | Router 3 | } from 'express' 4 | import * as Datastore from 'nedb-core' 5 | 6 | const router = Router() 7 | 8 | router.get('/get-article', function(req, res, next) { 9 | let db = new Datastore({ 10 | filename: __dirname + '/../db/article', 11 | autoload: true 12 | }) 13 | 14 | let id = req.query.id 15 | 16 | let article = db 17 | .findOne({ 18 | _id: id 19 | }, (error, article) => res.json(article)) 20 | }) 21 | 22 | export default router 23 | -------------------------------------------------------------------------------- /server/api/get-articles.js: -------------------------------------------------------------------------------- 1 | import { 2 | Router 3 | } from 'express' 4 | import * as Datastore from 'nedb-core' 5 | 6 | const router = Router() 7 | 8 | router.get('/get-articles', function(req, res, next) { 9 | let db = new Datastore({ 10 | filename: __dirname + '/../db/article', 11 | autoload: true 12 | }) 13 | 14 | db.find({}).sort({createdDate: -1}).exec((err, articles) => res.json(articles)) 15 | }) 16 | 17 | export default router 18 | -------------------------------------------------------------------------------- /server/api/index.js: -------------------------------------------------------------------------------- 1 | import { Router } from 'express' 2 | import signIn from './sign-in' 3 | import createArticle from './create-article' 4 | import editArticle from './edit-article' 5 | import getArticles from './get-articles' 6 | import getArticle from './get-article' 7 | import deleteArticle from './delete-article' 8 | 9 | const router = Router() 10 | 11 | router.use(signIn) 12 | router.use(createArticle) 13 | router.use(editArticle) 14 | router.use(getArticles) 15 | router.use(getArticle) 16 | router.use(deleteArticle) 17 | 18 | export default router 19 | -------------------------------------------------------------------------------- /server/api/services/CryptographyService.js: -------------------------------------------------------------------------------- 1 | import crypto from 'crypto' 2 | 3 | export default { 4 | 5 | /** 6 | * @param decrypted 7 | */ 8 | encrypt: (decrypted) => { 9 | let cipher = crypto.createCipher('aes-256-cbc', 'd6F3Efeq') 10 | let crypted = cipher.update(decrypted.toString(), 'utf8', 'hex') 11 | crypted += cipher.final('hex') 12 | 13 | return crypted 14 | }, 15 | 16 | /** 17 | * @param encrypted 18 | */ 19 | decrypt: (encrypted) => { 20 | let decipher = crypto.createDecipher('aes-256-cbc', 'd6F3Efeq') 21 | let decrypted = decipher.update(encrypted.toString(), 'hex', 'utf8') 22 | decrypted += decipher.final('utf8') 23 | 24 | return decrypted 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /server/api/sign-in.js: -------------------------------------------------------------------------------- 1 | import { 2 | Router 3 | } from 'express' 4 | import * as Datastore from 'nedb-core' 5 | import bcrypt from 'bcrypt' 6 | import CryptographyService from './services/CryptographyService' 7 | 8 | const router = Router() 9 | 10 | router.post('/sign-in', function(req, res, next) { 11 | let db = new Datastore({ 12 | filename: __dirname + '/../db/user', 13 | autoload: true 14 | }) 15 | 16 | let firstName = req.body.firstName 17 | let password = req.body.password 18 | 19 | db 20 | .findOne({ 21 | firstName 22 | }, (error, user) => { 23 | if (user && bcrypt.compareSync(password, user.password)) { 24 | res.cookie('identifier', CryptographyService.encrypt(user.identifier)) 25 | return res.sendStatus(200) 26 | } else return res.sendStatus(403) 27 | }) 28 | }) 29 | 30 | export default router 31 | -------------------------------------------------------------------------------- /server/db/article: -------------------------------------------------------------------------------- 1 | {"title":"Artus et atque et illis Minervae","text":"Laniata regnique. Equorum Thyesteis partes incumbens illo intremuit dixit\nstatuitque patiere.\n\nEt fulvos errat quoque, e sensit [tua](http://virginibus-labor.org/quod.php)\nvidit meminisse concipit, parte venit veluti. Recusat obstantes, in tum, quod\nfatum vocalibus atque nepotem **virgineosque**! Spicis datum nectar, erat, nil\nquod, haec ita. Animosus flammas bitumineae ingenium iniusti moenia devastata\nsubiecto. Senectam materno [unda latentia Oenidae](http://vulnusque.org/), ne\nsumma contigerat et *talia*.\n\n## Et refugerit sceleri virides fessis\n\nHunc nondum membris, veniebat equorum? Et et ingenium et operisque totidemque\npicum posito tua, illo falsi sub. **Penna est cutem**, et vindicat damus ora\nmanibus canes Capitolia, loris inque generi multo capillos terra quae, in?\n\nVagantur vaccae caede vestigia. Cardine Iovi. Vires pars putes et Telethusa\nperque petis in ambiguus surgere. Addit cura et limen iactat, patris nemus\nquae hoc sollerti vocem. Quibus blanditur et sibi diva ora **conloquiumque**\nAegides genitore addere, in.\n\nValle visa aquarum vindicet viscera. Et est ducunt vetustas mergeret utque arcus\nevincere *fugit*; et alter suum, admissa. Male Ionium iactu formas ne opposuit\nCentaurorum docui pictarumque dederunt qua: virides ipse dissuaserat quem: ibi\nviolas tibi!","createdDate":{"$$date":1507810522909},"_id":"Ixj4ax0cOJmmSCsy"} 2 | {"title":"Cunctos una viguere deposcunt sparserat tamen","text":"## Revirescere cutis \n\n*Lorem markdownum Zephyro* placuisse **relictum et quae** ut primus Politen\ntonitrus caputque! Nec plenis Elin; **aevo** umbras, venit minoribus ossa\ntactaeque tu recepta pedes, dona.\n\n var drive_hard_function = pack_ctp(so_pop(42, multiplatform_nas) +\n nocCardSsl);\n memoryItunes(3, bufferHfs(bare_engine(samba_bank, -5, multitaskingWhois)),\n format(domainVaporware));\n ansi_captcha_table.textWindow(compression + desktop_cms_raid);\n\n## Alae ratem curvata\n\nEt aut iramque foret. Hic rumor petentem. Viro altera, exitium eadem sunt\nAchivos fuit consulit, secuit illic inferias placere partique demens;\ntriplicesque. Vides perpetuumque superis vultus studiosius nec inmurmurat flere\net Eoo ut hunc.\n\nNuper verbis est aures in quid iuxta, cycnorum me. Iusta cum veste Latiis\nvulnera est, vitane neque quaterque teretes an. Aspicis accepisse *Romanum mori\nme*, per digitos grandior sagitta, rus genitum dracones, ad curvo Cerealis.","createdDate":{"$$date":1507812404011},"_id":"UpqIvffkflsHwHPU"} 3 | -------------------------------------------------------------------------------- /server/db/user: -------------------------------------------------------------------------------- 1 | {"identifier":1,"firstName":"Alfarr","lastName":"Ferdinand","password":"$2a$06$LDXrJ6m48MJXyzw.4zIHru/kH2gdduUSWwN4G.jWKnnrQNW9kJ89C","_id":"akFTiLP5zlPznecv"} 2 | -------------------------------------------------------------------------------- /server/index.js: -------------------------------------------------------------------------------- 1 | import express from 'express' 2 | import bodyParser from 'body-parser' 3 | import { 4 | Nuxt, 5 | Builder 6 | } from 'nuxt' 7 | import * as Datastore from 'nedb-core' 8 | import bcrypt from 'bcrypt' 9 | 10 | const db = new Datastore({ 11 | filename: 'server/db/user', 12 | autoload: true 13 | }) 14 | 15 | import api from './api' 16 | 17 | const app = express() 18 | const host = process.env.HOST || '127.0.0.1' 19 | const port = process.env.PORT || 3000 20 | 21 | app.set('port', port) 22 | 23 | app.use(bodyParser.json()) 24 | app.use(bodyParser.urlencoded({ 25 | extended: true 26 | })) 27 | 28 | app.use('/api', api) 29 | 30 | let config = require('../nuxt.config.js') 31 | config.dev = !(process.env.NODE_ENV === 'production') 32 | 33 | const nuxt = new Nuxt(config) 34 | 35 | if (config.dev) { 36 | const builder = new Builder(nuxt) 37 | builder.build() 38 | } 39 | 40 | app.use(nuxt.render) 41 | 42 | app.listen(port, host) 43 | console.log('Server listening on ' + host + ':' + port) // eslint-disable-line no-console 44 | 45 | db 46 | .find({ 47 | identifier: 1 48 | }, (error, user) => { 49 | if (!user) { 50 | const administrator = { 51 | identifier: 1, 52 | firstName: 'Alfarr', 53 | lastName: 'Ferdinand', 54 | password: bcrypt.hashSync('123456', bcrypt.genSaltSync(6)) 55 | } 56 | 57 | db 58 | .insert(administrator, (error) => { 59 | if (error) throw new Error(error) 60 | }) 61 | } 62 | }) 63 | -------------------------------------------------------------------------------- /static/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ndabAP/nuxt-express-example/12ccd2c429b87093bd9eed6f6644b2f3e8da2369/static/favicon.ico -------------------------------------------------------------------------------- /store/article/article.actions.js: -------------------------------------------------------------------------------- 1 | import axios from 'axios' 2 | 3 | const actions = { 4 | postArticle () { 5 | return new Promise(async (resolve, reject) => { 6 | try { 7 | let { 8 | data 9 | } = await axios 10 | .post('http://localhost:3000/api/administration/create') 11 | 12 | resolve(data) 13 | } catch (error) { 14 | reject(error) 15 | } 16 | }) 17 | }, 18 | 19 | getArticle ({state = undefined}, id) { 20 | return new Promise(async (resolve, reject) => { 21 | try { 22 | let {data} = await axios.get('http://localhost:3000/api/get-article', { 23 | params: { 24 | id 25 | } 26 | }) 27 | resolve(data) 28 | } catch (error) { 29 | reject(error) 30 | } 31 | }) 32 | }, 33 | 34 | patchArticle ({state}) { 35 | return new Promise(async (resolve, reject) => { 36 | try { 37 | await axios 38 | .patch('http://localhost:3000/api/administration/edit', { 39 | id: state.article._id, 40 | title: state.article.title, 41 | text: state.article.text 42 | }) 43 | 44 | resolve() 45 | } catch (error) { 46 | reject(error) 47 | } 48 | }) 49 | }, 50 | 51 | deleteArticle () {} 52 | } 53 | 54 | export default actions 55 | -------------------------------------------------------------------------------- /store/article/article.getters.js: -------------------------------------------------------------------------------- 1 | const getters = { 2 | article: state => state.article 3 | } 4 | 5 | export default getters 6 | -------------------------------------------------------------------------------- /store/article/article.module.js: -------------------------------------------------------------------------------- 1 | import state from './article.state' 2 | import mutations from './article.mutations' 3 | import actions from './article.actions' 4 | import getters from './article.getters' 5 | 6 | export default { 7 | namespaced: true, 8 | state, 9 | getters, 10 | mutations, 11 | actions 12 | } 13 | -------------------------------------------------------------------------------- /store/article/article.mutations.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | 3 | const mutations = { 4 | SET_ARTICLE (state, article) { 5 | state.article = article 6 | }, 7 | 8 | SET_ID (state, id) { 9 | Vue.set(state.article, '_id', id) 10 | }, 11 | 12 | SET_TITLE (state, title) { 13 | Vue.set(state.article, 'title', title) 14 | }, 15 | 16 | SET_TEXT (state, text) { 17 | Vue.set(state.article, 'text', text) 18 | }, 19 | 20 | RESET_ARTICLE (state) { 21 | state.article = { 22 | _id: '', 23 | title: '', 24 | text: '' 25 | } 26 | } 27 | } 28 | 29 | export default mutations 30 | -------------------------------------------------------------------------------- /store/article/article.state.js: -------------------------------------------------------------------------------- 1 | const state = { 2 | article: { 3 | _id: '', 4 | createdDate: '', 5 | title: '', 6 | text: '' 7 | } 8 | } 9 | 10 | export default state 11 | -------------------------------------------------------------------------------- /store/articles/articles.actions.js: -------------------------------------------------------------------------------- 1 | const actions = { 2 | postArticles () {}, 3 | 4 | getArticles () {}, 5 | 6 | patchArticles () {}, 7 | 8 | deleteArticles () {} 9 | } 10 | 11 | export default actions 12 | -------------------------------------------------------------------------------- /store/articles/articles.getters.js: -------------------------------------------------------------------------------- 1 | const getters = { 2 | articles: state => state.articles 3 | } 4 | 5 | export default getters 6 | -------------------------------------------------------------------------------- /store/articles/articles.module.js: -------------------------------------------------------------------------------- 1 | import state from './articles.state' 2 | import mutations from './articles.mutations' 3 | import actions from './articles.actions' 4 | import getters from './articles.getters' 5 | 6 | export default { 7 | namespaced: true, 8 | state, 9 | getters, 10 | mutations, 11 | actions 12 | } 13 | -------------------------------------------------------------------------------- /store/articles/articles.mutations.js: -------------------------------------------------------------------------------- 1 | const mutations = { 2 | SET_ARTICLES (state, articles) { 3 | state.articles = articles 4 | } 5 | } 6 | 7 | export default mutations 8 | -------------------------------------------------------------------------------- /store/articles/articles.state.js: -------------------------------------------------------------------------------- 1 | const state = { 2 | articles: [] 3 | } 4 | 5 | export default state 6 | -------------------------------------------------------------------------------- /store/index.js: -------------------------------------------------------------------------------- 1 | import Vuex from 'vuex' 2 | import article from './article/article.module' 3 | import articles from './articles/articles.module' 4 | 5 | const store = () => { 6 | return new Vuex.Store({ 7 | modules: { 8 | Article: article, 9 | Articles: articles 10 | }, 11 | 12 | state: { 13 | user: { 14 | isUserAuthenticated: false 15 | } 16 | }, 17 | 18 | mutations: { 19 | setIsUserAuthenticated (state, isUserAuthenticated) { 20 | state.user.isUserAuthenticated = isUserAuthenticated 21 | } 22 | } 23 | }) 24 | } 25 | 26 | export default store 27 | --------------------------------------------------------------------------------