-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
374 additions
and
420 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
dist | ||
lib | ||
node_modules | ||
release | ||
private |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import Axle from '../dist/index'; | ||
|
||
// setup cancel | ||
const cancelMark = new Axle.cancelMark(); | ||
const cancelSignal = cancelMark.signal; | ||
|
||
(async function test() { | ||
const json = await ( | ||
await Axle.get('https://dog.ceo/api/breeds/image/random', { | ||
signal: cancelSignal, | ||
}) | ||
).json(); | ||
|
||
console.log(json.message); // dog image url | ||
|
||
// cancel with message, optional | ||
cancelMark.cancel('Canceled Request'); | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import Axle from '../dist/index'; | ||
|
||
// custom middleware | ||
Axle.use((req, res) => { | ||
if (res.query['id']) { | ||
console.log(`ID: ${res.queryParam('id')}`); | ||
} else { | ||
console.log('Different URL, no ID found'); | ||
} | ||
}); | ||
|
||
// built-in middleware | ||
Axle.use(Axle.middleware.timeTook()); | ||
|
||
// built-in middleware options | ||
Axle.useOptions({ | ||
...Axle.middlewareOptions.cors(), | ||
...Axle.middlewareOptions.kneepads(), | ||
}); | ||
|
||
(async function test() { | ||
const res = await Axle.get('https://dog.ceo/api/breeds/image/random'); | ||
const json = await res.json(); | ||
|
||
console.log(json.message); // random dog url | ||
})(); |
Oops, something went wrong.