MCPcopy Index your code
hub / github.com/imcuttle/mometa / handlerHttp

Function handlerHttp

packages/editor/webpack/create-server.js:121–155  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

119 }
120
121 const handlerHttp = async () => {
122 try {
123 if (req.method.toUpperCase() === 'POST') {
124 switch (stripPrefix(baseURL, req.url)) {
125 case '/submit-op': {
126 const body = await json(req)
127 if (!body.preload.filename) {
128 throw new Error('Requires preload.filename')
129 }
130 body.preload.filename = nps.resolve(context, body.preload.filename)
131 await fsHandler(body)
132 res.statusCode = 200
133 res.write('true')
134 return
135 }
136
137 case '/open-editor': {
138 const body = await json(req)
139 const fileName = nps.resolve(context, body.fileName)
140 await launchEditor(fileName, body.lineNumber, body.colNumber)
141 res.statusCode = 200
142 res.write('true')
143 return
144 }
145 }
146 }
147 res.statusCode = 404
148 } catch (err) {
149 console.error('[MMS]', err)
150 res.statusCode = 501
151 res.write(JSON.stringify({ error: String(err) }))
152 } finally {
153 res.end()
154 }
155 }
156
157 if (req.method.toUpperCase() === 'GET') {
158 switch (stripPrefix(baseURL, req.url)) {

Callers 1

create-server.jsFile · 0.85

Calls 3

stripPrefixFunction · 0.85
jsonFunction · 0.85
launchEditorFunction · 0.85

Tested by

no test coverage detected