forked from TypeFox/monaco-languageclient
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.ts
40 lines (38 loc) · 1.58 KB
/
main.ts
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
39
40
/* --------------------------------------------------------------------------------------------
* Copyright (c) 2024 TypeFox GmbH (http://www.typefox.io). All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
* ------------------------------------------------------------------------------------------ */
import { resolve } from 'path';
import { runLanguageServer } from '../../common/language-server-runner.js';
import { IncomingMessage } from 'http';
import { LanguageName } from '../../common/server-commons.js';
export const runPythonServer = (baseDir: string, relativeDir: string) => {
const processRunPath = resolve(baseDir, relativeDir);
runLanguageServer({
serverName: 'PYRIGHT',
pathName: '/pyright',
serverPort: 30001,
runCommand: LanguageName.node,
runCommandArgs: [
processRunPath,
'--stdio'
],
wsServerOptions: {
noServer: true,
perMessageDeflate: false,
clientTracking: true,
verifyClient: (
clientInfo: { origin: string; secure: boolean; req: IncomingMessage },
callback
) => {
const parsedURL = new URL(`${clientInfo.origin}${clientInfo.req?.url ?? ''}`);
const authToken = parsedURL.searchParams.get('authorization');
if (authToken === 'UserAuth') {
callback(true);
} else {
callback(false);
}
}
}
});
};