Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 26 additions & 11 deletions src/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,40 @@ let newrelic = require('newrelic');
import express from "express";
import bodyParser from "body-parser";

import VRENroute from "./routes/VREN";
import VRESroute from "./routes/VRES";
import KSAV1route from "./routes/KSAV1";
import KSAV2route from "./routes/KSAV2";
import FLEXroute from "./routes/FLEX";
import routeLogic from "./helpers/routeLogic";
import KSAV1 from "./formDefinitions/KSAV1";
import KSAV2 from "./formDefinitions/KSAV2";
import VRES from "./formDefinitions/VRES";
import VREN from "./formDefinitions/VREN";

const app = express();
const jsonParser = bodyParser.json({limit: '50mb', extended: true});
const jsonParser = bodyParser.json({ limit: "50mb", extended: true });

app.locals.newrelic = newrelic;

app.get("/", (req, res) => {
res.json({ message: "ok" });
});

app.post("/vr/en", jsonParser, VRENroute);
app.post("/vr/es", jsonParser, VRESroute);
app.post("/av/ksav1", jsonParser, KSAV1route);
app.post("/av/ksav2", jsonParser, KSAV2route);
app.post("/flex", jsonParser, FLEXroute);
app.post("/vr/en", jsonParser, async (req, res) => {
res.json(await routeLogic(VREN, req.body));
});

app.post("/vr/es", jsonParser, async (req, res) => {
res.json(await routeLogic(VRES, req.body));
});

app.post("/av/ksav1", jsonParser, async (req, res) => {
res.json(await routeLogic(KSAV1, req.body));
});

app.post("/av/ksav2", jsonParser, async (req, res) => {
res.json(await routeLogic(KSAV2, req.body));
});

app.post("/flex", jsonParser, async (req, res) => {
const { formData, formDefinition } = req.body;
res.json(await routeLogic(formDefinition, formData));
});

export default app;
226 changes: 139 additions & 87 deletions src/formDefinitions/KSAV1.js
Original file line number Diff line number Diff line change
@@ -1,87 +1,139 @@
export default [
{ name: "state", x1: 204, y1: 340, x2: 512, y2: 372, type: "draw" },
{ name: "county_2", x1: 652, y1: 339, x2: 963, y2: 372, type: "draw" },
{ name: "id_number", x1: 1109, y1: 577, x2: 1596, y2: 625, type: "draw" },
{ name: "last_name", x1: 103, y1: 1031, x2: 564, y2: 1077, type: "draw" },
{ name: "first_name", x1: 598, y1: 1031, x2: 1064, y2: 1077, type: "draw" },
{
name: "middle_initial",
x1: 1097,
y1: 1032,
x2: 1163,
y2: 1077,
type: "draw"
},
{ name: "dob", x1: 1198, y1: 1032, x2: 1600, y2: 1076, type: "draw" },
{
name: "residential_address",
x1: 99,
y1: 1107,
x2: 748,
y2: 1145,
type: "draw"
},
{
name: "residential_state",
x1: 1200,
y1: 1108,
x2: 1354,
y2: 1145,
type: "draw"
},
{
name: "residential_zip",
x1: 1397,
y1: 1108,
x2: 1601,
y2: 1145,
type: "draw"
},
{ name: "democratic", x1: 865, y1: 1196, x2: 884, y2: 1214, type: "fill" },
{ name: "republican", x1: 1029, y1: 1196, x2: 1048, y2: 1214, type: "fill" },
{
name: "mailing_address",
x1: 101,
y1: 1300,
x2: 746,
y2: 1351,
type: "draw"
},
{ name: "mailing_city", x1: 799, y1: 1299, x2: 1155, y2: 1351, type: "draw" },
{
name: "mailing_state",
x1: 1198,
y1: 1299,
x2: 1352,
y2: 1348,
type: "draw"
},
{ name: "mailing_zip", x1: 1398, y1: 1299, x2: 1600, y2: 1349, type: "draw" },
{ name: "election_date", x1: 95, y1: 1679, x2: 408, y2: 1718, type: "draw" },
{ name: "signature", x1: 321, y1: 1738, x2: 764, y2: 1833, type: "overlay" },
{
name: "signature_date",
x1: 799,
y1: 1779,
x2: 1187,
y2: 1833,
type: "draw"
},
{
name: "phone_number",
x1: 1218,
y1: 1779,
x2: 1594,
y2: 1833,
type: "draw"
},
{
name: "residential_city",
x1: 799,
y1: 1108,
x2: 1156,
y2: 1143,
type: "draw"
},
{ name: "county_1", x1: 574, y1: 298, x2: 867, y2: 331, type: "draw" }
];
export default {
baseImg: "https://s3.amazonaws.com/ksvotes/AV1NVRIS.png",
fields: [
{ name: "state", x1: 204, y1: 340, x2: 512, y2: 372, type: "draw" },
{ name: "county_2", x1: 652, y1: 339, x2: 963, y2: 372, type: "draw" },
{ name: "id_number", x1: 1109, y1: 577, x2: 1596, y2: 625, type: "draw" },
{ name: "last_name", x1: 103, y1: 1031, x2: 564, y2: 1077, type: "draw" },
{
name: "first_name",
x1: 598,
y1: 1031,
x2: 1064,
y2: 1077,
type: "draw"
},
{
name: "middle_initial",
x1: 1097,
y1: 1032,
x2: 1163,
y2: 1077,
type: "draw"
},
{ name: "dob", x1: 1198, y1: 1032, x2: 1600, y2: 1076, type: "draw" },
{
name: "residential_address",
x1: 99,
y1: 1107,
x2: 748,
y2: 1145,
type: "draw"
},
{
name: "residential_state",
x1: 1200,
y1: 1108,
x2: 1354,
y2: 1145,
type: "draw"
},
{
name: "residential_zip",
x1: 1397,
y1: 1108,
x2: 1601,
y2: 1145,
type: "draw"
},
{
name: "democratic",
x1: 865,
y1: 1196,
x2: 884,
y2: 1214,
type: "fill"
},
{
name: "republican",
x1: 1029,
y1: 1196,
x2: 1048,
y2: 1214,
type: "fill"
},
{
name: "mailing_address",
x1: 101,
y1: 1300,
x2: 746,
y2: 1351,
type: "draw"
},
{
name: "mailing_city",
x1: 799,
y1: 1299,
x2: 1155,
y2: 1351,
type: "draw"
},
{
name: "mailing_state",
x1: 1198,
y1: 1299,
x2: 1352,
y2: 1348,
type: "draw"
},
{
name: "mailing_zip",
x1: 1398,
y1: 1299,
x2: 1600,
y2: 1349,
type: "draw"
},
{
name: "election_date",
x1: 101,
y1: 1679,
x2: 408,
y2: 1718,
type: "draw"
},
{
name: "signature",
x1: 301,
y1: 1738,
x2: 764,
y2: 1833,
type: "overlay"
},
{
name: "signature_date",
x1: 799,
y1: 1779,
x2: 1187,
y2: 1833,
type: "draw"
},
{
name: "phone_number",
x1: 1218,
y1: 1779,
x2: 1594,
y2: 1833,
type: "draw"
},
{
name: "residential_city",
x1: 799,
y1: 1108,
x2: 1156,
y2: 1143,
type: "draw"
},
{ name: "county_1", x1: 574, y1: 298, x2: 867, y2: 331, type: "draw" }
]
};
Loading