Skip to content
Snippets Groups Projects
Commit 4d89db0b authored by Yannis Barlas's avatar Yannis Barlas
Browse files

feat(server): add ability to disable server

parent fa2ce203
No related branches found
No related tags found
No related merge requests found
...@@ -155,6 +155,24 @@ cron.schedule('* * * * * *', () => { ...@@ -155,6 +155,24 @@ cron.schedule('* * * * * *', () => {
The library that enables this is `node-cron`. Be sure to check its [documentation](https://github.com/node-cron/node-cron#node-cron) for further details. The library that enables this is `node-cron`. Be sure to check its [documentation](https://github.com/node-cron/node-cron#node-cron) for further details.
### Disable GraphQL
There are cases where you might not want a graphql server at all. eg. If you are building a sevice with a single REST api endpoint with coko server.
To disable graphql on the server, change the following value in your config:
```js
// config/default.js
module.exports = {
'pubsweet-server': {
useGraphQLServer: false,
},
}
```
_Note that this is `true` by default as using GraphQL will be the most common use case._
### CORS support for the client ### CORS support for the client
If you run your client on a different host/port than the server, you might run into issues where cross-origin requests are rejected. If that happens, make sure the following entries exist in your config. The server should take care of it once these are defined. If you run your client on a different host/port than the server, you might run into issues where cross-origin requests are rejected. If that happens, make sure the following entries exist in your config. The server should take care of it once these are defined.
......
...@@ -86,8 +86,20 @@ const configureApp = app => { ...@@ -86,8 +86,20 @@ const configureApp = app => {
app.use('/api', api) // REST API app.use('/api', api) // REST API
const gqlApi = require('./graphqlApi') let useGraphQLServer = true
gqlApi(app) // GraphQL API if (
config.has('pubsweet-server.useGraphQLServer') &&
config.get('pubsweet-server.useGraphQLServer') === false
) {
useGraphQLServer = false
}
logger.warn('useGraphQLServer', useGraphQLServer)
if (useGraphQLServer) {
const gqlApi = require('./graphqlApi')
gqlApi(app) // GraphQL API
}
app.use('/', index) // Serve the index page for front end app.use('/', index) // Serve the index page for front end
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment