Skip to content
This repository was archived by the owner on Oct 11, 2021. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,20 @@ const app = new Koa()
app.use(sassy('/sass'))

app.listen(3000)
```
```

## API :package:

### sassy(src, options) ⇒ `function`

serves cached sass as complied css

**Kind**: exported function
**Returns**: `function` - middleware serving complied css

| Param | Type | Description |
| --- | --- | --- |
| src | `String` | path to sass directory |
| options | `Object` | koa-sassy options object |
| mount | `string` | mount point for css to be severed - default / |
| options.maxAge | `Number` | maximum time the favicon is considered fresh - default one day |
8 changes: 8 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ const path = require('path')
const ONE_YEAR_MS = 60 * 60 * 24 * 365 // one year in seconds
const ONE_DAY_MS = 60 * 60 * 24 // one day in seconds

/**
* serves cached sass as complied css
* @param {String} src path to sass directory
* @param {Object} options koa-sassy options object
* @param {Object} options.mount mount point for css to be severed - default /
* @param {Number} options.maxAge maximum time the favicon is considered fresh - default one day
* @returns {Function} middleware serving complied css
*/
function middleware (src, options) {
if (!src) throw new Error('[koa-sassy] src path is required')
if (!fs.existsSync(src)) throw new Error('[koa-sassy] src path must exist')
Expand Down