You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

57 lines
1.6 KiB

  1. /*
  2. * vertretungsplan.io custom crawler
  3. * Copyright (C) 2019 Jonas Lochmann
  4. *
  5. * This program is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU Affero General Public License as
  7. * published by the Free Software Foundation, version 3 of the
  8. * License.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU Affero General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU Affero General Public License
  16. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  17. */
  18. import { Router } from 'express'
  19. import { wrapCrawler } from '../crawlutil'
  20. import { InstitutionElement } from '../element'
  21. import { crawl } from './crawler'
  22. export function domgymVerdenElementCreator (): InstitutionElement {
  23. const router = Router()
  24. const crawlUtil = wrapCrawler(() => crawl())
  25. router.get('/config/default', (_, res) => {
  26. res.json({
  27. config: [ /* no parameters */ ],
  28. configValidationConditionId: '_true',
  29. contentBucketSets: [
  30. {
  31. id: 'default',
  32. usageConditionId: '_true',
  33. type: 'content'
  34. }
  35. ],
  36. conditionSets: [ /* nothing */ ]
  37. })
  38. })
  39. router.get('/content/default', (_, res, next) => {
  40. crawlUtil.getLastSuccessPromise().then((data) => {
  41. res.json(data)
  42. }).catch((ex) => next(ex))
  43. })
  44. return {
  45. id: 'domgym-verden',
  46. title: 'Domgymnasium Verden',
  47. router,
  48. getStatus: () => crawlUtil.getLastPromise()
  49. }
  50. }