mock-responses

espress-kind http request middleware

Usage no npm install needed!

<script type="module">
  import mockResponses from 'https://cdn.skypack.dev/mock-responses';
</script>

README

mock-responses

NOT-real API server for front-end development Introduction

Start server(NestJS) for production

$ cd server 
$ npm i
$ npm run build
$ cd dist/server && node main.js

For development

$ npm i
$ npm start
# cd server && npm run start:server # to start server(NestJS) separately
# or cd client && npm run start:client # to start clien(Angular9) separately

Configuration File

Update mock-responses.config.js for detailed setup.

  • dbPath: required, mock-responses .sql file (get this from demo)
  • ssl: optional, false in default. If true, the server starts in ssl mode.
  • sslKeyPath: optional, ssl key file path. If not defined, it uses a defaul key file.
  • sslCertPath: optional, ssl dert. file path. If not defined, it uses a defaul cert file.
  • port: optional, default 3331. port number for server
  • cookie: optional, sring. if set, all mock responses reply with this cookie.
  • headers: optional, array, if set, all mock resonses reply with this headers.
module.exports = {
  dbPath: './mock-server/mock-responses.sql',
  ssl: true,
  port: 9200,
  cookie: 'MY_SESSION=ACCTNBR=123456789; Path=/',
  headers: [
    'Access-Control-Allow-Headers=Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With'
  ]
};