Add lucky number endpoint

This commit is contained in:
Mikołaj Pich 2020-02-11 19:31:30 +01:00
parent 2c65544fcb
commit 278dc75535
No known key found for this signature in database
GPG key ID: F62B26E36D4C4BAA
3 changed files with 18 additions and 1 deletions

View file

@ -1,7 +1,10 @@
const router = require('express').Router();
const protocol = require('../utils/connection');
const {format} = require("date-fns");
router.all("/", (req, res) => {
const today = format(new Date(), "yyyy-MM-dd");
let base = protocol(req) + "://" + req.get('host');
res.json({
"status": "success",
@ -16,6 +19,7 @@ router.all("/", (req, res) => {
base + "/powiatwulkanowy/123456/api/mobile/version?app=DzienniczekPlus%202.0",
base + "/powiatwulkanowy/123456/api/mobile/heartbeat",
base + "/powiatwulkanowy/123456/api/mobile/internal/time",
base + "/powiatwulkanowy/123456/api/mobile/school/lucky?constituentId=2&day=" + today,
],
"mobile-api": [
base + "/powiatwulkanowy/mobile-api/Uczen.v3.UczenStart/Certyfikat",
@ -48,6 +52,7 @@ router.use("/powiatwulkanowy/123456/mobile-api/Push.v1.Push", require("./mobile-
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.use("/powiatwulkanowy/123456/api/mobile/school", require("./api/school"));
router.all("/*", (req, res) => {
res.json({

12
src/routes/api/school.js Normal file
View file

@ -0,0 +1,12 @@
const router = require('express').Router({});
const {createEnvelope} = require("./utils");
const {format} = require("date-fns");
router.all("/lucky", (req, res) => {
res.json(createEnvelope(0, "OK", "LuckyNumberPayload", {
"Day": format(new Date(), "yyyy-MM-dd"),
"Number": format(new Date(), "d")
}));
});
module.exports = router;

View file

@ -4,7 +4,7 @@ const {getTime, format} = require("date-fns");
exports.createEnvelope = (statusCode, statusMessage, type, body) => {
return {
"Envelope": body,
"EnvelopeType": "type",
"EnvelopeType": type,
"InResponseTo": null,
"RequestId": uuid(),
"Status": {