File tree Expand file tree Collapse file tree 2 files changed +41
-0
lines changed
src/main/resources/services/postMarkdown Expand file tree Collapse file tree 2 files changed +41
-0
lines changed Original file line number Diff line number Diff line change 1+ import { connect } from '/lib/xp/node'
2+
3+ export const post = ( req : XP . Request ) : XP . Response => {
4+ const params = {
5+ displayName : req . params . displayName ,
6+ markdown : req . params . markdown ,
7+ }
8+
9+ const conn = connect ( {
10+ repoId : 'no.ssb.pubmd' ,
11+ branch : 'master' ,
12+ principals : [ 'role:system.admin' ] ,
13+ } )
14+
15+ const nodeId = typeof req . params . _id === 'string' ? req . params . _id : ''
16+ const nodeExists = nodeId ? conn . exists ( nodeId ) : false
17+
18+ let result
19+ if ( nodeExists ) {
20+ result = conn . modify ( {
21+ key : nodeId ,
22+ editor : ( node ) => ( {
23+ ...node ,
24+ ...params ,
25+ } ) ,
26+ } )
27+ } else {
28+ result = conn . create ( params )
29+ }
30+
31+ return {
32+ status : 200 ,
33+ body : result ,
34+ contentType : 'application/json' ,
35+ }
36+ }
Original file line number Diff line number Diff line change 1+ <service >
2+ <allow >
3+ <principal >role:system.everyone</principal >
4+ </allow >
5+ </service >
You can’t perform that action at this time.
0 commit comments