Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handler for LM services #189

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

Handler for LM services #189

wants to merge 5 commits into from

Conversation

jokd
Copy link
Contributor

@jokd jokd commented Nov 5, 2024

Fixes #190
Simplifies access to services from Lantmäteriet

Some origo server middleman (not included):

const lmservices = require('./lmservices.js');

const getStuff = async (req, res) => {
  const typ = req.query.typ;
  const fastighet = req.query.fastighet;
  const id = req.query.id || [];
  const hasAccess = await checkAccess();
  if(hasAccess){
    console.log("Has access");
    const response = await lmservices({ typ, fastighet, id, includeData: 'total' })
    res.json(response);
  } else {
    console.log("No access");
	res.send();
  }
}

Requested like:
requestHandler?fastighet=XXXX-XXXX-XXXX-XXXX&typ=fastighetsamfallighet,markreglerandebestammelse

@jokd jokd changed the title Lmservices Handler for LM services Nov 5, 2024
@johnnyblasta
Copy link
Contributor

Tested and got an error for gemensamhetsanlaggning when using 909a6a80-de09-90ec-e040-ed8f66444c3f

C:\Test\origo-server-lmservices\handlers\lmservices.js:114
                if (response2.rattighet.features?.length > 0) {
                                        ^

TypeError: Cannot read properties of undefined (reading 'features')
    at lmservices (C:\Test\origo-server-lmservices\handlers\lmservices.js:114:41)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async getStuff (C:\Test\origo-server-lmservices\handlers\getstuff.js:7:20)

@jokd
Copy link
Contributor Author

jokd commented Dec 9, 2024

Tested and got an error for gemensamhetsanlaggning when using 909a6a80-de09-90ec-e040-ed8f66444c3f

C:\Test\origo-server-lmservices\handlers\lmservices.js:114
                if (response2.rattighet.features?.length > 0) {
                                        ^

TypeError: Cannot read properties of undefined (reading 'features')
    at lmservices (C:\Test\origo-server-lmservices\handlers\lmservices.js:114:41)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async getStuff (C:\Test\origo-server-lmservices\handlers\getstuff.js:7:20)

Have you set up rattighet as well? I pushed a commit that should solve it for you. There may be more similar cases though...

@johnnyblasta
Copy link
Contributor

Have you set up rattighet as well? I pushed a commit that should solve it for you. There may be more similar cases though...

Thanks, now it works! Yes, have tested with all 8 services.

@johnnyblasta
Copy link
Contributor

Some documentation would be nice even though there is no handler it be nice to know it exists and how it can be used.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Handler for LM services
2 participants