-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparse.js
More file actions
72 lines (65 loc) · 1.96 KB
/
parse.js
File metadata and controls
72 lines (65 loc) · 1.96 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
var csv = require("fast-csv");
var URL = require("url");
var aph = require("./apiheu");
if (process.argv.length < 3) {
console.warn("Usage: node parse.js ./path/to/file.csv");
return;
}
// Domain name
// avoid using underscore in URIs -> should I check only the path?
// lowercase in paths
// avoid trailing forward slash
// version number in path
// version number in params
// API denomination in domain
// API denomination in path
// last resource
// parent resource
// avoid using CRUD names
// resource extension
// hide scriptig technology
// use content negotiation (not format extentions)
// use content negotiation (extension in query params)
// number of query params
// Tunneling over GET / POST (crud in params)
// Tunneling over GET / POST (action in query)
// Tunneling over GET / POST (id in query)
// Tunneling over GET / POST (API as resource name)
// Avoid using cache as a param (use headers instead)
console.log(["domain",
"undescore",
"lowercase",
"slash",
"versionPath",
"versionParam",
"apiDomain",
"apiPath",
"resource",
"parent",
"crudResource",
"resourceExtension",
"hideExtension",
"formatExtension",
"queryExtension",
"nQueryParams",
"tunnelCrudParam",
"tunnelActionQuery",
"tunnelIdQuery",
"tunnelAPIResource",
"matchMedia",
"cacheQuery"].join("\t"));
csv
.fromPath(process.argv[2])
.on("data", function(data){
var request = {
url : URL.parse(data[3], true),
contentType : data[0],
method : data[1],
domain : data[2],
path : data[3]
};
console.log(data[2] + "\t" + aph.process(request).join("\t") + "\t" + data.join("\t"));
})
.on("end", function(){
console.info("done");
});