diff --git a/api.js b/api.js index 6eb0429..67579c7 100644 --- a/api.js +++ b/api.js @@ -15,6 +15,12 @@ var moment = require('moment'); module.exports = { sis: { + fetch: (url, next) => { + request.get("http://sis.rpi.edu/" + url, (err,res,body) => { + if (err) next(err); + else next(null, body); + }); + }, login: (user, pass, next) => { // gets the URL first to initialize the cookie request.get(sources.sis.login, () =>{ diff --git a/routes/sis.js b/routes/sis.js index 308acb0..d53a840 100644 --- a/routes/sis.js +++ b/routes/sis.js @@ -1,6 +1,13 @@ module.exports = function(app, api, auth) { + app.get("/fetch", (req,res) => { + api.fetch(req.query.url, (err,body) => { + if (err) res.status(500).send(err); + else res.send(body); + }) + }); + // The login route has a lot going on; this takes a few key bits of information from SIS at once app.post("/login", (req,res) =>