Skip to content

Commit

Permalink
chore: readme
Browse files Browse the repository at this point in the history
  • Loading branch information
jkuri committed Nov 6, 2016
1 parent c844fe1 commit 892835d
Show file tree
Hide file tree
Showing 4 changed files with 105 additions and 2 deletions.
21 changes: 21 additions & 0 deletions LICENCE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2016 Jan Kuri

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.
57 changes: 56 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,58 @@
# morose

Lightweight alternative for private npm registry.
Lightweight alternative for private npm registry heavily inspired by node-reggie.

morose is currently in development mode. It currently supports:

- registering/uploading packages
- supports basic semver wildcards (1.1.x) and ranges
- a few basic routes to see what's registered
- all packages info is saved in cache

Here's what it doesn't do yet:

- authentication on publish
- searching for packages

## Installation

```sh
$ npm install morose -g
```

## Usage

#### Running a Server

```sh
morose-server
```

#### Publishing package to registry

`cd` into package root directory you want to publish (should have package.json file) and:

```sh
morose publish [url:port]
```
where `url` is the HTTP url where `morose-server` is running. ie:

```sh
morose publish https://morose.example.com:4720
```

you can ofc omit port if morose server is running on port 80.

#### Installing package from morose server

```sh
npm install https://morose.example.com:4720/package/[package-name]/latest
```
or
```sh
npm install https://morose.example.com:4720/package/[package-name]/1.1.0
```

#### LICENCE

MIT
12 changes: 11 additions & 1 deletion lib/express.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import * as busboy from 'busboy';
import * as chalk from 'chalk';
import * as os from 'os';
import * as fs from 'fs';
import { savePackage, pkgVersions, getPkgData } from './package';
import { savePackage, pkgVersions, getPkgData, getPkgInfo } from './package';
import { writeFile, rand, prepareRootDirectory, getMoroseVersion } from './utils';
import { initCache } from './cache';
import * as semver from 'semver';
Expand Down Expand Up @@ -44,6 +44,7 @@ export class ExpressServer {
});
this.app.post('/package/:name/:version', this.publishVersion.bind(this));
this.app.get('/package/:name/:range', this.getPackage.bind(this));
this.app.get('/info/:name', this.getPackageInfo.bind(this));
}

private publishVersion(req: express.Request, res: express.Response) {
Expand Down Expand Up @@ -88,4 +89,13 @@ export class ExpressServer {
res.header('Content-Disposition', `filename=${path.basename(pkgData.file)}`);
res.status(200).download(pkgData.file);
}

private getPackageInfo(req: express.Request, res: express.Response) {
let pkgInfo = getPkgInfo(req.params.name);
if (!pkgInfo) {
res.status(404).send();
} else {
res.status(200).json(pkgInfo);
}
}
}
17 changes: 17 additions & 0 deletions lib/package.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,23 @@ export function publish(url: string): Observable<any> {
});
}

export function getPkgInfo(name: string): any {
let data = getCache();

if (!data[name]) {
return null;
}

return Object.keys(data[name]).map(version => {
let date = new Date(data[name][version].time);
return {
version: version,
time: data[name][version].time,
timeReleased: `${date.toDateString()}, ${date.toTimeString()}`
}
});
}

export function getPkgData(name: string, version: string): any {
let data = getCache();
return data[name][version];
Expand Down

0 comments on commit 892835d

Please sign in to comment.