refactor: logging + search modules PH

This commit is contained in:
Nicolas Giard
2018-08-31 23:42:14 -04:00
parent 23f07381c2
commit 9c6a4f6c20
34 changed files with 327 additions and 189 deletions

View File

@@ -7,9 +7,7 @@ defaults:
config:
# File defaults
port: 80
paths:
repo: ./repo
data: ./data
bindIP: 0.0.0.0
db:
type: postgres
host: localhost

View File

@@ -170,7 +170,7 @@ module.exports = async () => {
app.set('port', WIKI.config.port)
WIKI.server = http.createServer(app)
WIKI.server.listen(WIKI.config.port)
WIKI.server.listen(WIKI.config.port, WIKI.config.bindIP)
WIKI.server.on('error', (error) => {
if (error.syscall !== 'listen') {
throw error

View File

@@ -1,26 +0,0 @@
module.exports = {
key: 'algolia',
title: 'Algolia',
props: ['applicationID', 'adminAPIKey'],
activate(opts) {
},
deactivate(opts) {
},
query(opts) {
},
created(opts) {
},
updated(opts) {
},
deleted(opts) {
},
renamed(opts) {
}
}

View File

@@ -0,0 +1,7 @@
key: algolia
title: Algolia
description: Algolia is a powerful search-as-a-service solution, made easy to use with API clients, UI libraries, and pre-built integrations.
author: requarks.io
logo: https://static.requarks.io/logo/algolia.svg
website: https://www.algolia.com/
props: {}

View File

@@ -0,0 +1,26 @@
module.exports = {
activate() {
},
deactivate() {
},
query() {
},
created() {
},
updated() {
},
deleted() {
},
renamed() {
},
rebuild() {
}
}

View File

@@ -0,0 +1,7 @@
key: aws
title: AWS CloudSearch
description: Amazon CloudSearch is a managed service in the AWS Cloud that makes it simple and cost-effective to set up, manage, and scale a search solution for your website or application.
author: requarks.io
logo: https://static.requarks.io/logo/aws.svg
website: https://aws.amazon.com/cloudsearch/
props: {}

View File

@@ -0,0 +1,26 @@
module.exports = {
activate() {
},
deactivate() {
},
query() {
},
created() {
},
updated() {
},
deleted() {
},
renamed() {
},
rebuild() {
}
}

View File

@@ -1,26 +0,0 @@
module.exports = {
key: 'azure',
title: 'Azure Search',
props: ['apiKey', 'applicationID'],
activate(opts) {
},
deactivate(opts) {
},
query(opts) {
},
created(opts) {
},
updated(opts) {
},
deleted(opts) {
},
renamed(opts) {
}
}

View File

@@ -0,0 +1,7 @@
key: azure
title: Azure Search
description: AI-Powered cloud search service for web and mobile app development.
author: requarks.io
logo: https://static.requarks.io/logo/azure.svg
website: https://azure.microsoft.com/services/search/
props: {}

View File

@@ -0,0 +1,26 @@
module.exports = {
activate() {
},
deactivate() {
},
query() {
},
created() {
},
updated() {
},
deleted() {
},
renamed() {
},
rebuild() {
}
}

View File

@@ -1,26 +0,0 @@
module.exports = {
key: 'db',
title: 'Database (built-in)',
props: [],
activate(opts) {
},
deactivate(opts) {
},
query(opts) {
},
created(opts) {
},
updated(opts) {
},
deleted(opts) {
},
renamed(opts) {
}
}

View File

@@ -0,0 +1,7 @@
key: db
title: Database (built-in)
description: Default database-based search engine.
author: requarks.io
logo: https://static.requarks.io/logo/db.svg
website: https://www.requarks.io/
props: {}

View File

@@ -0,0 +1,26 @@
module.exports = {
activate() {
},
deactivate() {
},
query() {
},
created() {
},
updated() {
},
deleted() {
},
renamed() {
},
rebuild() {
}
}

View File

@@ -1,26 +0,0 @@
module.exports = {
key: 'elasticsearch',
title: 'Elasticsearch',
props: [],
activate(opts) {
},
deactivate(opts) {
},
query(opts) {
},
created(opts) {
},
updated(opts) {
},
deleted(opts) {
},
renamed(opts) {
}
}

View File

@@ -0,0 +1,7 @@
key: elasticsearch
title: Elasticsearch
description: Elasticsearch is a distributed, RESTful search and analytics engine capable of solving a growing number of use cases.
author: requarks.io
logo: https://static.requarks.io/logo/elasticsearch.svg
website: https://www.elastic.co/products/elasticsearch
props: {}

View File

@@ -0,0 +1,26 @@
module.exports = {
activate() {
},
deactivate() {
},
query() {
},
created() {
},
updated() {
},
deleted() {
},
renamed() {
},
rebuild() {
}
}

View File

@@ -0,0 +1,7 @@
key: manticore
title: Manticore Search
description: High performance full-text search engine with SQL and JSON support.
author: requarks.io
logo: https://static.requarks.io/logo/manticore.svg
website: https://manticoresearch.com/
props: {}

View File

@@ -0,0 +1,26 @@
module.exports = {
activate() {
},
deactivate() {
},
query() {
},
created() {
},
updated() {
},
deleted() {
},
renamed() {
},
rebuild() {
}
}

View File

@@ -1,26 +0,0 @@
module.exports = {
key: 'solr',
title: 'Solr',
props: [],
activate(opts) {
},
deactivate(opts) {
},
query(opts) {
},
created(opts) {
},
updated(opts) {
},
deleted(opts) {
},
renamed(opts) {
}
}

View File

@@ -0,0 +1,7 @@
key: solr
title: Solr
description: Solr is the popular, blazing-fast, open source enterprise search platform built on Apache Lucene.
author: requarks.io
logo: https://static.requarks.io/logo/solr.svg
website: http://lucene.apache.org/solr/
props: {}

View File

@@ -0,0 +1,26 @@
module.exports = {
activate() {
},
deactivate() {
},
query() {
},
created() {
},
updated() {
},
deleted() {
},
renamed() {
},
rebuild() {
}
}

View File

@@ -0,0 +1,7 @@
key: sphinx
title: Sphinx
description: Sphinx is an open source full text search server, designed from the ground up with performance, relevance and integration simplicity in mind.
author: requarks.io
logo: https://static.requarks.io/logo/sphinx.svg
website: http://sphinxsearch.com/
props: {}

View File

@@ -0,0 +1,26 @@
module.exports = {
activate() {
},
deactivate() {
},
query() {
},
created() {
},
updated() {
},
deleted() {
},
renamed() {
},
rebuild() {
}
}

View File

@@ -1,4 +1,5 @@
const path = require('path')
const os = require('os')
/* global WIKI */
@@ -89,16 +90,11 @@ module.exports = () => {
})
}
// Update config file
WIKI.logger.info('Writing config file to disk...')
let confRaw = await fs.readFileAsync(path.join(WIKI.ROOTPATH, 'config.yml'), 'utf8')
let conf = yaml.safeLoad(confRaw)
// Create directory structure
await fs.ensureDir(conf.paths.data)
await fs.ensureDir(path.join(conf.paths.data, 'cache'))
await fs.ensureDir(path.join(conf.paths.data, 'temp-upload'))
await fs.ensureDir(conf.paths.content)
const tmpPath = path.join(os.tmpdir(), 'wikijs')
await fs.ensureDir(tmpPath)
await fs.ensureDir(path.join(tmpPath, 'cache'))
await fs.ensureDir(path.join(tmpPath, 'uploads'))
// Set config
_.set(WIKI.config, 'defaultEditor', 'markdown')
@@ -237,7 +233,7 @@ module.exports = () => {
app.set('port', WIKI.config.port)
WIKI.server = http.createServer(app)
WIKI.server.listen(WIKI.config.port)
WIKI.server.listen(WIKI.config.port, WIKI.config.bindIP)
var openConnections = []