{"id":13672808,"url":"https://github.com/sourcegraph/sourcegraph-typescript","last_synced_at":"2025-04-28T03:33:02.895Z","repository":{"id":33829010,"uuid":"155401150","full_name":"sourcegraph/sourcegraph-typescript","owner":"sourcegraph","description":"Provides code intelligence for TypeScript","archived":true,"fork":false,"pushed_at":"2022-06-07T08:26:08.000Z","size":2708,"stargazers_count":34,"open_issues_count":66,"forks_count":6,"subscribers_count":58,"default_branch":"master","last_synced_at":"2025-04-24T00:48:50.599Z","etag":null,"topics":["repo-type-codeintel"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sourcegraph.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null}},"created_at":"2018-10-30T14:39:02.000Z","updated_at":"2024-12-28T06:26:38.000Z","dependencies_parsed_at":"2022-07-24T18:01:59.473Z","dependency_job_id":null,"html_url":"https://github.com/sourcegraph/sourcegraph-typescript","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sourcegraph%2Fsourcegraph-typescript","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sourcegraph%2Fsourcegraph-typescript/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sourcegraph%2Fsourcegraph-typescript/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sourcegraph%2Fsourcegraph-typescript/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sourcegraph","download_url":"https://codeload.github.com/sourcegraph/sourcegraph-typescript/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251246394,"owners_count":21558762,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["repo-type-codeintel"],"created_at":"2024-08-02T09:01:49.375Z","updated_at":"2025-04-28T03:32:57.884Z","avatar_url":"https://github.com/sourcegraph.png","language":"TypeScript","readme":"This repository has been superseded by [scip-typescript](https://github.com/sourcegraph/scip-typescript).\n\nUsing this code is not supported.\n\n---\n\n# Language server for TypeScript/JavaScript\n\n[![Build status](https://badge.buildkite.com/6399fffb5ec930dde31cf654b2cd694b56f2233345e2bc0db4.svg?branch=master)](https://buildkite.com/sourcegraph/sourcegraph-typescript)\n\nThis is a backend for the [Sourcegraph TypeScript extension](https://github.com/sourcegraph/code-intel-extensions/tree/master/extensions/typescript),\nspeaking the [Language Server Protocol](https://github.com/Microsoft/language-server-protocol) over WebSockets.\n\nIt supports editor features such as go-to-definition, hover, and find-references for TypeScript and JavaScript projects,\nincluding support for dependencies and cross-repository code intelligence.\n\nMonitoring is available through OpenTracing (Jaeger) and Prometheus.\n\n## How it works\n\nCheck out [@felixfbecker](https://github.com/felixfecker)'s talk at FOSDEM for an overview \u0026 deep dive of the architecture:\n\n\u003cp\u003e\n  \u003ca href=\"https://vimeo.com/327174558\" title=\"Talk Recording: Advanced TypeScript Tooling at Scale\"\u003e\n    \u003cimg\n      alt=\"Talk Recording: Advanced TypeScript Tooling at Scale\"\n      src=\"https://i.vimeocdn.com/filter/overlay?src0=https%3A%2F%2Fi.vimeocdn.com%2Fvideo%2F771375540_960.jpg\u0026src1=http%3A%2F%2Ff.vimeocdn.com%2Fp%2Fimages%2Fcrawler_play.png\"\n      width=\"480\"\n    /\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\nTopics covered:\n\n- Basic features\n- LSP WebSocket architecture\n- Repository contents through the Sourcegraph raw HTTP API\n- Cross-repository Go-to-Definition\n- Cross-repository Find-References\n\n## Deployment\n\nThe server is available as a Docker image `sourcegraph/lang-typescript` from Docker Hub.\n\n### 🔐 Secure deployment 🔐\n\nIf you have private code, we recommend deploying the language server behind an\nauth proxy (such as the example below using HTTP basic authentication in NGINX), a firewall, or a VPN.\n\n### HTTP basic authentication\n\nYou can prevent unauthorized access to the language server by enforcing HTTP basic authentication in nginx, which comes with the sourcegraph/server image. At a high level, you'll create a secret then put it in both the nginx config and in your Sourcegraph global settings so that logged-in users are authenticated when their browser makes requests to the TypeScript language server.\n\nHere's how to set it up:\n\nCreate an `.htpasswd` file in the Sourcegraph config directory with one entry:\n\n```\n$ htpasswd -c ~/.sourcegraph/config/.htpasswd langserveruser\nNew password:\nRe-type new password:\nAdding password for user langserveruser\n```\n\nAdd a location directive the [nginx.conf](https://docs.sourcegraph.com/admin/nginx) that will route requests to the TypeScript language server:\n\n```nginx\n...\nhttp {\n    ...\n    server {\n        ...\n        location / {\n            ...\n        }\n\n        location /typescript {\n            proxy_pass http://host.docker.internal:8080;\n            proxy_http_version 1.1;\n            proxy_set_header Upgrade $http_upgrade;\n            proxy_set_header Connection \"Upgrade\";\n\n            auth_basic \"basic authentication is required to access the language server\";\n            auth_basic_user_file /etc/sourcegraph/.htpasswd;\n        }\n    }\n}\n```\n\n- If you're running the quickstart on Linux, change `host.docker.internal` to the output of `ip addr show docker0 | grep -Po 'inet \\K[\\d.]+'`.\n- If you're using [Kubernetes](#using-kubernetes) (e.g. [deploy-sourcegraph](https://github.com/sourcegraph/deploy-sourcegraph)), change `host.docker.internal` to `lang-typescript`.\n\nRestart the sourcegraph/server container (or nginx deployment if deployed to Kubernetes) to pick up the configuration change.\n\nAfter deploying the language server, unauthenticated access to `http://localhost:7080/typescript` (or https://sourcegraph.example.com/typescript) should be blocked, but code intelligence should work when you're logged in.\n\nYou can always revoke the `PASSWORD` by deleting the `.htpasswd` file and restarting nginx.\n\n### Using Docker\n\nRun the server:\n\n```sh\ndocker run -p 8080:8080 sourcegraph/lang-typescript\n```\n\nYou can verify it's up and running with [`ws`](https://github.com/hashrocket/ws):\n\n```sh\n$ go get -u github.com/hashrocket/ws\n$ ws ws://localhost:8080\n\u003e\n```\n\n#### TLS in Docker\n\nTo enable the use of Websocket with SSL pass the key/certificate pair as environment variables to the docker container.\n\n```\ndocker run -p 8080:8080 -e TLS_KEY=\"$(cat sourcegraph.example.com.key)\" -e TLS_CERT=\"$(cat sourcegraph.example.com.crt)\" sourcegraph/lang-typescript\n```\n\nTo reuse the self-signed certificate created by following the steps [here](https://docs.sourcegraph.com/admin/nginx#tls-https) add these parameters to the run command above:\n\n```\n-e NODE_EXTRA_CA_CERTS=/home/node/sourcegraph.example.com.crt -v ~/.sourcegraph/config:/home/node\n```\n\nThe self signed certificate's `Common Name (CN)` should be the host name of your host. Also make sure you use Websocket with SSL in your Sourcegraph settings to connect to the language server:\n\n```json\n\"typescript.serverUrl\": \"wss://localhost:8080\"\n```\n\n### Authentication proxies and firewalls\n\nSome customers deploy Sourcegraph behind an authentication proxy or firewall. If you do this, we\nrecommend deploying the language server behind the proxy so that it can issue requests directly to\nSourcegraph without going through the proxy. (Otherwise, you will need to configure the language\nserver to authenticate through your proxy.) Make sure you set `typescript.sourcegraphUrl` to the URL\nthat the language server should use to reach Sourcegraph, which is likely different from the URL\nthat end users use.\n\n### Using Kubernetes\n\nTo deploy the language server with Kubernetes, use a deployment like this:\n\n```yaml\napiVersion: apps/v1\nkind: Deployment\nmetadata:\n  name: lang-typescript\nspec:\n  replicas: 4 # adjust as needed\n  selector:\n    matchLabels:\n      app: lang-typescript\n  template:\n    metadata:\n      labels:\n        app: lang-typescript\n    spec:\n      containers:\n        - name: lang-typescript\n          image: sourcegraph/lang-typescript\n          ports:\n            - containerPort: 8080\n              name: wss\n          env:\n            # TLS certificate and key to secure the WebSocket connection (optional)\n            - name: TLS_CERT\n              value: ... your TLS certificate ...\n            - name: TLS_KEY\n              value: ... your TLS key ...\n          # Resources to provision for the server (adjust as needed)\n          resources:\n            limits:\n              cpu: '4'\n              memory: 5Gi\n            requests:\n              cpu: 500m\n              memory: 2Gi\n          # Probes the server periodically to see if it is healthy\n          livenessProbe:\n            initialDelaySeconds: 30\n            tcpSocket:\n              port: wss\n            timeoutSeconds: 5\n          readinessProbe:\n            tcpSocket:\n              port: wss\n```\n\nWith a corresponding service:\n\n```yaml\napiVersion: v1\nkind: Service\nmetadata:\n  labels:\n    app: lang-typescript\n    deploy: lang-typescript\n  name: lang-typescript\nspec:\n  ports:\n    - name: wss\n      port: 443\n      targetPort: wss\n  selector:\n    app: lang-typescript\n  type: LoadBalancer\n```\n\n#### TLS\n\nTo enable TLS, set the `TLS_KEY` and `TLS_CERT` environment variables. TLS optional but **strongly recommended** for production deployments.\n\n#### Enabling OpenTracing\n\nThe server can report spans through OpenTracing to diagnose issues.\nIf the environment variable `JAEGER_DISABLED` is not set,\nthe server will send tracing data to a Jaeger agent (by default `localhost:6832`).\n\nTracing can be further configured through [environment variables](https://github.com/jaegertracing/jaeger-client-node#environment-variables). Example:\n\n```diff\n  env:\n+   - name: JAEGER_AGENT_HOST\n+     value: my-jaeger-agent\n```\n\n#### Enabling Prometheus metrics\n\nThe server exposes metrics on port 6060 that can be scraped by Prometheus.\n\n#### Improving performance with an SSD\n\nTo improve performance of dependency installation, the server can be configured to use a mounted SSD at a given directory by setting the `CACHE_DIR` environment variable. The instructions for how to mount a SSD depend on your deployment environment.\n\n1. Add a volume for the mount path of the SSD:\n\n   ```diff\n     spec:\n   + volumes:\n   +   - hostPath:\n   +       path: /path/to/mounted/ssd\n   +     name: cache-ssd\n   ```\n\n   For example, Google Cloud Platform mounts the first SSD disk to `/mnt/disks/ssd0`.\n\n2. Add a volume mount to the container spec:\n\n   ```diff\n     image: sourcegraph/lang-typescript\n   + volumeMounts:\n   +   - mountPath: /mnt/cache\n   +     name: cache-ssd\n   ```\n\n3. Tell the language server to use the mount as the root for temporary directories:\n\n   ```diff\n     env:\n   +   - name: CACHE_DIR\n   +     value: /mnt/cache\n   ```\n\n#### Improving performance with an npm registry proxy\n\nTo further speed up dependency installation, all npm registry requests can be proxied through a cache running on the same node.\n\nExample deployment for Kubernetes:\n\n```yaml\napiVersion: apps/v1\nkind: Deployment\nmetadata:\n  name: npm-proxy\nspec:\n  minReadySeconds: 10\n  replicas: 1\n  revisionHistoryLimit: 10\n  strategy:\n    rollingUpdate:\n      maxSurge: 1\n      maxUnavailable: 1\n    type: RollingUpdate\n  template:\n    metadata:\n      labels:\n        app: npm-proxy\n    spec:\n      containers:\n        - image: sourcegraph/npm-proxy:latest\n          name: npm-proxy\n          ports:\n            - containerPort: 8080\n              name: http\n          resources:\n            limits:\n              cpu: '1'\n              memory: 1Gi\n          volumeMounts:\n            - mountPath: /cache\n              name: npm-proxy-cache\n      volumes:\n        - name: npm-proxy-cache\n          persistentVolumeClaim:\n            claimName: npm-proxy\n---\napiVersion: v1\nkind: PersistentVolumeClaim\nmetadata:\n  annotations:\n    volume.beta.kubernetes.io/storage-class: default\n  name: npm-proxy\nspec:\n  accessModes:\n    - ReadWriteOnce\n  resources:\n    requests:\n      storage: 100Gi\n---\napiVersion: v1\nkind: Service\nmetadata:\n  labels:\n    app: npm-proxy\n  name: npm-proxy\nspec:\n  ports:\n    - name: http\n      port: 8080\n      targetPort: http\n  selector:\n    app: npm-proxy\n  type: ClusterIP\n```\n\nThen define a `.yarnrc` as a config map that points to the proxy:\n\n```yaml\napiVersion: v1\ndata:\n  .yarnrc: |\n    # THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.\n    # yarn lockfile v1\n\n\n    https-proxy \"http://npm-proxy:8080\"\n    proxy \"http://npm-proxy:8080\"\n    strict-ssl false\nkind: ConfigMap\nmetadata:\n  name: yarn-config\n```\n\nand mount it into the container:\n\n```diff\n  name: lang-typescript\n+ volumeMounts:\n+  - mountPath: /yarn-config\n+    name: yarn-config\n```\n\n```diff\n  spec:\n+   volumes:\n+     - configMap:\n+         name: yarn-config\n+       name: yarn-config\n```\n\n## Support for dependencies on private packages and git repositories\n\nDependencies on private npm packages and private registries is supported by setting the `typescript.npmrc` setting.\nIt contains the same key/value settings as your `.npmrc` file in your home folder, and therefor supports the same scoping to registries and package scopes.\nSee https://docs.npmjs.com/misc/config#config-settings for more information on what is possible to configure in `.npmrc`.\n\nExample:\n\n```json\n\"typescript.npmrc\": {\n  \"//registry.npmjs.org/:_authToken\": \"asfdh21e-1234-asdn-123v-1234asdb2\"\n}\n```\n\nFor dependencies on private git repositories, mount an SSH key into `~/.ssh`.\n\n## Contributing\n\nYou need NodeJS \u003e=11.1.0 and yarn installed.\n\n```sh\n# Install dependencies\nyarn\n# Build the extension and the server\nyarn run build\n```\n","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsourcegraph%2Fsourcegraph-typescript","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsourcegraph%2Fsourcegraph-typescript","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsourcegraph%2Fsourcegraph-typescript/lists"}