Code Monkey home page Code Monkey logo

dsbmobile.js's Introduction

dsbmobile.js

badge badge badge badge badge

A Javascript package for the dsbmobile API

Installation

$ npm install dsbmobile

Example

import Dsbmobile from "dsbmobile";

const dsb = new Dsbmobile("<id>", "<password>");

dsb.getTimetable().then((timetable) => {
    console.log(timetable.entries[0].newSubject);
});
English

Documentation

You can read the docs right here.

Contribute

Feel free to contribute on the Github repository.

Browser issues

The official dsbmobile API doesn't send a CORS header, which is required for Browser requests, due to security reasons.

However, there is a way to bypass it that is not a security tradeoff.

Use https://mydsb.johannespour.de (also on Github) instead.

You can use it like this like this:

new Dsbmobile({
    id: "<id>",
    password: "<password>",
    baseURL: "https://mydsb.johannespour.de",
    resourceBaseURL: "https://mydsb.johannespour.de/light",
});

After that, all requests will not be sent to the official Server, but to the mydsb.johannespour.de one, which will make a request for you to the resource and add a CORS header.

If you are concerned about privacy and other things, you can check out the code, because it's open source.

Incompatible plan

As I only know the layout of my local DSBmobile substitution plan, it is possible that your DSBmobile substitution plan may be incompatible with this package.

If this is the case, please leave a comment below issue #43, in which you describe the layout of your plan, so a solution can be worked out.

dsbmobile.js's People

Contributors

tch1b0 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

dsbmobile.js's Issues

Service Unavailable (503)

Hi, I have used this API for a while, made my own fork of it, and sometimes I am getting the error "Service Unavailable (503)", but I cannot say why, because I never got one with an older JS libary for fetching DSB. I already called Heineking Media and asked them about this error, but they said that this error could not be possible. I am thinking that their services are checking the UserAgent, to check if their app is requesting, or something else. Does anyone else also experienced this, and could someone help me? Thanks!

Broken `Entry.period`

It appears that the property period of Entry isn't parsed right, because it only shows up as NaN

make new subjects shorts customizable

The current subject shorts are hard-coded and don't allow much variation.
The user of this package should be able to add custom subject shorts like this:

dsb.addSubjectShorts(
    new Map([["G", "German"], ["E", "English"]])
);

Add more tests

Currently, there only is 1 test that covers the TimeTable.
There should also be tests for the NewsPostCollection and DocumentPostCollection

Fix class name parsing

When an entry is active for more than one class, it isn't parsed correctly. Most likely some missing comma in the Dom selector

Refactor inconsistent variables

Some variables like resourceApiURL don't feel right when there is also a variable baseURL.
Maybe rename resourceApiURL to resourceBaseURL for example.

Add support for newsletter

The API has the route /newstab.
Add news as a resource and make the Dsbmobile object able to fetch it

Fix import paths

To import for example the Entry class it isn't enough to write

import { Entry } from "dsbmobile"

but you need to write

import { Entry } from "dsbmobile/dist/timetable"

That shouldn't be like that.

Enhance error verbosity

The errors need to provide more information (status codes/messages, etc...) for outside usage.

Add `DsbmobileConfig` interface

At this moment the Dsbmobile constructor is able to receive 5 different arguments, so it is getting a bit confusing.
Make the User able to either create a Dsbmobile instance by passing argument by argument or by passing a config object.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.