@ashvajs/mock-server
Advanced tools
Comparing version 0.0.1 to 0.0.2
{ | ||
"name": "@ashvajs/mock-server", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"dependencies": { | ||
@@ -5,0 +5,0 @@ "fs": "^0.0.1-security", |
@@ -1,11 +0,34 @@ | ||
# mock-server | ||
# @ashvajs/mock-server | ||
This library was generated with [Nx](https://nx.dev). | ||
## Description | ||
Simple mock server to serve static/dynamic routes for mock api. | ||
## Building | ||
Run `nx build mock-server` to build the library. | ||
## Usage | ||
## Running unit tests | ||
Create your mock server object with mock server class and pass express app object with folder path. | ||
Run `nx test mock-server` to execute the unit tests via [Jest](https://jestjs.io). | ||
``` | ||
import path from 'path'; | ||
import express from 'express'; | ||
import { MockServer } from '@ashvajs/mock-server'; | ||
const host = process.env.HOST ?? 'localhost'; | ||
const port = process.env.PORT ? Number(process.env.PORT) : 3000; | ||
const app = express(); | ||
const mockserver = new MockServer( | ||
{ | ||
staticApiPath: path.resolve('apps/mock-server-example/mocks'), | ||
}, | ||
app | ||
); | ||
mockserver.init(); | ||
app.listen(port, host, () => { | ||
console.log(`[ ready ] http://${host}:${port}`); | ||
}); | ||
``` | ||
## Examples | ||
see `apps/mock-server-example` |
9628
34