https://github.com/lucid-services/serviser-shell
User-defined shell commands for `serviser` based projects
https://github.com/lucid-services/serviser-shell
microservice nodejs shell-command
Last synced: 11 months ago
JSON representation
User-defined shell commands for `serviser` based projects
- Host: GitHub
- URL: https://github.com/lucid-services/serviser-shell
- Owner: lucid-services
- License: gpl-3.0
- Created: 2019-02-07T09:05:40.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2019-03-11T16:10:09.000Z (almost 7 years ago)
- Last Synced: 2025-02-14T22:24:02.030Z (about 1 year ago)
- Topics: microservice, nodejs, shell-command
- Language: JavaScript
- Homepage:
- Size: 85.9 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://travis-ci.org/lucid-services/serviser-shell)
Implementation of `serviser` `AppInterface`.
Create command line applications with `serviser` framework.
### Usage
Load the plugin at the bottom of your `index.js` file:
```javascript
require('serviser-shell'); //loads the plugin
```
Initialize a shell `App` in your `app.js` file:
```javascript
service.buildShellApp('your-app-name-in-config.json5');
```
##### An example command definition:
```javascript
const router = service.appManager
.get('your-app-name-in-config.json5')
.buildRouter({
version: 1,
url: ':'
});
const route = router.buildRoute({
url: 'upload',
summary: 'Upload image',
})
route.acceptsContentType('image/png');
route.validate({
properties: {
title: {
type: ['string'],
$desc: 'Image title'
}
}
}, 'params');
route.main(function(req, res) {
const remoteResource = new AmazonResource(req.params);
remoteResource.setEncoding('utf8');
req.pipe(remoteResource).pipe(res);
});
```
Now the above command will be available through the `serviser` executable:
```bash
project/root> ./node_modules/.bin/serviser
node_modules/.bin/serviser [options]
Commands:
run [options..] Starts serviser app - expects it to be located under cwd [aliases: start, serve]
get:config [key] Dumbs resolved service configuration
:upload Upload image
Options:
--help, -h Show help [boolean]
--config Custom config file destination [string]
--version Prints serviser version [boolean]
project/root>
project/root>
project/root> ./node_modules/.bin/serviser :upload --help
node_modules/.bin/serviser :upload
Options:
--help, -h Show help [boolean]
--config Custom config file destination [string]
--version Prints serviser version [boolean]
--title Image title [string]
project/root> cat ./dog.png | ./node_modules/.bin/serviser :upload --title Loky
https://cloudvendor.com/locky_dog.png
project/root>
```