feat: admin auth + config ref + modules sidebar ui + GQL upload (wip)
This commit is contained in:
16
server/db/migrations-sqlite/2.0.0-beta.99.js
Normal file
16
server/db/migrations-sqlite/2.0.0-beta.99.js
Normal file
@@ -0,0 +1,16 @@
|
||||
exports.up = knex => {
|
||||
const dbCompat = {
|
||||
charset: (WIKI.config.db.type === `mysql` || WIKI.config.db.type === `mariadb`)
|
||||
}
|
||||
return knex.schema
|
||||
.createTable('assetData', table => {
|
||||
if (dbCompat.charset) { table.charset('utf8mb4') }
|
||||
table.integer('id').primary()
|
||||
table.binary('data').notNullable()
|
||||
})
|
||||
}
|
||||
|
||||
exports.down = knex => {
|
||||
return knex.schema
|
||||
.dropTableIfExists('assetData')
|
||||
}
|
16
server/db/migrations/2.0.0-beta.99.js
Normal file
16
server/db/migrations/2.0.0-beta.99.js
Normal file
@@ -0,0 +1,16 @@
|
||||
exports.up = knex => {
|
||||
const dbCompat = {
|
||||
charset: (WIKI.config.db.type === `mysql` || WIKI.config.db.type === `mariadb`)
|
||||
}
|
||||
return knex.schema
|
||||
.createTable('assetData', table => {
|
||||
if (dbCompat.charset) { table.charset('utf8mb4') }
|
||||
table.integer('id').primary()
|
||||
table.binary('data').notNullable()
|
||||
})
|
||||
}
|
||||
|
||||
exports.down = knex => {
|
||||
return knex.schema
|
||||
.dropTableIfExists('assetData')
|
||||
}
|
@@ -7,6 +7,7 @@ const PubSub = require('graphql-subscriptions').PubSub
|
||||
const { LEVEL, MESSAGE } = require('triple-beam')
|
||||
const Transport = require('winston-transport')
|
||||
const { createRateLimitTypeDef } = require('graphql-rate-limit-directive')
|
||||
const { GraphQLUpload } = require('graphql-upload')
|
||||
|
||||
/* global WIKI */
|
||||
|
||||
@@ -26,7 +27,9 @@ schemas.forEach(schema => {
|
||||
|
||||
// Resolvers
|
||||
|
||||
let resolvers = {}
|
||||
let resolvers = {
|
||||
Upload: GraphQLUpload
|
||||
}
|
||||
const resolversObj = _.values(autoload(path.join(WIKI.SERVERPATH, 'graph/resolvers')))
|
||||
resolversObj.forEach(resolver => {
|
||||
_.merge(resolvers, resolver)
|
||||
|
45
server/graph/schemas/asset.graphql
Normal file
45
server/graph/schemas/asset.graphql
Normal file
@@ -0,0 +1,45 @@
|
||||
# ===============================================
|
||||
# ASSETS
|
||||
# ===============================================
|
||||
|
||||
extend type Query {
|
||||
assets: AssetQuery
|
||||
}
|
||||
|
||||
extend type Mutation {
|
||||
assets: AssetMutation
|
||||
}
|
||||
|
||||
# -----------------------------------------------
|
||||
# QUERIES
|
||||
# -----------------------------------------------
|
||||
|
||||
type AssetQuery {
|
||||
list(
|
||||
root: String
|
||||
kind: [AssetKind]
|
||||
): [AssetItem]
|
||||
}
|
||||
|
||||
# -----------------------------------------------
|
||||
# MUTATIONS
|
||||
# -----------------------------------------------
|
||||
|
||||
type AssetMutation {
|
||||
upload(
|
||||
data: Upload!
|
||||
): DefaultResponse
|
||||
}
|
||||
|
||||
# -----------------------------------------------
|
||||
# TYPES
|
||||
# -----------------------------------------------
|
||||
|
||||
type AssetItem {
|
||||
id: Int!
|
||||
}
|
||||
|
||||
enum AssetKind {
|
||||
IMAGE
|
||||
BINARY
|
||||
}
|
@@ -58,6 +58,7 @@ type AuthenticationStrategy {
|
||||
props: [String]
|
||||
title: String!
|
||||
description: String
|
||||
isAvailable: Boolean
|
||||
useForm: Boolean!
|
||||
logo: String
|
||||
color: String
|
||||
|
@@ -11,7 +11,6 @@ const https = require('https')
|
||||
const path = require('path')
|
||||
const _ = require('lodash')
|
||||
const { ApolloServer } = require('apollo-server-express')
|
||||
// const oauth2orize = require('oauth2orize')
|
||||
|
||||
/* global WIKI */
|
||||
|
||||
@@ -61,12 +60,6 @@ module.exports = async () => {
|
||||
maxAge: '7d'
|
||||
}))
|
||||
|
||||
// ----------------------------------------
|
||||
// OAuth2 Server
|
||||
// ----------------------------------------
|
||||
|
||||
// const OAuth2Server = oauth2orize.createServer()
|
||||
|
||||
// ----------------------------------------
|
||||
// Passport Authentication
|
||||
// ----------------------------------------
|
||||
@@ -137,6 +130,7 @@ module.exports = async () => {
|
||||
path: '/graphql-subscriptions'
|
||||
}
|
||||
})
|
||||
app.use('/graphql', mw.upload)
|
||||
apolloServer.applyMiddleware({ app })
|
||||
|
||||
// ----------------------------------------
|
||||
|
8
server/middlewares/upload.js
Normal file
8
server/middlewares/upload.js
Normal file
@@ -0,0 +1,8 @@
|
||||
const { graphqlUploadExpress } = require('graphql-upload')
|
||||
|
||||
/* global WIKI */
|
||||
|
||||
/**
|
||||
* GraphQL File Upload Middleware
|
||||
*/
|
||||
module.exports = graphqlUploadExpress({ maxFileSize: 5000000, maxFiles: 20 })
|
@@ -5,8 +5,21 @@ author: requarks.io
|
||||
logo: https://static.requarks.io/logo/auth0.svg
|
||||
color: deep-orange
|
||||
website: https://auth0.com/
|
||||
isAvailable: true
|
||||
useForm: false
|
||||
props:
|
||||
domain: String
|
||||
clientId: String
|
||||
clientSecret: String
|
||||
domain:
|
||||
type: String
|
||||
title: Domain
|
||||
hint: Your Auth0 domain (e.g. something.auth0.com)
|
||||
order: 1
|
||||
clientId:
|
||||
type: String
|
||||
title: Client ID
|
||||
hint: Application Client ID
|
||||
order: 2
|
||||
clientSecret:
|
||||
type: String
|
||||
title: Client Secret
|
||||
hint: Application Client Secret
|
||||
order: 3
|
||||
|
@@ -5,5 +5,6 @@ author: requarks.io
|
||||
logo: https://static.requarks.io/logo/wikijs.svg
|
||||
color: yellow darken-3
|
||||
website: https://wiki.js.org
|
||||
isAvailable: true
|
||||
useForm: true
|
||||
props: {}
|
||||
|
Reference in New Issue
Block a user