2019-10-05 08:44:49 +00:00
|
|
|
const Connection = require('@slate-collaborative/backend')
|
|
|
|
const defaultValue = require('./src/defaultValue')
|
2019-10-27 12:43:12 +00:00
|
|
|
const server = require('http').createServer()
|
2019-10-05 08:44:49 +00:00
|
|
|
|
|
|
|
const config = {
|
2019-10-27 12:43:12 +00:00
|
|
|
entry: server, // or specify port to start io server
|
2019-10-05 08:44:49 +00:00
|
|
|
defaultValue,
|
|
|
|
saveTreshold: 2000,
|
|
|
|
onAuthRequest: async (query, socket) => {
|
|
|
|
// some query validation
|
|
|
|
return true
|
|
|
|
},
|
|
|
|
onDocumentLoad: async pathname => {
|
|
|
|
// return initial document ValueJSON by pathnme
|
|
|
|
return defaultValue
|
|
|
|
},
|
|
|
|
onDocumentSave: async (pathname, document) => {
|
|
|
|
// save document
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const connection = new Connection(config)
|
2019-10-27 12:43:12 +00:00
|
|
|
|
|
|
|
server.listen(9000)
|