Serve csv and pdf files locally (#2946)

Co-authored-by: David Marby <david@dmarby.se>
This commit is contained in:
Opender SinghandDavid Marby authored and GitHub committed 2020-12-17 13:10:01 +13:00
1 parent 357b8f05f8
commit adb79a720d
4 files changed
+7 -16

No files matched your search

@@ -64,7 +64,7 @@ describe('Application launch', function() {
);
it('sends CSV request and shows rich response', async () => {
const url = 'http://127.0.0.1:4010/csv';
const url = 'http://127.0.0.1:4010/file/dummy.csv';
await debug.workspaceDropdownExists(app);
await debug.createNewRequest(app, 'csv');
@@ -77,9 +77,7 @@ describe('Application launch', function() {
});
it('sends PDF request and shows rich response', async () => {
// Cannot mock the pdf response using Prism because it is not yet supported
// https://github.com/stoplightio/prism/issues/1248#issuecomment-646056440
const url = 'https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf';
const url = 'http://127.0.0.1:4010/file/dummy.pdf';
await debug.workspaceDropdownExists(app);
await debug.createNewRequest(app, 'pdf');
@@ -0,0 +1,2 @@
a,b,c
1,2,3
1 a b c
2 1 2 3
Binary file not shown.
+3 -12
View File
@@ -6,7 +6,7 @@ const app = express();
const basicAuthRouter = express.Router();
const port = 4010;
// Artificallly slow each request down
// Artificially slow each request down
app.use((req, res, next) => {
setTimeout(next, 500);
});
@@ -15,12 +15,7 @@ app.get('/pets/:id', (req, res) => {
res.status(200).send({ id: req.params.id });
});
app.get('/csv', (_, res) => {
res
.status(200)
.header('content-type', 'text/csv')
.send(`a,b,c\n1,2,3`);
});
app.use('/file', express.static('fixtures'));
const { utf8, latin1 } = basicAuthCreds;
@@ -29,11 +24,7 @@ const users = {
[latin1.encoded.user]: latin1.encoded.pass,
};
basicAuthRouter.use(
basicAuth({
users,
}),
);
basicAuthRouter.use(basicAuth({ users }));
basicAuthRouter.get('/', (_, res) => {
res