forked from firefox-devtools/debugger
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcypress-server.js
More file actions
executable file
·47 lines (37 loc) · 1.2 KB
/
cypress-server.js
File metadata and controls
executable file
·47 lines (37 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
"use strict";
const express = require("express");
const bodyParser = require("body-parser");
const fs = require('fs');
const path = require('path');
/**
saves a fixture file to public/js/test/fixtures
@param name - name of the fixture file
@param text - fixture json text
*/
function saveFixture(name, text) {
function getFixtureFile(name) {
const fixturePath = path.join(__dirname, "../public/js/test/fixtures");
const fixtureFile = path.join(fixturePath, name + ".json");
if (!fs.existsSync(fixturePath)) {
throw new Error("Could not find fixture " + name);
}
return fixtureFile;
}
const fixtureFile = getFixtureFile(name);
fs.writeFileSync(fixtureFile, text)
}
const app = express();
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json({ limit: "50mb" }));
app.post("/save-fixture", function(req, res) {
const fixtureName = req.body.fixtureName;
const fixtureText = req.body.fixtureText;
saveFixture(fixtureName, fixtureText);
res.send(`saved fixture ${fixtureName}`);
});
app.listen(8001, "localhost", function(err, result) {
if (err) {
console.log(err);
}
console.log("Development Server Listening at http://localhost:8001");
});