repl.it
@426729/

McpsApi

Express

No description

fork
loading
Files
  • index.js
  • account.js
  • db.js
  • Packager files
  • package-lock.json
  • package.json
index.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
34
35
36
37
38
39
40
41
42
43
44
45
//https://github.com/nmittu/MyMCPS-Helper/blob/master/lib/AccountManager.dart
const express = require('express');
const bodyParser = require('body-parser');
// const db = require('./db');

const app = express();

app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));

app.use(express.static('public'));

const SITE_URL = "https://portal.mcpsmd.org/";

app.get('/', (req, res) => {
  res.send('Hello Express app');
});

app.get('/api/c', async (req, res) => {
  const request = request.default({ jar: true });
  const { username, password, classPeriod } = req.query;
  if (username && password && classPeriod) {
    await request({
      uri: SITE_URL
    });
    const loggedIn = await request({
      uri: SITE_URL + "guardian/home.html";
      method: "POST",
      formData: {

      }
    })
  }
  else {
    return res.json({
      error: {//This describes all of the missing values
        username: !username,
        password: !password,
        classPeriod: !classPeriod
      }
    });
  }
});

app.listen(3000, () => console.log('server started'));
?