2020-12-07 20:12:50 +00:00
|
|
|
import express from 'express';
|
2022-06-22 15:29:27 +00:00
|
|
|
import { graphqlHTTP } from 'express-graphql';
|
2021-07-22 23:04:56 +00:00
|
|
|
|
2022-02-28 15:28:02 +00:00
|
|
|
import { basicAuthRouter } from './basic-auth';
|
2022-03-18 09:57:12 +00:00
|
|
|
import githubApi from './github-api';
|
2022-06-01 08:39:31 +00:00
|
|
|
import gitlabApi from './gitlab-api';
|
2022-06-22 15:29:27 +00:00
|
|
|
import { root, schema } from './graphql';
|
2022-05-05 15:49:14 +00:00
|
|
|
import { startGRPCServer } from './grpc';
|
2022-02-28 15:28:02 +00:00
|
|
|
import { oauthRoutes } from './oauth';
|
2020-12-07 20:12:50 +00:00
|
|
|
|
|
|
|
const app = express();
|
|
|
|
const port = 4010;
|
2022-05-05 15:49:14 +00:00
|
|
|
const grpcPort = 50051;
|
2020-12-07 20:12:50 +00:00
|
|
|
|
|
|
|
app.get('/pets/:id', (req, res) => {
|
|
|
|
res.status(200).send({ id: req.params.id });
|
|
|
|
});
|
|
|
|
|
2021-11-17 09:44:19 +00:00
|
|
|
app.get('/sleep', (_req, res) => {
|
|
|
|
res.status(200).send({ sleep: true });
|
|
|
|
});
|
|
|
|
|
2022-02-04 12:20:21 +00:00
|
|
|
app.get('/cookies', (_req, res) => {
|
|
|
|
res
|
|
|
|
.status(200)
|
|
|
|
.header('content-type', 'text/plain')
|
|
|
|
.cookie('insomnia-test-cookie', 'value123')
|
|
|
|
.send(`${_req.headers['cookie']}`);
|
|
|
|
});
|
|
|
|
|
2021-10-06 22:01:43 +00:00
|
|
|
app.use('/file', express.static('fixtures/files'));
|
2020-12-07 20:12:50 +00:00
|
|
|
|
|
|
|
app.use('/auth/basic', basicAuthRouter);
|
|
|
|
|
2022-03-18 09:57:12 +00:00
|
|
|
githubApi(app);
|
2022-06-01 08:39:31 +00:00
|
|
|
gitlabApi(app);
|
2022-03-18 09:57:12 +00:00
|
|
|
|
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
|
|
|
});
|
2022-02-28 15:28:02 +00:00
|
|
|
|
|
|
|
app.use('/oidc', oauthRoutes(port));
|
|
|
|
|
2022-03-18 09:57:12 +00:00
|
|
|
app.get('/', (_req, res) => {
|
|
|
|
res.status(200).send();
|
|
|
|
});
|
|
|
|
|
2022-06-22 15:29:27 +00:00
|
|
|
app.use('/graphql', graphqlHTTP({
|
|
|
|
schema: schema,
|
|
|
|
rootValue: root,
|
|
|
|
graphiql: true,
|
|
|
|
}));
|
|
|
|
|
2022-05-05 15:49:14 +00:00
|
|
|
startGRPCServer(grpcPort).then(() => {
|
|
|
|
app.listen(port, () => {
|
|
|
|
console.log(`Listening at http://localhost:${port}`);
|
|
|
|
});
|
2022-02-28 15:28:02 +00:00
|
|
|
});
|