-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added tests for Alias class * Added tests for HttpIncoming class * Add tests for HttpOutgoing class * Added tests for Meta class * Added version overview
- Loading branch information
1 parent
af328b8
commit 9505b4a
Showing
18 changed files
with
696 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -66,7 +66,7 @@ Status codes: | |
- `303` if module is successfully uploaded. `location` is root of module | ||
- `400` if validation in URL parameters or form fields fails | ||
- `401` if user is not authorized | ||
- `409` if module already exist | ||
- `409` if module already exist or version in a major range is not newer than previous version in a major range | ||
- `415` if file format of the uploaded file is unsupported | ||
- `502` if package could not be written to the sink | ||
|
||
|
@@ -76,6 +76,58 @@ Example: | |
curl -X PUT -i -F [email protected] http://localhost:4001/finn/pkg/fuzz/8.4.1 | ||
``` | ||
|
||
### Latest Package versions | ||
|
||
**Method:** `GET` | ||
|
||
Retrieves an overview of the latest major versions of a package. | ||
|
||
```bash | ||
https://:assetServerUrl:port/:org/pkg/:name | ||
``` | ||
|
||
URL parameters: | ||
|
||
- `:org` is the name of your organisation. Validator: [`^[a-zA-Z0-9_-]+$`](https://regexper.com/#%5E%5Ba-zA-Z0-9_-%5D%2B%24). | ||
- `:name` is the name of the package. Validator: Comply with [npm package names](https://github.com/npm/validate-npm-package-name). | ||
|
||
Status codes: | ||
|
||
- `200` if file is successfully retrieved | ||
- `404` if file is not found | ||
|
||
Example: | ||
|
||
```bash | ||
curl -X GET http://localhost:4001/finn/pkg/fuzz | ||
``` | ||
|
||
### Package version overview | ||
|
||
**Method:** `GET` | ||
|
||
Retrieves an overview of the files of a package version. | ||
|
||
```bash | ||
https://:assetServerUrl:port/:org/pkg/:name/:version | ||
``` | ||
|
||
URL parameters: | ||
|
||
- `:org` is the name of your organisation. Validator: [`^[a-zA-Z0-9_-]+$`](https://regexper.com/#%5E%5Ba-zA-Z0-9_-%5D%2B%24). | ||
- `:name` is the name of the package. Validator: Comply with [npm package names](https://github.com/npm/validate-npm-package-name). | ||
- `:version` is the version of the package. Validator: Comply with [semver validation regex](https://semver.org/). | ||
|
||
Status codes: | ||
|
||
- `200` if file is successfully retrieved | ||
- `404` if file is not found | ||
|
||
Example: | ||
|
||
```bash | ||
curl -X GET http://localhost:4001/finn/pkg/fuzz | ||
``` | ||
|
||
## Import Maps | ||
|
||
|
@@ -151,6 +203,31 @@ Example: | |
curl -X PUT -i -F [email protected] http://localhost:4001/finn/map/buzz/8.4.1 | ||
``` | ||
|
||
### Latest Import Map versions | ||
|
||
**Method:** `GET` | ||
|
||
Retrieves an overview of the latest versions of a Import Map. | ||
|
||
```bash | ||
https://:assetServerUrl:port/:org/map/:name | ||
``` | ||
|
||
URL parameters: | ||
|
||
- `:org` is the name of your organisation. Validator: [`^[a-zA-Z0-9_-]+$`](https://regexper.com/#%5E%5Ba-zA-Z0-9_-%5D%2B%24). | ||
- `:name` is the name of the import map. Validator: Comply with [npm package names](https://github.com/npm/validate-npm-package-name). | ||
|
||
Status codes: | ||
|
||
- `200` if file is successfully retrieved | ||
- `404` if file is not found | ||
|
||
Example: | ||
|
||
```bash | ||
curl -X GET http://localhost:4001/finn/map/buzz | ||
``` | ||
|
||
## Aliases | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
'use strict'; | ||
|
||
const Meta = class Meta { | ||
construct({ | ||
constructor({ | ||
value = '', | ||
name = '', | ||
} = {}) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
'use strict'; | ||
|
||
const semver = require('semver'); | ||
|
||
const Versions = class Versions { | ||
constructor({ versions = [], name = '', org = '' } = {}) { | ||
this._versions = new Map(versions); | ||
this._name = name; | ||
this._org = org; | ||
} | ||
|
||
get versions() { | ||
return Array.from(this._versions.entries()).sort((a, b) => { | ||
return a[0] > b[0] ? -1 : 1; | ||
}); | ||
} | ||
|
||
get name() { | ||
return this._name; | ||
} | ||
|
||
get org() { | ||
return this._org; | ||
} | ||
|
||
setVersion(version, integrity) { | ||
if (!this.check(version)) { | ||
throw new Error('Semver version is lower than previous version'); | ||
} | ||
const major = semver.major(version); | ||
this._versions.set(major, { | ||
version, | ||
integrity, | ||
}); | ||
} | ||
|
||
getVersion(major) { | ||
return this._versions.get(major); | ||
} | ||
|
||
check(version) { | ||
const major = semver.major(version); | ||
const previous = this.getVersion(major); | ||
if (previous) { | ||
if (semver.gte(previous.version, version)) { | ||
return false; | ||
} | ||
} | ||
return true; | ||
} | ||
|
||
toJSON() { | ||
return { | ||
versions: this.versions, | ||
name: this.name, | ||
org: this.org, | ||
}; | ||
} | ||
|
||
get [Symbol.toStringTag]() { | ||
return 'Versions'; | ||
} | ||
} | ||
module.exports = Versions; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.