Add some basic endpoints

This commit is contained in:
Mikołaj Pich 2020-02-11 18:25:02 +01:00
parent 0a1b3e897a
commit b4f4f9fb8b
No known key found for this signature in database
GPG key ID: F62B26E36D4C4BAA
3 changed files with 64 additions and 2 deletions

View file

@ -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({

View file

@ -25,7 +25,7 @@ router.all("/new", (req, res) => {
});
});
router.get("/hebe", (req, res) => {
router.all("/hebe", (req, res) => {
res.json({
"Envelope": {
"Capabilities": [

55
src/routes/api/student.js Normal file
View file

@ -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;