express-fixturer
Advanced tools
Comparing version 0.0.1 to 0.0.2
/// <reference types="express" /> | ||
import { Request, Response, NextFunction } from 'express'; | ||
export interface Parameters { | ||
saveRoutes: boolean | string[]; | ||
fixtureRoutes: boolean | string[]; | ||
saveRoutes?: boolean | string[]; | ||
fixtureRoutes?: boolean | string[]; | ||
fixtureBasePath: string; | ||
hashFn: (req: Request) => object; | ||
hashFn?: (req: Request) => object; | ||
} | ||
declare const middlewareFactory: (opts: Parameters) => (req: Request, res: Response, next: NextFunction) => void; | ||
export default middlewareFactory; |
{ | ||
"name": "express-fixturer", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "Easily manage your API fixtures", | ||
@@ -36,2 +36,2 @@ "main": "lib/index.js", | ||
} | ||
} | ||
} |
@@ -9,2 +9,14 @@ # Express-fixturer | ||
## How to get started | ||
Install the middleware: | ||
``` | ||
npm install express-fixturer | ||
``` | ||
Plug it to express: | ||
```js | ||
const app = express(); | ||
app.use(expressFixturer({ fixtureBasePath: './fixtures' })); | ||
``` | ||
## API | ||
@@ -11,0 +23,0 @@ |
@@ -10,6 +10,6 @@ import { Request, Response, NextFunction } from 'express'; | ||
// save all routes, yes no or define the routes you want to save | ||
saveRoutes: boolean | string[]; | ||
fixtureRoutes: boolean | string[]; | ||
saveRoutes?: boolean | string[]; | ||
fixtureRoutes?: boolean | string[]; | ||
fixtureBasePath: string; | ||
hashFn: (req: Request) => object; | ||
hashFn?: (req: Request) => object; | ||
} | ||
@@ -35,3 +35,3 @@ | ||
params.fixtureBasePath, | ||
`${createHash(params.hashFn(req))}.json` | ||
`${createHash(params.hashFn!(req))}.json` | ||
); | ||
@@ -38,0 +38,0 @@ |
Sorry, the diff of this file is not supported yet
10263
54