-
Notifications
You must be signed in to change notification settings - Fork 308
Expand file tree
/
Copy pathldp-middleware.mjs
More file actions
38 lines (32 loc) · 1.1 KB
/
Copy pathldp-middleware.mjs
File metadata and controls
38 lines (32 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import express from 'express'
import { linksHandler, addPermissions } from './header.mjs'
import allow from './handlers/allow.mjs'
import get from './handlers/get.mjs'
import post from './handlers/post.mjs'
import put from './handlers/put.mjs'
import del from './handlers/delete.mjs'
import patch from './handlers/patch.mjs'
import index from './handlers/index.mjs'
import copy from './handlers/copy.mjs'
import notify from './handlers/notify.mjs'
export default function LdpMiddleware (corsSettings, prep) {
const router = express.Router('/')
// Add Link headers
router.use(linksHandler)
if (corsSettings) {
router.use(corsSettings)
}
router.copy('/*', allow('Write'), copy)
router.get('/*', index, allow('Read'), addPermissions, get)
router.post('/*', allow('Append'), post)
router.patch('/*', allow('Append'), patch)
router.put('/*', allow('Append'), put)
router.delete('/*', allow('Write'), del)
if (prep) {
router.post('/*', notify)
router.patch('/*', notify)
router.put('/*', notify)
router.delete('/*', notify)
}
return router
}