Skip to content

Commit e738094

Browse files
committed
security to ESM
1 parent 3d1563b commit e738094

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

lib/defaultargs.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ const exports = argv => {
5959
argv.database.type = 'wiki-storage-' + argv.database.type
6060
}
6161

62-
argv.security_type ||= './security.cjs'
63-
if (argv.security_type === './security.cjs') {
62+
argv.security_type ||= './security.js'
63+
if (argv.security_type === './security.js') {
6464
console.log('\n\nINFORMATION: Using default security module.')
6565
} else {
6666
argv.security_type = 'wiki-security-' + argv.security_type

lib/security.cjs renamed to lib/security.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@
1313
// allow the server to run read-only.
1414

1515
// #### Requires ####
16-
const fs = require('node:fs')
16+
import fs from 'node:fs'
1717

1818
// Export a function that generates security handler
1919
// when called with options object.
20-
module.exports = exports = (log, loga, argv) => {
20+
const exports = (log, loga, argv) => {
2121
const security = {}
2222

2323
// #### Private utility methods. ####
@@ -92,3 +92,6 @@ module.exports = exports = (log, loga, argv) => {
9292

9393
return security
9494
}
95+
96+
export default exports
97+
export { exports }

lib/server.cjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ module.exports = exports = argv => {
139139
app.searchhandler = searchhandler = searchFactory.default(argv)
140140

141141
// Require the security adapter and initialize it with options.
142-
app.securityhandler = securityhandler = require(argv.security_type)(log, loga, argv)
142+
app.securityhandler = securityhandler = require(argv.security_type).default(log, loga, argv)
143143

144144
// If the site is owned, owner will contain the name of the owner
145145
let owner = ''

0 commit comments

Comments
 (0)