From b4f4f9fb8beec30009a75570ed6c55b1efcac9cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Pich?= Date: Tue, 11 Feb 2020 18:25:02 +0100 Subject: [PATCH] Add some basic endpoints --- src/routes/api.js | 9 ++++++- src/routes/api/register.js | 2 +- src/routes/api/student.js | 55 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 64 insertions(+), 2 deletions(-) create mode 100644 src/routes/api/student.js diff --git a/src/routes/api.js b/src/routes/api.js index dc150cd..7e6f85b 100644 --- a/src/routes/api.js +++ b/src/routes/api.js @@ -10,7 +10,12 @@ router.all("/", (req, res) => { "sdk": "https://github.com/wulkanowy/sdk", "docs": "https://gitlab.com/erupcja/uonet-api-docs", "api": [ - base + "/powiatwulkanowy/api/mobile/register/new" + base + "/powiatwulkanowy/api/mobile/register/new", + base + "/powiatwulkanowy/api/mobile/register/hebe", + base + "/powiatwulkanowy/123456/api/mobile/register/hebe", + base + "/powiatwulkanowy/123456/api/mobile/version?app=DzienniczekPlus%202.0", + base + "/powiatwulkanowy/123456/api/mobile/heartbeat", + base + "/powiatwulkanowy/123456/api/mobile/internal/time", ], "mobile-api": [ base + "/powiatwulkanowy/mobile-api/Uczen.v3.UczenStart/Certyfikat", @@ -41,6 +46,8 @@ router.use("/powiatwulkanowy/123456/mobile-api/Push.v1.Push", require("./mobile- // hebe router.use("/powiatwulkanowy/api/mobile/register", require("./api/register")); +router.use("/powiatwulkanowy/123456/api/mobile/register", require("./api/register")); +router.use("/powiatwulkanowy/123456/api/mobile", require("./api/student")); router.all("/*", (req, res) => { res.json({ diff --git a/src/routes/api/register.js b/src/routes/api/register.js index 9ae26f6..0271fbd 100644 --- a/src/routes/api/register.js +++ b/src/routes/api/register.js @@ -25,7 +25,7 @@ router.all("/new", (req, res) => { }); }); -router.get("/hebe", (req, res) => { +router.all("/hebe", (req, res) => { res.json({ "Envelope": { "Capabilities": [ diff --git a/src/routes/api/student.js b/src/routes/api/student.js new file mode 100644 index 0000000..10d59d5 --- /dev/null +++ b/src/routes/api/student.js @@ -0,0 +1,55 @@ +const router = require('express').Router({}); +const uuid = require("uuid"); +const {getTime, format} = require("date-fns"); + +router.all("/version", (req, res) => { + res.json({ + "Envelope": null, + "EnvelopeType": "Object", + "InResponseTo": null, + "RequestId": uuid(), + "Status": { + "Code": 105, + "Message": "Podany czas jest nieprawidłowy" + }, + "Timestamp": getTime(new Date()), + "TimestampFormatted": format(new Date(), "yyyy-MM-dd HH:mm:ss") + }); +}); + +router.all("/internal/time", (req, res) => { + res.json({ + "Envelope": { + "Date": format(new Date(), "yyyy-MM-dd"), + "DateDisplay": format(new Date(), "dd.MM.yyyy"), + "Time": format(new Date(), "HH:mm:ss"), + "Timestamp": getTime(new Date()) + }, + "EnvelopeType": "DateInfoPayload", + "InResponseTo": null, + "RequestId": uuid(), + "Status": { + "Code": 0, + "Message": "OK" + }, + "Timestamp": getTime(new Date()), + "TimestampFormatted": format(new Date(), "yyyy-MM-dd HH:mm:ss") + }); +}); + +router.all("/heartbeat", (req, res) => { + res.json({ + "Envelope": true, + "EnvelopeType": "Boolean", + "InResponseTo": null, + "RequestId": uuid(), + "Status": { + "Code": 0, + "Message": "OK" + }, + "Timestamp": getTime(new Date()), + "TimestampFormatted": format(new Date(), "yyyy-MM-dd HH:mm:ss") + }); +}); + +module.exports = router;