Skip to content

Commit

Permalink
First!
Browse files Browse the repository at this point in the history
  • Loading branch information
aron committed Jun 22, 2021
0 parents commit 412425e
Show file tree
Hide file tree
Showing 17 changed files with 6,759 additions and 0 deletions.
64 changes: 64 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
{
"root": true,
"parser": "@typescript-eslint/parser",
"plugins": [
"@typescript-eslint"
],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended"
],
"env": {
"node": true,
"es6": true
},
"rules": {
"array-bracket-spacing": ["error", "always"],
"block-scoped-var": "error",
"brace-style": "error",
"camelcase": "error",
"comma-dangle": ["error", "always-multiline"],
"computed-property-spacing": ["error", "never"],
"curly": "error",
"eol-last": "error",
"eqeqeq": ["error", "smart"],
"indent": [
"error",
2,
{
"SwitchCase": 1
}
],
"keyword-spacing": ["error", {"before": true, "after": true}],
"max-depth": ["error", 5],
"max-len": ["error", 120],
"max-statements": ["error", 30],
"new-cap": "off",
"no-caller": "error",
"no-debugger": "error",
"no-else-return": "error",
"no-extend-native": "error",
"no-mixed-spaces-and-tabs": "error",
"no-trailing-spaces": "error",
"no-redeclare": "error",
"no-undef": "error",
"no-unused-vars": ["error", {"argsIgnorePattern": "next"}],
"no-use-before-define": ["error", "nofunc"],
"object-curly-spacing": ["error", "always"],
"object-shorthand": ["error", "always"],
"prefer-arrow-callback": "error",
"prefer-const": "error",
"quotes": ["error", "single", "avoid-escape"],
"semi": ["error", "always"],
"space-before-blocks": "error",
"space-before-function-paren": [
"error",
{
"anonymous": "ignore",
"named": "never"
}
],
"space-unary-ops": ["error", {"words": true, "nonwords": false}],
"spaced-comment": "error"
}
}
2 changes: 2 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# https://docs.github.com/en/github/creating-cloning-and-archiving-repositories/about-code-owners
* @snyk/plg @snyk/cloudconfig
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
12
9 changes: 9 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
The MIT License (MIT)

Copyright © 2021 <copyright holders>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
46 changes: 46 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# npm dependency server

A web server that provides a basic HTTP api for querying the dependency
tree of an [npm](https://npmjs.org) package.

## Prerequisites

* [Node v12 LTS](https://nodejs.org/download/release/latest-v12.x/)

## Getting Started

To install dependencies and start the server in development mode:

```sh
npm install
npm start
```

The server will now be running on an available port (defaulting to 3000) and
will restart on changes to the src files.

Then we can try the `/package` endpoint. Here is an example that uses `curl` and
`jq`, but feel free to use any client.

```sh
curl -s http://localhost:3000/package/react/16.13.0 | jq .
```

Most of the code is boilerplate; the logic for the `/package` endpoint can be
found in [src/package.ts](src/package.ts), and some basic tests in
[test/package.test.ts](test/package.test.ts)

You can run the tests with:

```sh
npm run test

# Or in watch mode
npm run test -- --watch
```

The code is linted via eslint, you can run this via:

```sh
npm run lint
```
9 changes: 9 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
globals: {
'ts-jest': {
tsConfig: '<rootDir>/test/tsconfig.json',
},
},
};
Loading

0 comments on commit 412425e

Please sign in to comment.