feat: apollo upgrade to 2.0 + dev improvements + localization

pull/621/head
NGPixel 7 years ago
parent 99d7078c2c
commit 49834461a6

@ -1,12 +1,16 @@
'use strict' 'use strict'
/* global siteConfig */
import Vue from 'vue' import Vue from 'vue'
import VueRouter from 'vue-router' import VueRouter from 'vue-router'
import VueClipboards from 'vue-clipboards' import VueClipboards from 'vue-clipboards'
import VueSimpleBreakpoints from 'vue-simple-breakpoints' import VueSimpleBreakpoints from 'vue-simple-breakpoints'
import VeeValidate from 'vee-validate' import VeeValidate from 'vee-validate'
import { ApolloClient } from 'apollo-client' import { ApolloClient } from 'apollo-client'
import { BatchHttpLink } from 'apollo-link-batch-http' import { createPersistedQueryLink } from 'apollo-link-persisted-queries'
// import { BatchHttpLink } from 'apollo-link-batch-http'
import { createHttpLink } from 'apollo-link-http'
import { InMemoryCache } from 'apollo-cache-inmemory' import { InMemoryCache } from 'apollo-cache-inmemory'
import VueApollo from 'vue-apollo' import VueApollo from 'vue-apollo'
import Vuetify from 'vuetify' import Vuetify from 'vuetify'
@ -37,17 +41,22 @@ window.WIKI = null
window.boot = boot window.boot = boot
window.Hammer = Hammer window.Hammer = Hammer
moment.locale(siteConfig.lang)
// ==================================== // ====================================
// Initialize Apollo Client (GraphQL) // Initialize Apollo Client (GraphQL)
// ==================================== // ====================================
const graphQLEndpoint = window.location.protocol + '//' + window.location.host + '/graphql' const graphQLEndpoint = window.location.protocol + '//' + window.location.host + '/graphql'
const graphQLLink = createPersistedQueryLink().concat(createHttpLink({
includeExtensions: true,
uri: graphQLEndpoint,
credentials: 'include'
}))
window.graphQL = new ApolloClient({ window.graphQL = new ApolloClient({
link: new BatchHttpLink({ link: graphQLLink,
uri: graphQLEndpoint,
credentials: 'include'
}),
cache: new InMemoryCache(), cache: new InMemoryCache(),
connectToDevTools: (process.env.node_env === 'development') connectToDevTools: (process.env.node_env === 'development')
}) })

