Fakultas Ilmu Komputer UI

Commit ba1e9c36 authored by Naufaldi Athallah Rifqi's avatar Naufaldi Athallah Rifqi
Browse files

endpoint ticket

parent 0991be43
......@@ -2,6 +2,8 @@
const express = require('express');
const bodyParser = require('body-parser');
const axios = require("axios");
var parser = require('xml2json-light');
// Constants
const PORT = 8000;
......@@ -20,5 +22,20 @@ app.get('/', (req, res) => {
})
})
app.get("/user/:ticketId", async (req, res, next) => {
const ticket = req.params.ticketId
const URL_REDIRECT = "http://localhost:8000"
try {
const data = await axios.post(
`https://sso.ui.ac.id/cas2/serviceValidate?ticket=${ticket}&service=${URL_REDIRECT}`
)
var json = parser.xml2json(data.data)
console.log(json)
res.send(data)
} catch (error) {
console.log(error)
}
});
app.listen(PORT);
console.log('Server listening on port: ' + PORT);
\ No newline at end of file
......@@ -18,6 +18,14 @@
"resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz",
"integrity": "sha1-ml9pkFGx5wczKPKgCJaLZOopVdI="
},
"axios": {
"version": "0.20.0",
"resolved": "https://registry.npmjs.org/axios/-/axios-0.20.0.tgz",
"integrity": "sha512-ANA4rr2BDcmmAQLOKft2fufrtuvlqR+cXNNinUmvfeSNCOF98PZL+7M/v1zIdGo7OLjEA9J2gXJL+j4zGsl0bA==",
"requires": {
"follow-redirects": "^1.10.0"
}
},
"body-parser": {
"version": "1.19.0",
"resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.19.0.tgz",
......@@ -152,6 +160,11 @@
"unpipe": "~1.0.0"
}
},
"follow-redirects": {
"version": "1.13.0",
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.13.0.tgz",
"integrity": "sha512-aq6gF1BEKje4a9i9+5jimNFIpq4Q1WiwBToeRK5NvZBd/TRsmW8BsJfOEGkr76TbOyPVD3OVDN910EcUNtRYEA=="
},
"forwarded": {
"version": "0.1.2",
"resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.1.2.tgz",
......@@ -293,6 +306,11 @@
"resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg=="
},
"sax": {
"version": "1.2.4",
"resolved": "https://registry.npmjs.org/sax/-/sax-1.2.4.tgz",
"integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw=="
},
"send": {
"version": "0.17.1",
"resolved": "https://registry.npmjs.org/send/-/send-0.17.1.tgz",
......@@ -369,6 +387,19 @@
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz",
"integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw="
},
"xml-js": {
"version": "1.6.11",
"resolved": "https://registry.npmjs.org/xml-js/-/xml-js-1.6.11.tgz",
"integrity": "sha512-7rVi2KMfwfWFl+GpPg6m80IVMWXLRjO+PxTq7V2CDhoGak0wzYzFgUY2m4XJ47OGdXd8eLE8EmwfAmdjw7lC1g==",
"requires": {
"sax": "^1.2.4"
}
},
"xml2json-light": {
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/xml2json-light/-/xml2json-light-1.0.6.tgz",
"integrity": "sha1-ERaHcQorAfvS/hj0GK31Ed5UfzQ="
}
}
}
......@@ -8,8 +8,11 @@
"start": "node index.js"
},
"dependencies": {
"axios": "^0.20.0",
"body-parser": "^1.19.0",
"express": "^4.16.1"
"express": "^4.16.1",
"xml-js": "^1.6.11",
"xml2json-light": "^1.0.6"
},
"repository": {
"type": "git",
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment