{"id":23819853,"url":"https://github.com/kth/kth-node-express-routing","last_synced_at":"2025-06-13T19:05:30.981Z","repository":{"id":45639698,"uuid":"89704709","full_name":"KTH/kth-node-express-routing","owner":"KTH","description":"Define named routes using express routing syntax. Allows exporting route defs javascript object","archived":false,"fork":false,"pushed_at":"2025-04-09T06:44:01.000Z","size":735,"stargazers_count":0,"open_issues_count":1,"forks_count":1,"subscribers_count":17,"default_branch":"main","last_synced_at":"2025-06-13T19:05:19.423Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/KTH.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-04-28T12:37:27.000Z","updated_at":"2025-04-09T06:43:05.000Z","dependencies_parsed_at":"2024-02-19T10:46:31.691Z","dependency_job_id":"3fbd3649-0d6c-4345-8f2a-e6ebe3043a83","html_url":"https://github.com/KTH/kth-node-express-routing","commit_stats":{"total_commits":55,"total_committers":7,"mean_commits":7.857142857142857,"dds":0.5454545454545454,"last_synced_commit":"a07c369729fdc9de49353ff6ea834800b600c92a"},"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"purl":"pkg:github/KTH/kth-node-express-routing","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KTH%2Fkth-node-express-routing","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KTH%2Fkth-node-express-routing/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KTH%2Fkth-node-express-routing/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KTH%2Fkth-node-express-routing/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/KTH","download_url":"https://codeload.github.com/KTH/kth-node-express-routing/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KTH%2Fkth-node-express-routing/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259704410,"owners_count":22898858,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-01-02T07:16:05.817Z","updated_at":"2025-06-13T19:05:30.957Z","avatar_url":"https://github.com/KTH.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# kth-node-express-routing\n\nThis is a wrapper for express route to allow generating named path files for app routes. It is used på KTH node-web projects to pass urls to browser clients.\n\n## PageRouter\n\nPageRouter allows us to register page style routes that are registered in the path definition files.\n\nUsage:\n\n```JavaScript\nconst AppRouter = require('kth-node-express-routing').PageRouter\nconst getPaths = require('kth-node-express-routing').getPaths\nconst server = require('express')()\n\nconst systemRoute = AppRouter()\nsystemRoute.get('system.monitor', '/_monitor', function (req, res) { ... })\nserver.use('/', systemRoute.getRouter())\n\nconst appRoute = AppRouter()\nappRoute.get('app.index', '/', function (req, res) { ... })\nserver.use('/', appRoute.getRouter())\n\nconst paths = getPaths()\n/*\npaths = {\n  system: {\n    monitor: {\n      uri: '/_monitor',\n      method: 'get\n    }\n  },\n  app: {\n    index: {\n      uri: '/',\n      method: 'get\n    }\n  }\n}\n*/\n```\n\n## ApiRouter\n\nApiRouter allows us to register api endpoints by passing api endpoint definition objects from the paths file. It will set req.scope and add the authByApiKey middleware passed to ApiRouter IF the apiDefObj passed below evaluates `apikey.scope_required == true`\n\nUsage in your node-api app:\n\n```JavaScript\n// Middleware to protect enpoints with apiKey\nconst authByApiKey = passport.authenticate('apikey', { session: false })\n\nconst ApiRouter = require('kth-node-express-routing').ApiRouter\nconst apiRoute = ApiRouter(authByApiKey)\n\nconst apiDefObj = {\n  uri: \"/api/node/data/:id/api/node/v1\",\n  method: \"GET\",\n  apikey: {\n    scope_required: true,\n    scopes: [\"read\"],\n    type: \"api_key\"\n  }\n}\n\n// A middleware adding the access scope requriements (req.scope) and the authByApiKey is automatically\n// prepended to the middleware pipeline\napiRoute.register(apiDefObj, function (req, res) { ... })\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkth%2Fkth-node-express-routing","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkth%2Fkth-node-express-routing","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkth%2Fkth-node-express-routing/lists"}