Express style paths
See original GitHub issueI think it would be very useful to be able to use express-like paths. It’s especially useful when mocking an api that needs to store some simple state.
e.g.
const example = nock('http://example.com')
let users = new Map()
example.put('/user/:id', (uri, body, params) => {
users.set(params.id, body)
return [201]
})
example.get('/user/:id', (uri, body, params) => {
if (!users.has(params.id)) return [404]
return [200, users.get(params.id)]
})
Issue Analytics
- State:
- Created 7 years ago
- Reactions:5
- Comments:9 (6 by maintainers)
Top Results From Across the Web
Routing - Express.js
Route paths, in combination with a request method, define the endpoints at which requests can be made. Route paths can be strings, string...
Read more >Express Tutorial Part 4: Routes and controllers - MDN Web Docs
The route paths define the endpoints at which requests can be made. The examples we've seen so far have just been strings, and...
Read more >node.js - Difficulty with absolute and relative paths in Express
I try and it work, just add "/" before the link, example: you are in localhost:8080/courses/ and your href is: href="style/style.css" you will ......
Read more >Edit paths in Adobe Photoshop
To select a path component (including a shape in a shape layer), select the Path Selection tool , and click anywhere inside the...
Read more >Debian -- Details of package node-path-to-regexp in sid
Turn an Express-style path string such as `/user/:name` into a regular expression. Node.js is an event-based server-side JavaScript engine.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Would still love to see this ☺️ hopefully I can send a PR for this 👍
You can see https://github.com/3rd-Eden/nock-knock