Skip to content

Commit

Permalink
Updated docs
Browse files Browse the repository at this point in the history
  • Loading branch information
IonicaBizau committed Feb 12, 2018
1 parent 80470e5 commit a7f1682
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 10 deletions.
4 changes: 4 additions & 0 deletions DOCUMENTATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,10 @@ It emits the following events:

- `logErrors` (Boolean): Log the server errors (default: `true`).
- `csrf` (Object): The CSRF options. These are passed to [`csurf`](https://github.com/expressjs/csurf)
- `bodyParserJson` (Boolean): Whether to enable the JSON body parser (default: `true`)
- `bodyParserUrlEncoded` (Boolean): Whether to enable the URL encoded body parser (default: `true`)
- `cookieParser` (Boolean): Whether to enable the cookie parser (default: `true`)
- `transformers` (Boolean): Whether to enable the transformers (default: `true`)

#### Return
- **Object** The Lien instance.
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2014-17 Ionică Bizău <[email protected]> (https://ionicabizau.net/)
Copyright (c) 2014-18 Ionică Bizău <[email protected]> (https://ionicabizau.net/)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
61 changes: 53 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
<!-- Please do not edit this file. Edit the `blah` field in the `package.json` instead. If in doubt, open an issue. -->


[![lien](https://raw.githubusercontent.com/LienJS/Resources/master/logo/header.png)](#)

# lien

[![Support me on Patreon][badge_patreon]][patreon] [![Buy me a book][badge_amazon]][amazon] [![PayPal][badge_paypal_donate]][paypal-donations] [![Travis](https://img.shields.io/travis/LienJS/Lien.svg)](https://travis-ci.org/LienJS/Lien/) [![Version](https://img.shields.io/npm/v/lien.svg)](https://www.npmjs.com/package/lien) [![Downloads](https://img.shields.io/npm/dt/lien.svg)](https://www.npmjs.com/package/lien)
[![Support me on Patreon][badge_patreon]][patreon] [![Buy me a book][badge_amazon]][amazon] [![PayPal][badge_paypal_donate]][paypal-donations] [![Ask me anything](https://img.shields.io/badge/ask%20me-anything-1abc9c.svg)](https://github.com/IonicaBizau/ama) [![Travis](https://img.shields.io/travis/LienJS/Lien.svg)](https://travis-ci.org/LienJS/Lien/) [![Version](https://img.shields.io/npm/v/lien.svg)](https://www.npmjs.com/package/lien) [![Downloads](https://img.shields.io/npm/dt/lien.svg)](https://www.npmjs.com/package/lien)

> An easy to use web framework for Node.js.
## :cloud: Installation

```sh
$ npm i --save lien
# Using npm
npm install --save lien

# Using yarn
yarn add lien
```


Expand Down Expand Up @@ -52,13 +58,17 @@ server.on("serverError", err => {
});
```



## :question: Get Help

There are few ways to get help:

1. Please [post questions on Stack Overflow](https://stackoverflow.com/questions/ask). You can open issues with questions, as long you add a link to your Stack Overflow question.
2. For bug reports and feature requests, open issues. :bug:
3. For direct and quick help from me, you can [use Codementor](https://www.codementor.io/johnnyb). :rocket:

3. For direct and quick help, you can [use Codementor](https://www.codementor.io/johnnyb). :rocket:



## :memo: Documentation
Expand All @@ -68,6 +78,7 @@ There are few ways to get help:
Creates the `lien` object.

#### Params

- **Object** `req`: The request object.
- **Object** `res`: The response object.
- **Function** `next`: The `next` middleware function.
Expand All @@ -86,32 +97,37 @@ Go to the next middleware handler.
Redirects the client to another url.

#### Params

- **String** `newUrl`: The new url to redirect to.
- **Boolean|Object** `query`: If `true`, the request querystring parameters will be appended. If it's an object, it will be merged with the request querystring parameters.

### `render(template, data)`
Renders a template to the client.

#### Params

- **String** `template`: The template name.
- **Object** `data`: The template data.

### `startSession(data)`
Starts a session.

#### Params

- **Object** `data`: The session data.

### `setSessionData(data)`
Sets the session data.

#### Params

- **Object** `data`: The session data.

### `getSessionData(field)`
Returns the session data object/specific field.

#### Params

- **Field** `field`: A specific field to get from the session object.

#### Return
Expand All @@ -124,6 +140,7 @@ Destroys the session.
Gets/sets/deletes headers.

#### Params

- **String** `name`: The header name.
- **String** `value`: The header value to set. If `null`, the header will be *removed*.

Expand All @@ -134,20 +151,23 @@ Gets/sets/deletes headers.
Sends to the client a JSON object containing the `message` field.

#### Params

- **String** `msg`: The API message.
- **Number** `status`: The status code (default: `200`).

### `apiError(msg, status)`
Like `apiMsg`, but by default with a status code of `422`.

#### Params

- **String** `msg`: The API message.
- **Number** `status`: The status code (default: `422`).

### `end(content, status, contentType, headers)`
Ends the response sending the content.

#### Params

- **Anything** `content`: The content that should be sent to the response.
- **Number** `status`: The status code.
- **String** `contentType`: The content type (e.g. `"json"`).
Expand All @@ -157,6 +177,7 @@ Ends the response sending the content.
Sets, gets or deletes the cookie.

#### Params

- **String** `cookie`: The searched cookie.
- **String** `value`: If provided and it not `null`, the cookie will be set. If it's null, the cookie will be deleted. If `value` is not provided, the cookie value will be returned.

Expand All @@ -167,6 +188,7 @@ Sets, gets or deletes the cookie.
Serves a file to the response.

#### Params

- **String** `path`: Relative path to the file.
- **String** `customRoot`: Absolute path to the root directory (optional).

Expand All @@ -182,6 +204,7 @@ It emits the following events:
- `error` (err): Errors which may appear during the server initialization.

#### Params

- **Object** `opt_options`: An object containing the following properties:
- `host` (String): The server host.
- `port` (Integer): The server port. `process.env.PORT` is used, default is `3000`.
Expand Down Expand Up @@ -220,6 +243,10 @@ It emits the following events:

- `logErrors` (Boolean): Log the server errors (default: `true`).
- `csrf` (Object): The CSRF options. These are passed to [`csurf`](https://github.com/expressjs/csurf)
- `bodyParserJson` (Boolean): Whether to enable the JSON body parser (default: `true`)
- `bodyParserUrlEncoded` (Boolean): Whether to enable the URL encoded body parser (default: `true`)
- `cookieParser` (Boolean): Whether to enable the cookie parser (default: `true`)
- `transformers` (Boolean): Whether to enable the transformers (default: `true`)

#### Return
- **Object** The Lien instance.
Expand All @@ -228,13 +255,15 @@ It emits the following events:
Adds a new static path to the server.

#### Params

- **String** `url`: The static path url endpoint.
- **String** `localPath`: The local path to the directory.

### `addPage(url, method, output)`
Adds a new page to be handled.

#### Params

- **String** `url`: The page url.
- **String|Object** `method`: The request methods to be handled (default: `"all"`) or an object:
- `method` (String): The HTTP method.
Expand All @@ -246,6 +275,7 @@ Adds a new page to be handled.
Handle the error pages.

#### Params

- **Object** `options`: An object containing the following fields:
- `notFound` (String|Function): The path to a custom 404 page or a function receiving the lien object as parameter. This can be used to serve custom 404 pages.
- `serverError` (String|Function): The path to a custom 500 page or a function receiving the lien object as parameter. This can be used to serve custom 500 pages.
Expand All @@ -254,6 +284,7 @@ Handle the error pages.
Gets the transformer for a url.

#### Params

- **String** `type`: The hook type (`before` or `after`).
- **String** `url`: The url.
- **String** `method`: The method.
Expand All @@ -266,6 +297,7 @@ Similar to `getHooks`, but doesn't concat hooks based on the regex
matching but only if they are the same regex.

#### Params

- **String** `type`: The hook type (`before` or `after`).
- **String** `url`: The url.
- **String** `method`: The method.
Expand All @@ -277,6 +309,7 @@ matching but only if they are the same regex.
Inserts a new hook.

#### Params

- **String** `type`: The hook type (`before`, `after`, `custom:name`).
- **String** `url`: The url.
- **String** `method`: The method.
Expand All @@ -289,6 +322,7 @@ Inserts a new hook.
Adds a new hook.

#### Params

- **String** `where`: The hook type (`before` or `after`).
- **String** `url`: The route url.
- **String** `method`: The HTTP method.
Expand All @@ -299,6 +333,7 @@ Adds a new hook.
Adds a before hook. It will handle all the subroutes of the `url`.

#### Params

- **String** `url`: The route url.
- **String** `method`: The HTTP method.
- **Function** `cb`: The callback function.
Expand All @@ -308,6 +343,7 @@ Adds a before hook. It will handle all the subroutes of the `url`.
Adds a before hook. It will handle all the subroutes of the `url`.

#### Params

- **String** `url`: The route url.
- **String** `method`: The HTTP method.
- **Function** `cb`: The callback function.
Expand All @@ -317,6 +353,7 @@ Adds a before hook. It will handle all the subroutes of the `url`.
Use this function to add middleware handlers.

#### Params

- **String** `url`: The route url.
- **String** `method`: The HTTP method.
- **Function** `cb`: The callback function.
Expand All @@ -326,6 +363,7 @@ Use this function to add middleware handlers.
Adds a new middleware. **Note**: This will *not* trigger the hooks.

#### Params

- **String** `url`: The endpoint url.
- **String** `method`: The HTTP method (default: `all`).
- **Function** `cb`: The callback function.
Expand All @@ -343,20 +381,25 @@ this takes time. You can integrate and use these projects in your applications *

However, if you get some profit from this or just want to encourage me to continue creating stuff, there are few ways you can do it:


- Starring and sharing the projects you like :rocket:
- [![Buy me a book][badge_amazon]][amazon]—I love books! I will remember you after years if you buy me one. :grin: :book:
- [![PayPal][badge_paypal]][paypal-donations]—You can make one-time donations via PayPal. I'll probably buy a ~~coffee~~ tea. :tea:
- [![Support me on Patreon][badge_patreon]][patreon]—Set up a recurring monthly donation and you will get interesting news about what I'm doing (things that I don't share with everyone).
- **Bitcoin**—You can send me bitcoins at this address (or scanning the code below): `1P9BRsmazNQcuyTxEqveUsnf5CERdq35V6`

![](https://i.imgur.com/z6OQI95.png)


Thanks! :heart:


## :dizzy: Where is this library used?
If you are using this library in one of your projects, add it in this list. :sparkles:


- [`bloggify`](https://github.com/Bloggify/Bloggify) (by Bloggify)—We make publishing easy.
- [`bloggify-cli`](https://github.com/Bloggify/Bloggify) (by Bloggify)—We make publishing easy.
- [`bloggify-prebuilt`](https://github.com/Bloggify/bloggify-prebuilt#readme)—The prebuilt Bloggify version.
- [`bloggify-server-prebuilt`](https://bitbucket.org/bloggify/bloggify-server-prebuilt#readme)—Bundled and minified Bloggify server.
- [`bnotify`](https://github.com/IonicaBizau/bnotify)—A notification system written in NodeJS using the BAT platform.
Expand All @@ -368,19 +411,21 @@ If you are using this library in one of your projects, add it in this list. :spa
- [`web-term`](https://github.com/IonicaBizau/web-term)—A full screen terminal in your browser.
- [`wrabbit`](https://github.com/jillix/wrabbit) (by jillix)—Wrap scripts by providing the wrapping function.
- [`youtube-album-uploader`](https://github.com/jpchip/youtube-album-uploader) (by Jared Chapiewsky)—Uploads an mp3 album to Youtube
- [`youtube-album-uploader-multiple`](https://github.com/Chnapy/youtube-album-uploader-multiple) (by Richard Haddad)—Uploads multiple mp3 files to youtube

## :scroll: License

[MIT][license] © [Ionică Bizău][website]

[badge_patreon]: http://ionicabizau.github.io/badges/patreon.svg
[badge_amazon]: http://ionicabizau.github.io/badges/amazon.svg
[badge_paypal]: http://ionicabizau.github.io/badges/paypal.svg
[badge_paypal_donate]: http://ionicabizau.github.io/badges/paypal_donate.svg

[badge_patreon]: https://ionicabizau.github.io/badges/patreon.svg
[badge_amazon]: https://ionicabizau.github.io/badges/amazon.svg
[badge_paypal]: https://ionicabizau.github.io/badges/paypal.svg
[badge_paypal_donate]: https://ionicabizau.github.io/badges/paypal_donate.svg

[patreon]: https://www.patreon.com/ionicabizau
[amazon]: http://amzn.eu/hRo9sIZ
[paypal-donations]: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=RVXDDLKKLQRJW
[donate-now]: http://i.imgur.com/6cMbHOC.png

[license]: http://showalicense.com/?fullname=Ionic%C4%83%20Biz%C4%83u%20%3Cbizauionica%40gmail.com%3E%20(https%3A%2F%2Fionicabizau.net%2F)&year=2014#license-mit
[website]: https://ionicabizau.net/
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,4 @@
"transformer": "^1.0.1",
"ul": "^5.2.1"
}
}
}

0 comments on commit a7f1682

Please sign in to comment.