Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/totallymoney/filename-basepath
Mount express routes using filename as basepath
https://github.com/totallymoney/filename-basepath
Last synced: 3 days ago
JSON representation
Mount express routes using filename as basepath
- Host: GitHub
- URL: https://github.com/totallymoney/filename-basepath
- Owner: totallymoney
- License: mit
- Created: 2020-05-09T01:06:33.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2022-12-12T17:39:23.000Z (almost 2 years ago)
- Last Synced: 2024-11-08T15:54:28.444Z (7 days ago)
- Language: JavaScript
- Size: 33.2 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# Filename Basepath
Mount express routes using filename as basepath.
Useful for efficiently mocking multiple http dependencies.
## Example
```bash
$ yarn add -D @totallymoney/filename-basepath
``````bash
$ tree
.
├── mocks
│ └── my-route.js
└── package.json
``````bash
$ cat mocks/my-route.jsvar router = require("express").Router();
router.get("/foo", function (_, res) {
res.send("bar");
});module.exports = router;
``````bash
$ yarn filename-basepath mocksSourcing routes from: my-repo/mocks
/my-route
Running on port 3000
``````bash
$ curl -s http://localhost:3000/my-route/foo"bar"
```## Development
Make sure you belong to the [totallymoney](https://www.npmjs.com/settings/totallymoney/packages) npm organization. Then make changes to the source code and publish. Enter the new version number as prompted. A git push command will run automatically after publishing.
```bash
$ git commit -am "Improve logging"
$ yarn publish --access public
```