{"id":15939645,"url":"https://github.com/binarykitchen/wants-json","last_synced_at":"2025-04-03T20:21:46.129Z","repository":{"id":25254864,"uuid":"28679901","full_name":"binarykitchen/wants-json","owner":"binarykitchen","description":"Tiny middleware to figure out if a JSON response is expected","archived":false,"fork":false,"pushed_at":"2024-03-26T10:26:30.000Z","size":9,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-09T08:34:38.410Z","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":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/binarykitchen.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2015-01-01T03:36:55.000Z","updated_at":"2024-02-11T18:59:28.000Z","dependencies_parsed_at":"2024-10-29T13:29:12.748Z","dependency_job_id":null,"html_url":"https://github.com/binarykitchen/wants-json","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/binarykitchen%2Fwants-json","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/binarykitchen%2Fwants-json/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/binarykitchen%2Fwants-json/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/binarykitchen%2Fwants-json/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/binarykitchen","download_url":"https://codeload.github.com/binarykitchen/wants-json/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247071034,"owners_count":20878603,"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":"2024-10-07T06:20:29.701Z","updated_at":"2025-04-03T20:21:46.106Z","avatar_url":"https://github.com/binarykitchen.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# wants-json\n\n[![Build Status](https://travis-ci.org/binarykitchen/wants-json.svg?branch=master)](https://travis-ci.org/binarykitchen/wants-json)\n\nA tiny ExpressJS middleware to figure out if a JSON response is expected.\n\nWhen you have a single page app, you probably communicate in JSON with the server. But on the first page load you send the HTML. With this middleware you can distinct between these two requests.\n\n## ExpressJS middleware example for single page apps\n\n```js\nvar wantsJson = require('wants-json'),\n    express   = require('express'),\n    app       = express()\n\napp.use(wantsJson())\n\napp.get('/data', function(req, res, ext) {\n    if (req.wantsJson()) {\n        // load data and send to client\n    } else {\n        // send single page app\n        next \u0026\u0026 next()\n    }\n})\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbinarykitchen%2Fwants-json","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbinarykitchen%2Fwants-json","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbinarykitchen%2Fwants-json/lists"}