overleaf/services/filestore/test/acceptance/js/FilestoreApp.js
Antoine Clausse 7f48c67512 Add prefer-node-protocol ESLint rule (#21532)
* Add `unicorn/prefer-node-protocol`

* Fix `unicorn/prefer-node-protocol` ESLint errors

* Run `npm run format:fix`

* Add sandboxed-module sourceTransformers in mocha setups

Fix `no such file or directory, open 'node:fs'` in `sandboxed-module`

* Remove `node:` in the SandboxedModule requires

* Fix new linting errors with `node:`

GitOrigin-RevId: 68f6e31e2191fcff4cb8058dd0a6914c14f59926
2024-11-11 09:04:51 +00:00

45 lines
1.1 KiB
JavaScript

const logger = require('@overleaf/logger')
const ObjectPersistor = require('@overleaf/object-persistor')
const Settings = require('@overleaf/settings')
const { promisify } = require('node:util')
const App = require('../../../app')
const FileHandler = require('../../../app/js/FileHandler')
logger.logger.level('info')
class FilestoreApp {
async runServer() {
if (!this.server) {
await new Promise((resolve, reject) => {
this.server = App.listen(
Settings.internal.filestore.port,
'127.0.0.1',
err => {
if (err) {
return reject(err)
}
resolve()
}
)
})
}
this.persistor = ObjectPersistor({
...Settings.filestore,
paths: Settings.path,
})
FileHandler._TESTONLYSwapPersistorManager(this.persistor)
}
async stop() {
if (!this.server) return
const closeServer = promisify(this.server.close).bind(this.server)
try {
await closeServer()
} finally {
delete this.server
}
}
}
module.exports = FilestoreApp