rhases-nodejs-commons
Advanced tools
Comparing version 0.1.0 to 0.1.1
{ | ||
"name": "rhases-nodejs-commons", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "Node.js utilities", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -1,29 +0,42 @@ | ||
# Example Typescript 2.x Library | ||
# Node.js Utilities | ||
Simple starter library from June 2017. | ||
Tutorial can be found at | ||
[how-to-write-a-typescript-library.com](http://how-to-write-a-typescript-library.com). | ||
## Installation | ||
Or just browse the code here! Or clone the repo. | ||
Using npm: | ||
```shell | ||
$ npm i --save rhases-nodejs-commons | ||
``` | ||
# Usage | ||
## Using | ||
### Pino Log | ||
```js | ||
import l from 'rhases-nodejs-commons'; | ||
l.error(err); | ||
l.info("foo", foo); | ||
``` | ||
git clone https://github.com/bersling/typescript-library-starter.git | ||
``` | ||
### Service Utils | ||
then modify whatever you want, then | ||
```js | ||
import {ServiceUtils} from 'rhases-nodejs-commons'; | ||
serviceUtils = new ServiceUtils(MyMongooseModel); | ||
all() { | ||
return this.serviceUtils.all(); | ||
} | ||
``` | ||
tsc | ||
``` | ||
### Controller Utils | ||
You can check if everything is working like this: | ||
http://how-to-write-a-typescript-library.com/local-consumer | ||
```js | ||
import {ControllerUtils} from 'rhases-nodejs-commons'; | ||
You can write a test like this: | ||
http://how-to-write-a-typescript-library.com/unit-testing | ||
controllerUtils = new ControllerUtils(MyService); | ||
And once you're ready, simply change the `name` in the `package.json` | ||
and publish your brand new cool library. Have fun! | ||
byId(req, res) { | ||
this.controllerUtils.byId(req, res); | ||
} | ||
``` | ||
43
10239