REST Service for POPCORN - ILIAS
3dc8dc57b32b22284131396f7e4f880c813180be..24e2d3d3400dcdc84cd4659d2710e83e97a5700c
81 mins ago alex
adding route /api/ping
24e2d3 diff | tree
82 mins ago alex
adding route /api/ping
b512ec diff | tree
84 mins ago alex
adding route /api/ping
edcf60 diff | tree
98 mins ago alex
cleanup
b9ca09 diff | tree
3 files modified
1 files added
60 ■■■■■ changed files
app.js 12 ●●●●● patch | view | raw | blame | history
test/testAbmelden.js 6 ●●●● patch | view | raw | blame | history
test/testAnmelden.js 2 ●●● patch | view | raw | blame | history
test/testApiPing.js 40 ●●●●● patch | view | raw | blame | history
app.js
@@ -75,7 +75,6 @@
      })
   })
/////// USER ////////////////////////////////////////////////////////////////
fastify
@@ -338,6 +337,17 @@
      }
   })
   /////// system ////////////////////////////////////////////////////////////////
   .get("/api/ping", async function (req, res) {
      try {
         const res2 = await libIlias.ping()
         return res.send(res2)
      } catch (err) {
         console.error(err)
         return res.code(500).send({status: "error", error: err.toString()})
      }
   })
/////// STATIC / SPA ////////////////////////////////////////////////////////////////
test/testAbmelden.js
@@ -7,7 +7,7 @@
/////////////////////////////////////////////////////////////////////////
describe("the function anmelden", function () {
describe.skip("the function anmelden", function () {
   const kurs = testData.kurs // TODO
   const user = testData.user
@@ -18,12 +18,12 @@
   beforeEach(async function () {
      // const {usr_id:userId} = await libIlias.importIliasUser(user)
      const userRes  = await libIlias.importIliasUser(user)
      const kursRes  = await libIlias.
      // const kursRes  = await libIlias.
      console.log(data)
   })
   afterEach(async function () {
      // await libIlias.deleteUser(userId)
      await libIlias.deleteUser(userId)
      // TODO delete kurs
   })
test/testAnmelden.js
@@ -7,7 +7,7 @@
/////////////////////////////////////////////////////////////////////////
describe("the function anmelden", function () {
describe.skip("the function anmelden", function () {
   const kurs = testData.kurs // TODO
   const user = testData.user
test/testApiPing.js
New file
@@ -0,0 +1,40 @@
const expect = require("chai").expect
const settings = require("../settings")
/////////////////////////////////////////////////////////////////////////
function getUrl(ref_id) {
    return `http://localhost:${settings.port}/api/ping?token=${settings.authtoken}`
}
const ref_id = 595
describe("using the API", function () {
    describe("the Route GET /api/ping", function () {
        it("should return an answer from php component", async function () {
            const url = getUrl(ref_id)
            console.log(url)
            const res = await fetch(url, {
                method: "GET",
                // body: JSON.stringify({}),
                headers: {
                    'Content-Type': 'application/json', // Indicate JSON data
                },
            })
            const data = await res.json()
            // console.log(data)
            expect(data).to.be.a("object")
            expect(data.status).to.equal("ok")
            expect(data.msg).to.equal("pong")
        })
    })
})
/////////////////////////////////////////////////////////////////////////