diff options
Diffstat (limited to 'usecaseui-portal/src/app/mock/server.js')
-rw-r--r-- | usecaseui-portal/src/app/mock/server.js | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/usecaseui-portal/src/app/mock/server.js b/usecaseui-portal/src/app/mock/server.js index f0c46fb3..010f480d 100644 --- a/usecaseui-portal/src/app/mock/server.js +++ b/usecaseui-portal/src/app/mock/server.js @@ -18,6 +18,7 @@ const jsonServer = require('json-server'); const server = jsonServer.create(); const middlewares = jsonServer.defaults(); const customersRouters = require('./routes'); +const baseUrl = "/usecaseui-server/v1"; // Set default middlewares (logger, static, cors and no-cache) server.use(middlewares); @@ -68,6 +69,7 @@ function fileDisplay(filePath) { runServer(localJsonDb); }, 100) } + function getjsonContent(path) { let newpath = `./src/app/mock/json/${path}.json`; let result = JSON.parse(fs.readFileSync(newpath)); @@ -82,6 +84,24 @@ function serverRewrite() { function runServer(db) { server.use(jsonServer.router(db)); } +server.post(`${baseUrl}/*`, (req, res, next) => { + const prefix = req.url.replace(baseUrl, ""); + req.url = `${baseUrl}/POST${prefix}`; + req.method = 'GET'; + next(); +}) +server.put(`${baseUrl}/*`, (req, res, next) => { + const prefix = req.url.replace(baseUrl, ""); + req.url = `${baseUrl}/PUT${prefix}`; + req.method = 'GET'; + next(); +}) +server.delete(`${baseUrl}/*`, (req, res, next) => { + const prefix = req.url.replace(baseUrl, ""); + req.url = `${baseUrl}/DELETE${prefix}`; + req.method = 'GET'; + next(); +}) server.listen(3002, () => { console.log('Mock Server is successfully running on port 3002 😁') |