You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
cudr_slate-collaborative/packages/example/server.js

29 lines
745 B

const Connection = require('@slate-collaborative/backend')
const defaultValue = require('./src/defaultValue')
const express = require('express')
const PORT = process.env.PORT || 9000
const server = express()
.use(express.static('build'))
.listen(PORT, () => console.log(`Listening on ${PORT}`))
const config = {
entry: server, // or specify port to start io server
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)