dev.12: R105 fixes

a massive diff due to infrastructure work
the completion pane moved to the left of chat
no other intended changes for users
This commit is contained in:
2024-06-29 17:09:25 +00:00
parent b0961f4fb8
commit 90231cb2ae
6 changed files with 1633 additions and 1202 deletions

View File

@@ -1,35 +1,33 @@
import {readFileSync} from 'node:fs'
import {createServer} from 'node:http'
function stamp_cors(rx) {
rx.setHeader('Access-Control-Max-Age', '86400')
rx.setHeader('Access-Control-Allow-Private-Network', 'true')
rx.setHeader('Access-Control-Allow-Origin', '*')
rx.setHeader('Access-Control-Allow-Methods', 'GET, OPTIONS')
rx.setHeader('Access-Control-Allow-Headers', '*')
// rx.setHeader('Access-Control-Allow-Credentials', 'false') // omit this header to disallow
const config = {host: '127.0.0.1', port: 9696}
const h_cors = {
'Access-Control-Max-Age': '86400',
'Access-Control-Allow-Private-Network': 'true',
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Methods': 'GET, OPTIONS',
'Access-Control-Allow-Headers': '*',
// 'Access-Control-Allow-Credentials': 'false', // omit this header to disallow
}
const h_all = Object.assign({
'Content-Type': 'text/javascript',
'Cache-Control': 'no-cache',
}, h_cors)
/**
* @typedef {import('node:http').ServerResponse} ServerResponse
* @type {Record<string,function(ServerResponse):void>}
*/
const resp = {
GET(rx) { rx.writeHead(200, h_all); rx.write(readFileSync('./mbchc.mjs')) },
OPTIONS(rx) { rx.writeHead(204, h_cors) },
}
const server = createServer((rq, rx) => {
switch (rq.method) {
case 'GET': {
rx.statusCode = 200
stamp_cors(rx)
rx.setHeader('Content-Type', 'text/javascript')
rx.setHeader('Cache-Control', 'no-cache')
const data = readFileSync('./mbchc.mjs')
rx.write(data)
break
}
case 'OPTIONS': {
rx.statusCode = 204
stamp_cors(rx)
break
}
default: {
rx.statusCode = 400
}
}
resp[rq.method] && (new URL(`http://${config.host}:${config.port}${rq.url}`)).pathname === '/' ? resp[rq.method](rx) : rx.writeHead(400)
rx.end()
console.log('%s %d %s %s', (new Date()).toISOString(), rx.statusCode, rq.method, rq.url)
})
server.listen(9696, '127.0.0.1', () => console.log('Server started.'))
server.listen(config.port, config.host, () => console.log(`Server started at http://${config.host}:${config.port}`))