GithubHelp home page GithubHelp logo

dtinth / vscode-rest-code-lens Goto Github PK

View Code? Open in Web Editor NEW
5.0 1.0 0.0 224 KB

An advanced VS Code extension that calls HTTP endpoint when text matches a regular expression and displays the result as code lenses

TypeScript 100.00%
vscode-extension

vscode-rest-code-lens's Introduction

rest-lens README

An advanced VS Code extension that calls HTTP endpoint when text matches a regular expression and displays the result as code lenses.

Features

Easily build programmable code lenses using just a simple JSON endpoint.

Given the VS Code settings:

  "restLens.providers": {
    "github": {
      "pattern": "https://github\\.com/[^/]+/[^/]+/(?:issues|pull)/\\d+",
      "url": "http://localhost:2323/info"
    }
  }

…and an endpoint (example here implemented with Node.js):

const express = require('express')
const app = express()
const got = require('got')
const metascraper = require('metascraper')([require('metascraper-title')()])
app.get('/info', async (req, res, next) => {
  try {
    const targetUrl = req.query.m[0]
    const { body: html, url } = await got(targetUrl)
    const metadata = await metascraper({ html, url })
    res.json({ title: metadata.title || url, url: targetUrl })
  } catch (error) {
    next(error)
  }
})
app.listen(+process.env.PORT || 2323)

This will display GitHub Issue and Pull Request titles as code lenses.

Screenshot

Extension Settings

This extension contributes the following settings:

  • restLens.providers An object of code lens providers, keyed by its ID (can be arbitrary string and is only used for informational and diagnostics purposes). Each code lens provider will be an object with the following properties:

    • pattern The regular expression to match against the document.
    • url The URL to invoke

HTTP Endpoint Specification

Request

The extension will make a GET request to the specified URL with the RegExp match as GET query parameter named m[].

  • m[0] The matched text
  • m[n] The capture group matches

Response

It should return a JSON object with the following properties:

  • title The title to display on the code lens
  • url The URL to open when clicking on the code lens
  • command+arguments The VS Code command to execute when clicking on the code lens, overriding url

The response will be cached throughout the session until the "Clear response cache" command is invoked.

vscode-rest-code-lens's People

Contributors

dtinth avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

vscode-rest-code-lens's Issues

Status of the project

Hi, your extension caught my attention and I'd like to know the current status of the project. It doesn't seems really maintained lately and I couldn't find a licensing file to understand if it's fine to fork the project.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.