• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

scriptype / writ-cms / 27473969531

13 Jun 2026 05:32PM UTC coverage: 58.928% (-0.8%) from 59.747%
27473969531

push

github

scriptype
Implement basic content edit

// TODO: Rename node folder name if title changes, instead of just
overriding title in front-matter

644 of 1062 branches covered (60.64%)

Branch coverage included in aggregate %.

0 of 41 new or added lines in 6 files covered. (0.0%)

2 existing lines in 2 files now uncovered.

2237 of 3827 relevant lines covered (58.45%)

1134.33 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/cms/server/public/api.js
1
const makeQueryString = (params) => {
×
2
  const query = new URLSearchParams()
×
3
  for (let key in params) {
×
4
    if (params.hasOwnProperty(key)) {
×
5
      query.append(key, encodeURI(params[key]))
×
6
    }
7
  }
8
  return query.toString()
×
9
}
10

11
const api = {
×
12
  ssg: {
13
    build: async (options) => {
14
      const response = await fetch('/api/ssg/build', {
×
15
        method: 'post',
16
        headers: {
17
          'content-type': 'application/json'
18
        },
19
        body: JSON.stringify(options)
20
      })
21
      return response.text()
×
22
    },
23

24
    watch: async (options) => {
25
      const response = await fetch('/api/ssg/watch', {
×
26
        method: 'post',
27
        headers: {
28
          'content-type': 'application/json'
29
        },
30
        body: JSON.stringify(options)
31
      })
32
      return response.text()
×
33
    },
34

35
    stopWatcher: async () => {
36
      const response = await fetch('/api/ssg/stop-watcher', {
×
37
        method: 'post'
38
      })
39
      return response.text()
×
40
    }
41

42
  },
43

44
  ssgOptions: {
45
    get: async () => {
46
      const response = await fetch('/api/ssgOptions', {
×
47
        method: 'get',
48
        headers: {
49
          'content-type': 'application/json'
50
        }
51
      })
52
      return response.json()
×
53
    }
54
  },
55

56
  workspace: {
57
    get: async () => {
58
      const response = await fetch('/api/workspace', {
×
59
        method: 'get',
60
        headers: {
61
          'content-type': 'application/json'
62
        }
63
      })
64
      return response.json()
×
65
    },
66

67
    create: async () => {
68
      const response = await fetch('/api/workspace', {
×
69
        method: 'post',
70
        headers: {
71
          'content-type': 'application/json'
72
        }
73
      })
74
      return response.json()
×
75
    },
76

77
    createProject: async (options) => {
78
      const response = await fetch('/api/workspace/project', {
×
79
        method: 'post',
80
        headers: {
81
          'content-type': 'application/json'
82
        },
83
        body: JSON.stringify(options)
84
      })
85
      return response.json()
×
86
    }
87
  },
88

89
  settings: {
90
    get: async () => {
91
      const response = await fetch('/api/settings', {
×
92
        method: 'get',
93
        headers: {
94
          'content-type': 'application/json'
95
        }
96
      })
97
      return response.json()
×
98
    },
99

100
    update: async (options) => {
101
      const response = await fetch('/api/settings', {
×
102
        method: 'post',
103
        headers: {
104
          'content-type': 'application/json'
105
        },
106
        body: JSON.stringify(options)
107
      })
108
      return response.json()
×
109
    }
110
  },
111

112
  contentTypes: {
113
    get: async () => {
114
      const response = await fetch('/api/contentTypes', {
×
115
        method: 'get',
116
        headers: {
117
          'content-type': 'application/json'
118
        }
119
      })
120
      return response.json()
×
121
    },
122

123
    create: async (options) => {
124
      const response = await fetch('/api/contentTypes', {
×
125
        method: 'post',
126
        headers: {
127
          'content-type': 'application/json'
128
        },
129
        body: JSON.stringify(options)
130
      })
131
      return response.json()
×
132
    }
133
  },
134

135
  contentModel: {
136
    get: async () => {
137
      const response = await fetch('/api/contentModel', {
×
138
        method: 'get',
139
        headers: {
140
          'content-type': 'application/json'
141
        }
142
      })
143
      return response.json()
×
144
    }
145
  },
146

147
  fileSystemTree: {
148
    get: async () => {
149
      const response = await fetch('/api/fileSystemTree', {
×
150
        method: 'get',
151
        headers: {
152
          'content-type': 'application/json'
153
        }
154
      })
155
      return response.json()
×
156
    }
157
  },
158

159
  collections: {
160
    get: async () => {
161
      const response = await fetch('/api/collections', {
×
162
        method: 'get',
163
        headers: {
164
          'content-type': 'application/json'
165
        }
166
      })
167
      return response.json()
×
168
    },
169

170
    create: async (options) => {
171
      const response = await fetch('/api/collections', {
×
172
        method: 'put',
173
        headers: {
174
          'content-type': 'application/json'
175
        },
176
        body: JSON.stringify(options)
177
      })
178
      return response.text()
×
179
    }
180
  },
181

182
  category: {
183
    create: async (options) => {
184
      const response = await fetch('/api/category', {
×
185
        method: 'put',
186
        headers: {
187
          'content-type': 'application/json'
188
        },
189
        body: JSON.stringify(options)
190
      })
191
      return response.text()
×
192
    }
193
  },
194

195
  post: {
196
    create: async (options) => {
NEW
197
      const response = await fetch('/api/post', {
×
198
        method: 'post',
199
        headers: {
200
          'content-type': 'application/json'
201
        },
202
        body: JSON.stringify(options)
203
      })
NEW
204
      return response.text()
×
205
    },
206

207
    edit: async (options) => {
UNCOV
208
      const response = await fetch('/api/post', {
×
209
        method: 'put',
210
        headers: {
211
          'content-type': 'application/json'
212
        },
213
        body: JSON.stringify(options)
214
      })
215
      return response.text()
×
216
    }
217
  },
218

219
  homepage: {
220
    get: async () => {
221
      const response = await fetch('/api/homepage', {
×
222
        method: 'get',
223
        headers: {
224
          'content-type': 'application/json'
225
        }
226
      })
227
      return response.json()
×
228
    },
229

230
    create: async (options) => {
231
      const response = await fetch('/api/homepage', {
×
232
        method: 'put',
233
        headers: {
234
          'content-type': 'application/json'
235
        },
236
        body: JSON.stringify(options)
237
      })
238
      return response.text()
×
239
    }
240
  },
241

242
  subpage: {
243
    get: async (options) => {
244
      const query = makeQueryString(options)
×
245
      const queryString = query ? `?${query}` : ''
×
246
      const response = await fetch(`/api/subpage/${queryString}`, {
×
247
        method: 'get',
248
        headers: {
249
          'content-type': 'application/json'
250
        }
251
      })
252
      return response.json()
×
253
    },
254

255
    create: async (options) => {
256
      const response = await fetch('/api/subpage', {
×
257
        method: 'put',
258
        headers: {
259
          'content-type': 'application/json'
260
        },
261
        body: JSON.stringify(options)
262
      })
263
      return response.text()
×
264
    }
265
  },
266

267
  subpages: {
268
    get: async () => {
269
      const response = await fetch('/api/subpages', {
×
270
        method: 'get',
271
        headers: {
272
          'content-type': 'application/json'
273
        }
274
      })
275
      return response.json()
×
276
    }
277
  }
278
}
279

280
export default api
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc