Skip to content

Commit

Permalink
feat(nuxt): add nuxtjs plugin for fast and easy nuxtjs applications (#91
Browse files Browse the repository at this point in the history
)
  • Loading branch information
bahdcoder authored Mar 10, 2021
1 parent 698a584 commit bc8f55f
Show file tree
Hide file tree
Showing 32 changed files with 2,785 additions and 412 deletions.
9 changes: 9 additions & 0 deletions examples/nuxt/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
node_modules/
.env
connect-session-knex.sqlite
blog.sqlite
storage/
mikrotensei
.next
tensei
.nuxt
227 changes: 227 additions & 0 deletions examples/nuxt/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,227 @@
# Change Log

All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [0.7.23](https://github.com/tenseijs/tensei/compare/v0.7.22...v0.7.23) (2021-03-08)

**Note:** Version bump only for package @examples/blog





## [0.7.22](https://github.com/tenseijs/tensei/compare/v0.7.21...v0.7.22) (2021-03-07)

**Note:** Version bump only for package @examples/blog





## [0.7.21](https://github.com/tenseijs/tensei/compare/v0.7.20...v0.7.21) (2021-03-07)


### Features

* **auth:** add cookie sessions authentication ([#86](https://github.com/tenseijs/tensei/issues/86)) ([00f4a11](https://github.com/tenseijs/tensei/commit/00f4a118e17e5da1ccc72c0bc12912d504bbe42d))





## [0.7.20](https://github.com/tenseijs/tensei/compare/v0.7.19...v0.7.20) (2021-03-04)

**Note:** Version bump only for package @examples/blog





## [0.7.19](https://github.com/tenseijs/tensei/compare/v0.7.18...v0.7.19) (2021-03-04)

**Note:** Version bump only for package @examples/blog





## [0.7.18](https://github.com/tenseijs/tensei/compare/v0.7.17...v0.7.18) (2021-03-04)


### Features

* **rest:** add simple rest documentation ([#81](https://github.com/tenseijs/tensei/issues/81)) ([8f30635](https://github.com/tenseijs/tensei/commit/8f306355eb091637276fed421ceba38be1d83372))





## [0.7.17](https://github.com/tenseijs/tensei/compare/v0.7.16...v0.7.17) (2021-03-02)

**Note:** Version bump only for package @examples/blog





## [0.7.16](https://github.com/tenseijs/tensei/compare/v0.7.15...v0.7.16) (2021-03-01)

**Note:** Version bump only for package @examples/blog





## [0.7.15](https://github.com/tenseijs/tensei/compare/v0.7.14...v0.7.15) (2021-03-01)

**Note:** Version bump only for package @examples/blog





## [0.7.14](https://github.com/tenseijs/tensei/compare/v0.7.13...v0.7.14) (2021-03-01)

**Note:** Version bump only for package @examples/blog





## [0.7.13](https://github.com/tenseijs/tensei/compare/v0.7.12...v0.7.13) (2021-03-01)


### Bug Fixes

* **auth:** remove user prefix from all auth graphql queries ([396f280](https://github.com/tenseijs/tensei/commit/396f28025ce91bc2d26d4f0ea330c41b522702e5))


### Features

* **auth:** add custom payload from social authenication to auth plugin ([44a8f3e](https://github.com/tenseijs/tensei/commit/44a8f3ea51774754c2648f74903ff826fad3c682))





## [0.7.12](https://github.com/tenseijs/tensei/compare/v0.7.11...v0.7.12) (2021-02-24)


### Features

* **mail:** add mailgun plugin and default mailing template components for saas apps ([#75](https://github.com/tenseijs/tensei/issues/75)) ([dcaae4b](https://github.com/tenseijs/tensei/commit/dcaae4b0053f2c0b7da1afc86f1f2617780faac4))





## [0.7.11](https://github.com/tenseijs/tensei/compare/v0.7.10...v0.7.11) (2021-02-16)

**Note:** Version bump only for package @examples/blog





## [0.7.10](https://github.com/tenseijs/tensei/compare/v0.7.9...v0.7.10) (2021-02-16)

**Note:** Version bump only for package @examples/blog





## [0.7.9](https://github.com/tenseijs/tensei/compare/v0.7.8...v0.7.9) (2021-02-13)

**Note:** Version bump only for package @examples/blog





## [0.7.8](https://github.com/tenseijs/tensei/compare/v0.7.7...v0.7.8) (2021-02-13)

**Note:** Version bump only for package @examples/blog





## [0.7.7](https://github.com/tenseijs/tensei/compare/v0.7.6...v0.7.7) (2021-02-13)

**Note:** Version bump only for package @examples/blog





## [0.7.6](https://github.com/tenseijs/tensei/compare/v0.7.5...v0.7.6) (2021-02-13)

**Note:** Version bump only for package @examples/blog





## [0.7.5](https://github.com/tenseijs/tensei/compare/v0.7.4...v0.7.5) (2021-02-13)

**Note:** Version bump only for package @examples/blog





## [0.7.4](https://github.com/tenseijs/tensei/compare/v0.7.3...v0.7.4) (2021-02-12)

**Note:** Version bump only for package @examples/blog






## [0.7.3](https://github.com/tenseijs/tensei/compare/v0.7.2...v0.7.3) (2021-02-11)


### Features

* **cms:** add users & roles to the cms sidebar menu ([eda1e3c](https://github.com/tenseijs/tensei/commit/eda1e3ca3716bcb69ecbfec6120ba55a2b4b06dd))





## [0.7.2](https://github.com/tenseijs/tensei/compare/v0.7.1...v0.7.2) (2021-02-11)

**Note:** Version bump only for package @examples/blog





## [0.7.1](https://github.com/tenseijs/tensei/compare/v0.7.0...v0.7.1) (2021-02-11)


### Bug Fixes

* **core:** remove dev deps from dependencies lists ([b5f449b](https://github.com/tenseijs/tensei/commit/b5f449bcabed4639d9d4197a15e52b51895e9c9b))





# [0.7.0](https://github.com/tenseijs/tensei/compare/v0.6.3...v0.7.0) (2021-02-10)

**Note:** Version bump only for package @examples/blog





## [0.6.3](https://github.com/tenseijs/tensei/compare/v0.6.2...v0.6.3) (2021-02-09)


### Bug Fixes

* fix several launch bugs (cms, core, media) ([aacc2f8](https://github.com/tenseijs/tensei/commit/aacc2f8175a74d4983c96358c85d1db67128f889))
50 changes: 50 additions & 0 deletions examples/nuxt/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
const { auth } = require('@tensei/auth')
const { rest } = require('@tensei/rest')
const { nuxt } = require('@tensei/nuxt')

const {
tensei,
resource,
slug,
text,
textarea,
dateTime,
belongsTo,
hasMany
} = require('@tensei/core')

tensei()
.root(__dirname)
.mailer('transactions')
.resources([
resource('Post')
.fields([
text('Title'),
slug('Slug').from('Title'),
textarea('Description'),
textarea('Content'),
dateTime('Published At'),
belongsTo('Category')
])
.displayField('Title'),
resource('Category')
.fields([
text('Name').notNullable().rules('required'),
textarea('Description'),
hasMany('Post')
])
.displayField('Name')
])
.plugins([
auth()
.cookieSessions()
.plugin(),
rest().plugin(),
nuxt().plugin(),
])
.databaseConfig({
type: 'sqlite',
dbName: 'tensei'
})
.start()
.catch(console.error)
4 changes: 4 additions & 0 deletions examples/nuxt/nodemon.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"watch": ["node_modules/", "index.js"],
"ext": "js, css"
}
8 changes: 8 additions & 0 deletions examples/nuxt/nuxt.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export default {
head: {
link: [{
rel: 'stylesheet',
href: 'https://unpkg.com/tailwindcss@^2/dist/tailwind.min.css'
}]
}
}
17 changes: 17 additions & 0 deletions examples/nuxt/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "@examples/nuxt",
"version": "0.7.23",
"main": "index.js",
"license": "MIT",
"dependencies": {
"@tensei/core": "^0.7.23",
"@tensei/nuxt": "^0.7.23"
},
"scripts": {
"example:dev": "nodemon --watch node_modules/ index.js"
},
"devDependencies": {
"nodemon": "^2.0.7"
},
"private": true
}
57 changes: 57 additions & 0 deletions examples/nuxt/pages/index.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<template>
<div class="w-full">
<nav class="w-full h-16 bg-green-900">
<div class="max-w-6xl px-12 lg:px-0 h-full flex justify-between items-center mx-auto">
<span class="text-white text-xl font-bold">Tensei</span>
<button @click="login" class="text-white cursor-pointer font-semibold" v-text="user ? user.email: 'Login'">

</button>
</div>
</nav>

<section class="max-w-6xl mx-auto grid grid-cols-1 md:grid-cols-4 gap-4 mt-16">
<div class="w-full bg-green-100 rounded h-96" v-for="sq in [1, 2, 3, 4, 5, 6, 7, 8]" :key="sq"></div>
</section>
</div>
</template>

<script>
export default {
async asyncData(ctx) {
return {
user: ctx.req?.session?.user
}
},
mounted() {
if (this.user) {
fetch('/auth/me')
}
},
methods: {
logout() {
fetch('/auth/logout', {
method: 'POST'
}).then(() => {
window.location.href = '/'
})
},
login() {
if (this.user) {
return this.logout()
}
fetch('/auth/login', {
method: 'POST',
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify({
email: 'hey@mail.ru',
password: 'password'
})
}).then(() => {
window.location.href = '/'
})
}
}
}
</script>
Loading

0 comments on commit bc8f55f

Please sign in to comment.