-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
33 lines (26 loc) · 958 Bytes
/
server.js
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
const express = require('express');
const axios = require('axios');
const app = express();
// Parse JSON bodies for this app.
app.use(express.json());
app.post('/', function(request, response){
data = request.body;
// debug purpose: show in console raw data received
console.log("Request received: \n"+JSON.stringify(data, null, 2));
// NOTE:
// orca system fields start with ___
// you can access the value of each field using the field name (data.Name, data.Barcode, data.Location)
const name = data.Name
//validation example
if(name.length > 20){
//return json error message
response.json({
"title": "Invalid Name",
"message": "Name cannot contain more than 20 characters",
}).send();
return;
}
//return HTTP Status 200 with no body
response.status(200).send();
});
app.listen(3000, () => console.log('Example app is listening on port 3000.'));