diff options
author | Tao Shen <shentao@chinamobile.com> | 2019-09-11 09:33:50 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2019-09-11 09:33:50 +0000 |
commit | d56bca3670049515d8a69e56d9f692e0f70c276b (patch) | |
tree | 993bc05c8aa9ec24a6b4f5e191e34fcb77164cc5 /usecaseui-portal/src/app/mock | |
parent | 1790dca317395495df2ea72ac4e088d4347bbacf (diff) | |
parent | fa426eee7abcb1a509b263585f4556f661a99d38 (diff) |
Merge "feat: add post and put mock method"
Diffstat (limited to 'usecaseui-portal/src/app/mock')
4 files changed, 39 insertions, 5 deletions
diff --git a/usecaseui-portal/src/app/mock/json/PUT_uui-lcm_customers.json b/usecaseui-portal/src/app/mock/json/PUT_uui-lcm_customers.json new file mode 100644 index 00000000..c014187e --- /dev/null +++ b/usecaseui-portal/src/app/mock/json/PUT_uui-lcm_customers.json @@ -0,0 +1,6 @@ +{ + "global-customer-id": "Democcy", + "subscriber-name": "Democcy", + "subscriber-type": "INFRA", + "resource-version": "1535601196964" +}
\ No newline at end of file diff --git a/usecaseui-portal/src/app/mock/json/PUT_uui-lcm_customers_service-subscriptions.json b/usecaseui-portal/src/app/mock/json/PUT_uui-lcm_customers_service-subscriptions.json new file mode 100644 index 00000000..c014187e --- /dev/null +++ b/usecaseui-portal/src/app/mock/json/PUT_uui-lcm_customers_service-subscriptions.json @@ -0,0 +1,6 @@ +{ + "global-customer-id": "Democcy", + "subscriber-name": "Democcy", + "subscriber-type": "INFRA", + "resource-version": "1535601196964" +}
\ No newline at end of file diff --git a/usecaseui-portal/src/app/mock/routes.js b/usecaseui-portal/src/app/mock/routes.js index 03dc68d3..cb3cc17e 100644 --- a/usecaseui-portal/src/app/mock/routes.js +++ b/usecaseui-portal/src/app/mock/routes.js @@ -35,8 +35,12 @@ module.exports = ///////////////////////// ///////<-------------managemence services--------->///// + "/uui-lcm/customers/:customer": "/serviceType", + "/PUT/uui-lcm/customers/:name/service-subscriptions/:id": "/PUT_uui-lcm_customers_service-subscriptions", + "/PUT/uui-lcm/customers/:customer": "/PUT_uui-lcm_customers", + "/uui-lcm/customers/:customer/service-subscriptions/:id": "/language", "/uui-lcm/customers/:customer/service-subscriptions": "/serviceType", - "/uui-lcm/serviceNumByServiceType/:customer":"/CustomersColumn", + "/uui-lcm/serviceNumByServiceType/:customer": "/CustomersColumn", ///////////////////////// diff --git a/usecaseui-portal/src/app/mock/server.js b/usecaseui-portal/src/app/mock/server.js index 726992d5..b603523f 100644 --- a/usecaseui-portal/src/app/mock/server.js +++ b/usecaseui-portal/src/app/mock/server.js @@ -18,13 +18,14 @@ 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); -server.use((requset,response,next) => { - requset.method = 'GET'; - next() -}) +// server.use((req, res, next) => { +// req.method = "GET"; +// next(); +// }) // Get mock data const fs = require('fs'); @@ -72,6 +73,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)); @@ -86,6 +88,22 @@ 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) => { + console.log("===delete😑") + next(); +}) server.listen(3002, () => { console.log('Mock Server is successfully running on port 3002 😁') |