2020-12-07 20:12:50 +00:00
|
|
|
import express from 'express';
|
|
|
|
import basicAuth from 'express-basic-auth';
|
2021-05-19 11:49:48 +00:00
|
|
|
import { basicAuthCreds } from '../fixtures/constants';
|
2020-12-07 20:12:50 +00:00
|
|
|
|
|
|
|
const app = express();
|
|
|
|
const basicAuthRouter = express.Router();
|
|
|
|
const port = 4010;
|
|
|
|
|
2020-12-17 00:10:01 +00:00
|
|
|
// Artificially slow each request down
|
2021-05-19 11:49:48 +00:00
|
|
|
app.use((_req, _res, next) => {
|
2020-12-07 20:12:50 +00:00
|
|
|
setTimeout(next, 500);
|
|
|
|
});
|
|
|
|
|
|
|
|
app.get('/pets/:id', (req, res) => {
|
|
|
|
res.status(200).send({ id: req.params.id });
|
|
|
|
});
|
|
|
|
|
2020-12-17 00:10:01 +00:00
|
|
|
app.use('/file', express.static('fixtures'));
|
2020-12-07 20:12:50 +00:00
|
|
|
|
|
|
|
const { utf8, latin1 } = basicAuthCreds;
|
|
|
|
|
|
|
|
const users = {
|
|
|
|
[utf8.encoded.user]: utf8.encoded.pass,
|
|
|
|
[latin1.encoded.user]: latin1.encoded.pass,
|
|
|
|
};
|
|
|
|
|
2020-12-17 00:10:01 +00:00
|
|
|
basicAuthRouter.use(basicAuth({ users }));
|
2020-12-07 20:12:50 +00:00
|
|
|
|
|
|
|
basicAuthRouter.get('/', (_, res) => {
|
|
|
|
res
|
|
|
|
.status(200)
|
|
|
|
.header('content-type', 'text/plain')
|
|
|
|
.send('basic auth received');
|
|
|
|
});
|
|
|
|
|
|
|
|
app.use('/auth/basic', basicAuthRouter);
|
|
|
|
|
|
|
|
app.listen(port, () => {
|
|
|
|
console.log(`Listening at http://localhost:${port}`);
|
|
|
|
});
|
ResponseTimer callstack exceeded (#3386)
* no default export (prepping for hooks)
* makes logic match other implementation
note that above in `componentDidUpdate` it uses `<= 0`, whereas here it uses `> 0` but then only checks for false.
Also, logically, there's no way to ever get `aria-hidden="true"` since it returns early so that entire attribute can just be removed.
* removes fake private class member syntax
this is moving to hooks anyway, but in the meantime...
* undoes calling identical code twice in a row...
* condenses class methods to prepare for hooks
* hooks refactor
fairly faithful to the original, this attempts to just refactor to hooks. this exposes, again, the fact that we're setting state within useEffect.
* removes 200 ms offset for response time
so that, now, you know, the time reported is the actual time.
* adds logging for response timer lage
* removes timer logging and `responseTime` prop after PR discussion
it's definitely fruitful, but the fix for the callstack exceeded is what needs to be the focus.
* removes shadowed variable per PR feedback
* reinstates and documents 200ms compensation
* add delay endpoint to example server
* Update packages/insomnia-app/app/ui/components/response-timer.tsx
Co-authored-by: Opender Singh <opender.singh@konghq.com>
2021-05-17 23:58:05 +00:00
|
|
|
|
|
|
|
app.get('/delay/seconds/:duration', (req, res) => {
|
2021-05-19 11:49:48 +00:00
|
|
|
const delaySec = Number.parseInt(req.params.duration || '2');
|
|
|
|
setTimeout(function() {
|
2021-05-27 18:00:32 +00:00
|
|
|
res.send(`Delayed by ${delaySec} seconds`);
|
ResponseTimer callstack exceeded (#3386)
* no default export (prepping for hooks)
* makes logic match other implementation
note that above in `componentDidUpdate` it uses `<= 0`, whereas here it uses `> 0` but then only checks for false.
Also, logically, there's no way to ever get `aria-hidden="true"` since it returns early so that entire attribute can just be removed.
* removes fake private class member syntax
this is moving to hooks anyway, but in the meantime...
* undoes calling identical code twice in a row...
* condenses class methods to prepare for hooks
* hooks refactor
fairly faithful to the original, this attempts to just refactor to hooks. this exposes, again, the fact that we're setting state within useEffect.
* removes 200 ms offset for response time
so that, now, you know, the time reported is the actual time.
* adds logging for response timer lage
* removes timer logging and `responseTime` prop after PR discussion
it's definitely fruitful, but the fix for the callstack exceeded is what needs to be the focus.
* removes shadowed variable per PR feedback
* reinstates and documents 200ms compensation
* add delay endpoint to example server
* Update packages/insomnia-app/app/ui/components/response-timer.tsx
Co-authored-by: Opender Singh <opender.singh@konghq.com>
2021-05-17 23:58:05 +00:00
|
|
|
}, delaySec * 1000);
|
2021-05-19 11:49:48 +00:00
|
|
|
});
|