@ -189,6 +189,7 @@ export default {
const resp = _.get(respRaw, 'data.localization.updateLocale.responseResult', {}) const resp = _.get(respRaw, 'data.localization.updateLocale.responseResult', {})
if (resp.succeeded) { if (resp.succeeded) {
WIKI.$i18n.i18next.changeLanguage(this.selectedLocale) WIKI.$i18n.i18next.changeLanguage(this.selectedLocale)
WIKI.$moment.locale(this.selectedLocale)
this.$store.commit('showNotification', { this.$store.commit('showNotification', {
message: 'Locale settings updated successfully.', message: 'Locale settings updated successfully.',
style: 'success', style: 'success',
@ -207,6 +208,7 @@ export default {
apollo: { apollo: {
locales: { locales: {
query: localesQuery, query: localesQuery,
fetchPolicy: 'network-only',
update: (data) => data.localization.locales.map(lc => ({ ...lc, isDownloading: false })), update: (data) => data.localization.locales.map(lc => ({ ...lc, isDownloading: false })),
watchLoading (isLoading) { watchLoading (isLoading) {
this.$store.commit(`loading${isLoading ? 'Start' : 'Stop'}`, 'admin-locale-refresh') this.$store.commit(`loading${isLoading ? 'Start' : 'Stop'}`, 'admin-locale-refresh')

@ -2,8 +2,8 @@
v-container(fluid, fill-height, grid-list-lg) v-container(fluid, fill-height, grid-list-lg)
v-layout(row, wrap) v-layout(row, wrap)
v-flex(xs12) v-flex(xs12)
.headline.primary--text System Info .headline.primary--text {{ $t('admin:system.title') }}
.subheading.grey--text Information about your system .subheading.grey--text {{ $t('admin:system.subtitle') }}
v-layout.mt-3(row wrap) v-layout.mt-3(row wrap)
v-flex(lg6 xs12) v-flex(lg6 xs12)
v-card v-card
@ -14,55 +14,55 @@
v-list-tile-avatar v-list-tile-avatar
v-icon.blue.white--text system_update_alt v-icon.blue.white--text system_update_alt
v-list-tile-content v-list-tile-content
v-list-tile-title Current Version v-list-tile-title {{ $t('admin:system.currentVersion') }}
v-list-tile-sub-title {{ info.currentVersion }} v-list-tile-sub-title {{ info.currentVersion }}
v-list-tile(avatar) v-list-tile(avatar)
v-list-tile-avatar v-list-tile-avatar
v-icon.blue.white--text open_in_browser v-icon.blue.white--text open_in_browser
v-list-tile-content v-list-tile-content
v-list-tile-title Latest Version v-list-tile-title {{ $t('admin:system.latestVersion') }}
v-list-tile-sub-title {{ info.latestVersion }} v-list-tile-sub-title {{ info.latestVersion }}
v-list-tile-action v-list-tile-action
v-list-tile-action-text Published X days ago v-list-tile-action-text {{ $t('admin:system.published') }} {{ info.latestVersionReleaseDate | moment('from') }}
v-divider v-divider
v-subheader Host Information v-subheader {{ $t('admin:system.hostInfo') }}
v-list-tile(avatar) v-list-tile(avatar)
v-list-tile-avatar v-list-tile-avatar
v-icon.blue-grey.white--text bubble_chart v-icon.blue-grey.white--text bubble_chart
v-list-tile-content v-list-tile-content
v-list-tile-title Operating System v-list-tile-title {{ $t('admin:system.os') }}
v-list-tile-sub-title {{ info.operatingSystem }} v-list-tile-sub-title {{ info.operatingSystem }}
v-list-tile(avatar) v-list-tile(avatar)
v-list-tile-avatar v-list-tile-avatar
v-icon.blue-grey.white--text computer v-icon.blue-grey.white--text computer
v-list-tile-content v-list-tile-content
v-list-tile-title Hostname v-list-tile-title {{ $t('admin:system.hostname') }}
v-list-tile-sub-title {{ info.hostname }} v-list-tile-sub-title {{ info.hostname }}
v-list-tile(avatar) v-list-tile(avatar)
v-list-tile-avatar v-list-tile-avatar
v-icon.blue-grey.white--text nfc v-icon.blue-grey.white--text nfc
v-list-tile-content v-list-tile-content
v-list-tile-title CPU Cores v-list-tile-title {{ $t('admin:system.cpuCores') }}
v-list-tile-sub-title {{ info.cpuCores }} v-list-tile-sub-title {{ info.cpuCores }}
v-list-tile(avatar) v-list-tile(avatar)
v-list-tile-avatar v-list-tile-avatar
v-icon.blue-grey.white--text memory v-icon.blue-grey.white--text memory
v-list-tile-content v-list-tile-content
v-list-tile-title Total RAM v-list-tile-title {{ $t('admin:system.totalRAM') }}
v-list-tile-sub-title {{ info.ramTotal }} v-list-tile-sub-title {{ info.ramTotal }}
v-list-tile(avatar) v-list-tile(avatar)
v-list-tile-avatar v-list-tile-avatar
v-icon.blue-grey.white--text last_page v-icon.blue-grey.white--text last_page
v-list-tile-content v-list-tile-content
v-list-tile-title Working Directory v-list-tile-title {{ $t('admin:system.workingDirectory') }}
v-list-tile-sub-title {{ info.workingDirectory }} v-list-tile-sub-title {{ info.workingDirectory }}
v-list-tile(avatar) v-list-tile(avatar)
v-list-tile-avatar v-list-tile-avatar
v-icon.blue-grey.white--text settings v-icon.blue-grey.white--text settings
v-list-tile-content v-list-tile-content
v-list-tile-title Configuration File v-list-tile-title {{ $t('admin:system.configFile') }}
v-list-tile-sub-title {{ info.configFile }} v-list-tile-sub-title {{ info.configFile }}
v-flex(lg6 xs12) v-flex(lg6 xs12)
@ -87,7 +87,7 @@
v-list-tile-title {{ info.redisVersion }} v-list-tile-title {{ info.redisVersion }}
v-list-tile-sub-title {{ info.redisHost }} v-list-tile-sub-title {{ info.redisHost }}
v-list-tile-action v-list-tile-action
v-list-tile-action-text RAM Usage: {{ info.redisUsedRAM }} / {{ info.redisTotalRAM }} v-list-tile-action-text {{ $t('admin:system.ramUsage', { used: info.redisUsedRAM, total: info.redisTotalRAM }) }}
v-divider v-divider

@ -35,7 +35,7 @@
button.button.is-blue.is-fullwidth(@click='verifySecurityCode') button.button.is-blue.is-fullwidth(@click='verifySecurityCode')
span {{ $t('auth:tfa.verifyToken') }} span {{ $t('auth:tfa.verifyToken') }}
.login-copyright .login-copyright
span {{ $t('footer.poweredBy') }} span {{ $t('common:footer.poweredBy') }}
a(href='https://wiki.js.org', rel='external', title='Wiki.js') Wiki.js a(href='https://wiki.js.org', rel='external', title='Wiki.js') Wiki.js
v-snackbar( v-snackbar(

@ -0,0 +1,13 @@
query {
users {
list {
id
name
email
provider
role
createdAt
updatedAt
}
}
}

@ -15,6 +15,8 @@ const babelDir = path.join(process.cwd(), '.webpack-cache/babel')
process.noDeprecation = true process.noDeprecation = true
fs.emptyDirSync(path.join(process.cwd(), 'assets'))
module.exports = { module.exports = {
mode: 'development', mode: 'development',
entry: { entry: {
@ -143,7 +145,10 @@ module.exports = {
{ {
test: /\.(graphql|gql)$/, test: /\.(graphql|gql)$/,
exclude: /node_modules/, exclude: /node_modules/,
loader: 'graphql-tag/loader' use: [
{ loader: 'graphql-persisted-document-loader' },
{ loader: 'graphql-tag/loader' }
]
}, },
{ {
test: /.jsx$/, test: /.jsx$/,

@ -19,6 +19,8 @@ const babelDir = path.join(process.cwd(), '.webpack-cache/babel')
process.noDeprecation = true process.noDeprecation = true
fs.emptyDirSync(path.join(process.cwd(), 'assets'))
module.exports = { module.exports = {
mode: 'production', mode: 'production',
entry: { entry: {
@ -149,7 +151,10 @@ module.exports = {
{ {
test: /\.(graphql|gql)$/, test: /\.(graphql|gql)$/,
exclude: /node_modules/, exclude: /node_modules/,
loader: 'graphql-tag/loader' use: [
{ loader: 'graphql-persisted-document-loader' },
{ loader: 'graphql-tag/loader' }
]
}, },
{ {
test: /.jsx$/, test: /.jsx$/,

@ -37,23 +37,25 @@
"node": ">=8.11" "node": ">=8.11"
}, },
"dependencies": { "dependencies": {
"apollo-server-express": "1.3.6", "apollo-server": "2.0.0-rc.2",
"apollo-server-express": "2.0.0-rc.2",
"auto-load": "3.0.0", "auto-load": "3.0.0",
"axios": "0.18.0", "axios": "0.18.0",
"bcryptjs-then": "1.0.1", "bcryptjs-then": "1.0.1",
"bluebird": "3.5.1", "bluebird": "3.5.1",
"body-parser": "1.18.3", "body-parser": "1.18.3",
"bugsnag": "2.4.0", "bugsnag": "2.4.3",
"bull": "3.4.2", "bull": "3.4.2",
"chalk": "2.4.1",
"cheerio": "1.0.0-rc.2", "cheerio": "1.0.0-rc.2",
"child-process-promise": "2.2.1", "child-process-promise": "2.2.1",
"chokidar": "2.0.3", "chokidar": "2.0.4",
"compression": "1.7.2", "compression": "1.7.2",
"connect-redis": "3.3.3", "connect-redis": "3.3.3",
"cookie-parser": "1.4.3", "cookie-parser": "1.4.3",
"cors": "2.8.4", "cors": "2.8.4",
"dependency-graph": "0.7.0", "dependency-graph": "0.7.1",
"diff2html": "2.3.3", "diff2html": "2.4.0",
"dotize": "^0.2.0", "dotize": "^0.2.0",
"execa": "0.10.0", "execa": "0.10.0",
"express": "4.16.3", "express": "4.16.3",
@ -68,21 +70,21 @@
"graphql": "0.13.2", "graphql": "0.13.2",
"graphql-list-fields": "2.0.2", "graphql-list-fields": "2.0.2",
"graphql-tools": "3.0.2", "graphql-tools": "3.0.2",
"i18next": "11.3.2", "i18next": "11.3.3",
"i18next-express-middleware": "1.1.1", "i18next-express-middleware": "1.1.1",
"i18next-localstorage-cache": "1.1.1", "i18next-localstorage-cache": "1.1.1",
"i18next-node-fs-backend": "1.0.0", "i18next-node-fs-backend": "1.0.0",
"image-size": "0.6.2", "image-size": "0.6.3",
"ioredis": "3.2.2", "ioredis": "3.2.2",
"js-yaml": "3.12.0", "js-yaml": "3.12.0",
"jsonwebtoken": "8.2.2", "jsonwebtoken": "8.3.0",
"klaw": "2.1.1", "klaw": "2.1.1",
"knex": "0.14.6", "knex": "0.14.6",
"lodash": "4.17.10", "lodash": "4.17.10",
"markdown-it": "8.4.1", "markdown-it": "8.4.1",
"markdown-it-abbr": "1.0.4", "markdown-it-abbr": "1.0.4",
"markdown-it-anchor": "4.0.0", "markdown-it-anchor": "5.0.2",
"markdown-it-attrs": "2.1.0", "markdown-it-attrs": "2.2.0",
"markdown-it-emoji": "1.4.0", "markdown-it-emoji": "1.4.0",
"markdown-it-expand-tabs": "1.0.13", "markdown-it-expand-tabs": "1.0.13",
"markdown-it-external-links": "0.0.6", "markdown-it-external-links": "0.0.6",
@ -93,10 +95,10 @@
"markdown-it-sub": "1.0.0", "markdown-it-sub": "1.0.0",
"markdown-it-sup": "1.0.0", "markdown-it-sup": "1.0.0",
"markdown-it-task-lists": "2.1.1", "markdown-it-task-lists": "2.1.1",
"mathjax-node": "2.1.0", "mathjax-node": "2.1.1",
"mime-types": "2.1.18", "mime-types": "2.1.18",
"moment": "2.22.2", "moment": "2.22.2",
"moment-timezone": "0.5.17", "moment-timezone": "0.5.21",
"mongodb": "3.1.0-beta4", "mongodb": "3.1.0-beta4",
"mssql": "4.1.0", "mssql": "4.1.0",
"multer": "1.3.0", "multer": "1.3.0",
@ -124,7 +126,7 @@
"pm2": "2.10.4", "pm2": "2.10.4",
"pug": "2.0.3", "pug": "2.0.3",
"qr-image": "3.2.0", "qr-image": "3.2.0",
"raven": "2.6.2", "raven": "2.6.3",
"read-chunk": "2.1.0", "read-chunk": "2.1.0",
"remove-markdown": "0.3.0", "remove-markdown": "0.3.0",
"request": "2.87.0", "request": "2.87.0",
@ -134,29 +136,30 @@
"serve-favicon": "2.5.0", "serve-favicon": "2.5.0",
"sqlite3": "4.0.0", "sqlite3": "4.0.0",
"uuid": "3.2.1", "uuid": "3.2.1",
"validator": "10.2.0", "validator": "10.4.0",
"validator-as-promised": "1.0.2", "validator-as-promised": "1.0.2",
"winston": "3.0.0-rc2", "winston": "3.0.0",
"yargs": "11.0.0" "yargs": "11.0.0"
}, },
"devDependencies": { "devDependencies": {
"@panter/vue-i18next": "0.11.0", "@panter/vue-i18next": "0.11.0",
"@vue/cli": "3.0.0-beta.15", "@vue/cli": "3.0.0-rc.3",
"apollo-cache-inmemory": "1.2.2", "apollo-cache-inmemory": "1.2.5",
"apollo-client": "2.3.2", "apollo-client": "2.3.5",
"apollo-fetch": "0.7.0", "apollo-fetch": "0.7.0",
"apollo-link": "1.2.2", "apollo-link": "1.2.2",
"apollo-link-batch-http": "1.2.2", "apollo-link-batch-http": "1.2.2",
"apollo-link-error": "1.0.9", "apollo-link-error": "1.1.0",
"apollo-link-http": "1.5.4", "apollo-link-http": "1.5.4",
"autoprefixer": "8.6.0", "apollo-link-persisted-queries": "0.2.1",
"autoprefixer": "8.6.3",
"babel-cli": "6.26.0", "babel-cli": "6.26.0",
"babel-core": "6.26.3", "babel-core": "6.26.3",
"babel-eslint": "8.2.3", "babel-eslint": "8.2.5",
"babel-jest": "23.0.1", "babel-jest": "23.0.1",
"babel-loader": "7.1.4", "babel-loader": "7.1.4",
"babel-plugin-graphql-tag": "1.6.0", "babel-plugin-graphql-tag": "1.6.0",
"babel-plugin-lodash": "3.3.2", "babel-plugin-lodash": "3.3.4",
"babel-plugin-transform-imports": "1.5.0", "babel-plugin-transform-imports": "1.5.0",
"babel-polyfill": "6.26.0", "babel-polyfill": "6.26.0",
"babel-preset-env": "1.7.0", "babel-preset-env": "1.7.0",
@ -165,12 +168,11 @@
"cache-loader": "1.2.2", "cache-loader": "1.2.2",
"chart.js": "2.7.2", "chart.js": "2.7.2",
"clean-webpack-plugin": "0.1.19", "clean-webpack-plugin": "0.1.19",
"colors": "1.3.0",
"copy-webpack-plugin": "4.5.1", "copy-webpack-plugin": "4.5.1",
"css-loader": "0.28.11", "css-loader": "0.28.11",
"cssnano": "4.0.0-rc.2", "cssnano": "4.0.0-rc.2",
"duplicate-package-checker-webpack-plugin": "3.0.0", "duplicate-package-checker-webpack-plugin": "3.0.0",
"eslint": "4.19.1", "eslint": "5.0.0",
"eslint-config-requarks": "1.0.7", "eslint-config-requarks": "1.0.7",
"eslint-config-standard": "11.0.0", "eslint-config-standard": "11.0.0",
"eslint-plugin-import": "2.12.0", "eslint-plugin-import": "2.12.0",
@ -180,15 +182,16 @@
"eslint-plugin-vue": "4.5.0", "eslint-plugin-vue": "4.5.0",
"file-loader": "1.1.11", "file-loader": "1.1.11",
"graphiql": "0.11.11", "graphiql": "0.11.11",
"graphql-persisted-document-loader": "1.0.1",
"graphql-tag": "^2.9.2", "graphql-tag": "^2.9.2",
"graphql-voyager": "1.0.0-rc.15", "graphql-voyager": "1.0.0-rc.19",
"hammerjs": "2.0.8", "hammerjs": "2.0.8",
"html-webpack-plugin": "3.2.0", "html-webpack-plugin": "3.2.0",
"html-webpack-pug-plugin": "0.3.0", "html-webpack-pug-plugin": "0.3.0",
"i18next-xhr-backend": "1.5.1", "i18next-xhr-backend": "1.5.1",
"ignore-loader": "0.1.2", "ignore-loader": "0.1.2",
"jest": "23.1.0", "jest": "23.1.0",
"jest-junit": "5.0.0", "jest-junit": "5.1.0",
"js-cookie": "2.2.0", "js-cookie": "2.2.0",
"lodash-webpack-plugin": "0.11.5", "lodash-webpack-plugin": "0.11.5",
"mini-css-extract-plugin": "0.4.0", "mini-css-extract-plugin": "0.4.0",
@ -206,9 +209,9 @@
"pug-loader": "2.4.0", "pug-loader": "2.4.0",
"pug-plain-loader": "1.0.0", "pug-plain-loader": "1.0.0",
"raw-loader": "0.5.1", "raw-loader": "0.5.1",
"react": "16.4.0", "react": "16.4.1",
"react-dom": "16.4.0", "react-dom": "16.4.1",
"sass-loader": "7.0.2", "sass-loader": "7.0.3",
"sass-resources-loader": "1.3.3", "sass-resources-loader": "1.3.3",
"script-ext-html-webpack-plugin": "2.0.1", "script-ext-html-webpack-plugin": "2.0.1",
"simple-progress-webpack-plugin": "1.1.2", "simple-progress-webpack-plugin": "1.1.2",
@ -217,29 +220,29 @@
"stylus-loader": "3.0.2", "stylus-loader": "3.0.2",
"twemoji-awesome": "1.0.6", "twemoji-awesome": "1.0.6",
"url-loader": "1.0.1", "url-loader": "1.0.1",
"vee-validate": "2.1.0-beta.1", "vee-validate": "2.1.0-beta.2",
"velocity-animate": "1.5.1", "velocity-animate": "1.5.1",
"vue": "2.5.16", "vue": "2.5.16",
"vue-apollo": "3.0.0-beta.16", "vue-apollo": "3.0.0-beta.19",
"vue-chartjs": "3.3.1", "vue-chartjs": "3.3.2",
"vue-clipboards": "1.2.4", "vue-clipboards": "1.2.4",
"vue-codemirror": "4.0.5", "vue-codemirror": "4.0.5",
"vue-hot-reload-api": "2.3.0", "vue-hot-reload-api": "2.3.0",
"vue-loader": "15.2.4", "vue-loader": "15.2.4",
"vue-material-design-icons": "1.5.1", "vue-material-design-icons": "1.5.1",
"vue-moment": "4.0.0-0", "vue-moment": "4.0.0",
"vue-router": "3.0.1", "vue-router": "3.0.1",
"vue-simple-breakpoints": "1.0.3", "vue-simple-breakpoints": "1.0.3",
"vue-template-compiler": "2.5.16", "vue-template-compiler": "2.5.16",
"vuetify": "1.0.18", "vuetify": "1.0.19",
"vuex": "3.0.1", "vuex": "3.0.1",
"vuex-persistedstate": "2.5.4", "vuex-persistedstate": "2.5.4",
"webpack": "4.10.2", "webpack": "4.12.0",
"webpack-bundle-analyzer": "2.13.1", "webpack-bundle-analyzer": "2.13.1",
"webpack-cli": "3.0.1", "webpack-cli": "3.0.8",
"webpack-dev-middleware": "3.1.3", "webpack-dev-middleware": "3.1.3",
"webpack-hot-middleware": "2.22.2", "webpack-hot-middleware": "2.22.2",
"webpack-merge": "4.1.2", "webpack-merge": "4.1.3",
"whatwg-fetch": "2.0.4", "whatwg-fetch": "2.0.4",
"write-file-webpack-plugin": "4.3.2" "write-file-webpack-plugin": "4.3.2"
}, },

@ -171,6 +171,7 @@ module.exports = class User extends Model {
} }
static async login (opts, context) { static async login (opts, context) {
console.info(context)
if (_.has(WIKI.auth.strategies, opts.strategy)) { if (_.has(WIKI.auth.strategies, opts.strategy)) {
_.set(context.req, 'body.email', opts.username) _.set(context.req, 'body.email', opts.username)
_.set(context.req, 'body.password', opts.password) _.set(context.req, 'body.password', opts.password)

@ -1,6 +1,6 @@
const _ = require('lodash') const _ = require('lodash')
const fs = require('fs') const fs = require('fs')
const gqlTools = require('graphql-tools') // const gqlTools = require('graphql-tools')
const path = require('path') const path = require('path')
const autoload = require('auto-load') const autoload = require('auto-load')
@ -24,11 +24,14 @@ resolversObj.forEach(resolver => {
_.merge(resolvers, resolver) _.merge(resolvers, resolver)
}) })
const Schema = gqlTools.makeExecutableSchema({ // const Schema = gqlTools.makeExecutableSchema({
typeDefs, // typeDefs,
resolvers // resolvers
}) // })
WIKI.logger.info(`GraphQL Schema: [ OK ]`) WIKI.logger.info(`GraphQL Schema: [ OK ]`)
module.exports = Schema module.exports = {
typeDefs,
resolvers
}

@ -29,8 +29,6 @@ module.exports = {
osLabel = `${os.type()} - ${osInfo.dist} (${osInfo.codename || os.platform()}) ${osInfo.release || os.release()} ${os.arch()}` osLabel = `${os.type()} - ${osInfo.dist} (${osInfo.codename || os.platform()}) ${osInfo.release || os.release()} ${os.arch()}`
} }
console.info(WIKI.db.knex.client)
return { return {
configFile: path.join(process.cwd(), 'config.yml'), configFile: path.join(process.cwd(), 'config.yml'),
currentVersion: WIKI.version, currentVersion: WIKI.version,

@ -21,7 +21,10 @@ module.exports = {
.select('id', 'email', 'name', 'provider', 'role', 'createdAt', 'updatedAt') .select('id', 'email', 'name', 'provider', 'role', 'createdAt', 'updatedAt')
}, },
async single(obj, args, context, info) { async single(obj, args, context, info) {
return WIKI.db.users.query().findById(args.id) let usr = await WIKI.db.users.query().findById(args.id)
usr.password = ''
usr.tfaSecret = ''
return usr
} }
}, },
UserMutation: { UserMutation: {

@ -13,14 +13,6 @@ enum RightRole {
manage manage
} }
# INTERFACES
interface Base {
id: Int!
createdAt: Date
updatedAt: Date
}
# TYPES # TYPES
type KeyValuePair { type KeyValuePair {
@ -43,7 +35,7 @@ type ResponseStatus {
message: String message: String
} }
type Comment implements Base { type Comment {
id: Int! id: Int!
createdAt: Date createdAt: Date
updatedAt: Date updatedAt: Date
@ -52,7 +44,7 @@ type Comment implements Base {
author: User! author: User!
} }
type Document implements Base { type Document {
id: Int! id: Int!
createdAt: Date createdAt: Date
updatedAt: Date updatedAt: Date
@ -68,7 +60,7 @@ type Document implements Base {
tags: [Tag] tags: [Tag]
} }
type File implements Base { type File {
id: Int! id: Int!
createdAt: Date createdAt: Date
updatedAt: Date updatedAt: Date
@ -81,7 +73,7 @@ type File implements Base {
folder: Folder folder: Folder
} }
type Folder implements Base { type Folder {
id: Int! id: Int!
createdAt: Date createdAt: Date
updatedAt: Date updatedAt: Date
@ -89,7 +81,7 @@ type Folder implements Base {
files: [File] files: [File]
} }
type Right implements Base { type Right {
id: Int! id: Int!
createdAt: Date createdAt: Date
updatedAt: Date updatedAt: Date
@ -106,7 +98,7 @@ type SearchResult {
tags: [String] tags: [String]
} }
type Setting implements Base { type Setting {
id: Int! id: Int!
createdAt: Date createdAt: Date
updatedAt: Date updatedAt: Date
@ -115,7 +107,7 @@ type Setting implements Base {
} }
# Tags are attached to one or more documents # Tags are attached to one or more documents
type Tag implements Base { type Tag {
id: Int! id: Int!
createdAt: Date createdAt: Date
updatedAt: Date updatedAt: Date

@ -9,8 +9,7 @@ const http = require('http')
const path = require('path') const path = require('path')
const session = require('express-session') const session = require('express-session')
const SessionRedisStore = require('connect-redis')(session) const SessionRedisStore = require('connect-redis')(session)
const graphqlApollo = require('apollo-server-express') const { ApolloServer } = require('apollo-server-express')
const graphqlSchema = require('./graph')
// const oauth2orize = require('oauth2orize') // const oauth2orize = require('oauth2orize')
/* global WIKI */ /* global WIKI */
@ -124,23 +123,34 @@ module.exports = async () => {
} }
// ---------------------------------------- // ----------------------------------------
// Controllers // Apollo Server (GraphQL)
// ----------------------------------------
const graphqlSchema = require('./graph')
const apolloServer = new ApolloServer({
...graphqlSchema,
context: ({ req, res }) => ({ req, res })
})
apolloServer.applyMiddleware({ app })
// ----------------------------------------
// Routing
// ---------------------------------------- // ----------------------------------------
app.use('/', ctrl.auth) app.use('/', ctrl.auth)
app.use('/graphql', (req, res, next) => { // app.use('/graphql', (req, res, next) => {
graphqlApollo.graphqlExpress({ // graphqlApollo.graphqlExpress({
schema: graphqlSchema, // schema: graphqlSchema,
context: { req, res }, // context: { req, res },
formatError: (err) => { // formatError: (err) => {
return { // return {
message: err.message // message: err.message
} // }
} // }
})(req, res, next) // })(req, res, next)
}) // })
app.use('/graphiql', graphqlApollo.graphiqlExpress({ endpointURL: '/graphql' })) // app.use('/graphiql', graphqlApollo.graphiqlExpress({ endpointURL: '/graphql' }))
app.use('/', mw.auth, ctrl.common) app.use('/', mw.auth, ctrl.common)

@ -12,6 +12,8 @@ const pm2 = Promise.promisifyAll(require('pm2'))
const ora = require('ora') const ora = require('ora')
const path = require('path') const path = require('path')
const cluster = require('cluster') const cluster = require('cluster')
const _ = require('lodash')
const chalk = require('chalk')
const ROOTPATH = process.cwd() const ROOTPATH = process.cwd()
@ -81,9 +83,19 @@ const init = {
hotMiddleware: require('webpack-hot-middleware')(global.WP) hotMiddleware: require('webpack-hot-middleware')(global.WP)
} }
global.WP_DEV.devMiddleware.waitUntilValid(() => { global.WP_DEV.devMiddleware.waitUntilValid(() => {
console.info('>>> Starting Wiki.js in DEVELOPER mode...') console.info(chalk.yellow.bold('>>> Starting Wiki.js in DEVELOPER mode...'))
require('./server') require('./server')
process.stdin.setEncoding('utf8')
process.stdin.on('data', data => {
if (_.trim(data) === 'rs') {
console.warn(chalk.yellow.bold('--- >>>>>>>>>>>>>>>>>>>>>>>> ---'))
console.warn(chalk.yellow.bold('--- Manual restart requested ---'))
console.warn(chalk.yellow.bold('--- <<<<<<<<<<<<<<<<<<<<<<<< ---'))
this.reload()
}
})
const devWatcher = chokidar.watch([ const devWatcher = chokidar.watch([
'./server', './server',
'!./server/views/master.pug' '!./server/views/master.pug'
@ -92,30 +104,38 @@ const init = {
atomic: 400 atomic: 400
}) })
devWatcher.on('ready', () => { devWatcher.on('ready', () => {
devWatcher.on('all', async () => { devWatcher.on('all', () => {
console.warn('--- >>>>>>>>>>>>>>>>>>>>>>>>>>>> ---') console.warn(chalk.yellow.bold('--- >>>>>>>>>>>>>>>>>>>>>>>>>>>> ---'))
console.warn('--- Changes detected: Restarting ---') console.warn(chalk.yellow.bold('--- Changes detected: Restarting ---'))
console.warn('--- <<<<<<<<<<<<<<<<<<<<<<<<<<<< ---') console.warn(chalk.yellow.bold('--- <<<<<<<<<<<<<<<<<<<<<<<<<<<< ---'))
console.warn('--- Closing DB connections...') this.reload()
await global.WIKI.db.knex.destroy()
console.warn('--- Closing Redis connections...')
await global.WIKI.redis.quit()
console.warn('--- Closing Server connections...')
global.WIKI.server.destroy(() => {
global.WIKI = {}
Object.keys(require.cache).forEach(function(id) {
if (/[/\\]server[/\\]/.test(id)) {
delete require.cache[id]
}
})
require('./server')
})
}) })
}) })
}) })
} else { } else {
require('./server') require('./server')
} }
},
async reload() {
console.warn(chalk.yellow('--- Closing DB connections...'))
await global.WIKI.db.knex.destroy()
console.warn(chalk.yellow('--- Closing Redis connections...'))
await global.WIKI.redis.quit()
console.warn(chalk.yellow('--- Closing Server connections...'))
global.WIKI.server.destroy(() => {
global.WIKI = {}
Object.keys(require.cache).forEach(id => {
if (/[/\\]server[/\\]/.test(id)) {
delete require.cache[id]
}
})
Object.keys(module.constructor._pathCache).forEach(cacheKey => {
if (/[/\\]server[/\\]/.test(cacheKey)) {
delete module.constructor._pathCache[cacheKey]
}
})
require('./server')
})
} }
} }

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save