Comparing version 1.0.5 to 1.0.6
{ | ||
"name": "jet-paths", | ||
"version": "1.0.5", | ||
"version": "1.0.6", | ||
"description": "Preprend strings in an object with the value from a base-key.", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
# About jet-paths | ||
Recursively formats an object containing strings, so that each string value is prepended with its containing objects prefix property. | ||
```typescript | ||
console.log(jetPaths({ | ||
Base: '/api', | ||
Users: { | ||
Base: '/users', | ||
Get: '/all', | ||
}, | ||
})); | ||
// Outputs | ||
{ | ||
Base: '/api', | ||
Users: { | ||
Base: '/api/users', | ||
Get: '/api/users/all', | ||
}, | ||
}; | ||
``` | ||
In my expressJS server, I would generally store my routes in an object like so | ||
@@ -12,3 +33,2 @@ and pass them to express `Router()` objects: | ||
Base: '/users', | ||
Get: '/all', | ||
Add: '/add', | ||
@@ -39,3 +59,3 @@ ... | ||
#### How it works | ||
The default import provides the function `jetPaths(obj, prefix (optional, default is 'BASE'))`. An object with the same keys is return with the prefix added for the parent object and all nested objects. | ||
The default import provides the function `jetPaths(obj, prefix (optional, default is 'Base'))`. An object with the same keys is returned with the prefix added for the parent object and all nested objects. | ||
@@ -46,3 +66,3 @@ | ||
```typescript | ||
import jetPaths from '../src'; | ||
import jetPaths from 'jet-paths'; | ||
@@ -102,2 +122,4 @@ const PREFIX = 'Root'; | ||
Oh yeah, whole thing is fully typesafe! | ||
Happy web-deving :) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6082
122