{"id":18539083,"url":"https://github.com/simov/grant-vercel","last_synced_at":"2026-01-24T16:36:31.209Z","repository":{"id":66028228,"uuid":"282792256","full_name":"simov/grant-vercel","owner":"simov","description":"Vercel Serverless Function handler for Grant","archived":false,"fork":false,"pushed_at":"2021-01-04T09:44:30.000Z","size":7,"stargazers_count":8,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-12-26T04:20:43.657Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Makefile","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/simov.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":"2020-07-27T04:17:12.000Z","updated_at":"2024-02-01T00:17:00.000Z","dependencies_parsed_at":null,"dependency_job_id":"e41d1a78-62dc-4153-8aaf-dc27c98fbce8","html_url":"https://github.com/simov/grant-vercel","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/simov%2Fgrant-vercel","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simov%2Fgrant-vercel/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simov%2Fgrant-vercel/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simov%2Fgrant-vercel/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/simov","download_url":"https://codeload.github.com/simov/grant-vercel/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239255308,"owners_count":19608251,"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-11-06T19:46:09.436Z","updated_at":"2025-11-01T04:30:20.181Z","avatar_url":"https://github.com/simov.png","language":"Makefile","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# grant-vercel\n\n\u003e _Vercel Serverless Function handler for **[Grant]**_\n\n```js\nvar grant = require('grant').vercel({\n  config: {/*configuration - see below*/}, session: {secret: 'grant'}\n})\n\nmodule.exports = async (req, res) =\u003e {\n  var {response} = await grant(req, res)\n  if (response) {\n    res.statusCode = 200\n    res.setHeader('content-type', 'application/json')\n    res.end(JSON.stringify(response))\n  }\n}\n```\n\n\u003e _Also available for [AWS], [Azure], [Google Cloud]_\n\n\u003e _[ES Modules and TypeScript][grant-types]_\n\n---\n\n## Configuration\n\nThe `config` key expects your [**Grant** configuration][grant-config].\n\n#### vercel.json\n\nThe following optional routing is used in all examples:\n\n```json\n{\n  \"rewrites\": [\n    {\"source\": \"/(.*)\", \"destination\": \"/api/grant\"}\n  ]\n}\n```\n\n#### .vercel\n\nYou need a `.vercel` folder containing a `project.json` file in every example:\n\n```json\n{\"orgId\":\"...\",\"projectId\":\"...\"}\n```\n\n---\n\n## Routing\n\nYou login by navigating to:\n\n```\nhttps://[PROJECT].vercel.app/connect/google\n```\n\nThe redirect URL of your OAuth app have to be set to:\n\n```\nhttps://[PROJECT].vercel.app/connect/google/callback\n```\n\nAnd locally:\n\n```\nhttp://localhost:3000/connect/google\nhttp://localhost:3000/connect/google/callback\n```\n\n---\n\n## Session\n\nThe `session` key expects your session configuration:\n\nOption | Description\n:- | :-\n`name` | Cookie name, defaults to `grant`\n`secret` | Cookie secret, **required**\n`cookie` | [cookie] options, defaults to `{path: '/', httpOnly: true, secure: false, maxAge: null}`\n`store` | External session store implementation\n\n#### NOTE:\n\n- The default cookie store is used unless you specify a `store` implementation!\n- Using the default cookie store **may leak private data**!\n- Implementing an external session store is recommended for production deployments!\n\nExample session store implementation using [Firebase]:\n\n```js\nvar request = require('request-compose').client\n\nvar path = process.env.FIREBASE_PATH\nvar auth = process.env.FIREBASE_AUTH\n\nmodule.exports = {\n  get: async (sid) =\u003e {\n    var {body} = await request({\n      method: 'GET', url: `${path}/${sid}.json`, qs: {auth},\n    })\n    return body\n  },\n  set: async (sid, json) =\u003e {\n    await request({\n      method: 'PATCH', url: `${path}/${sid}.json`, qs: {auth}, json,\n    })\n  },\n  remove: async (sid) =\u003e {\n    await request({\n      method: 'DELETE', url: `${path}/${sid}.json`, qs: {auth},\n    })\n  },\n}\n```\n\n---\n\n## Handler\n\nThe AWS Lambda handler for Grant accepts:\n\nArgument | Type | Description\n:- | :- | :-\n`req` | **required** | The request object\n`res` | **required** | The response object\n`state` | optional | [Dynamic State][grant-dynamic-state] object `{dynamic: {..Grant configuration..}}`\n\nThe AWS Lambda handler for Grant returns:\n\nParameter | Availability | Description\n:- | :- | :-\n`session` | Always | The session store instance, `get`, `set` and `remove` methods can be used to manage the Grant session\n`redirect` | On redirect only | HTTP redirect controlled by Grant, it is set to `true` when Grant is going to handle the redirect internally\n`response` | Based on transport | The [response data][grant-response-data], available for [transport-state][example-transport-state] and [transport-session][example-transport-session] only\n\n---\n\n## Examples\n\nExample | Session | Callback λ\n:- | :- | :-\n`transport-state` | Cookie Store | ✕\n`transport-querystring` | Cookie Store | ✓\n`transport-session` | Firebase Session Store | ✓\n`dynamic-state` | Firebase Session Store | ✕\n\n\u003e _Different session store types were used for example purposes only._\n\n#### Configuration\n\nAll variables at the top of the [`Makefile`][example-makefile] with value set to `...` have to be configured:\n\n- `token` - Vercel Token\n\nThe [transport-session][example-transport-session] and the [dynamic-state][example-dynamic-state] examples requires your [Firebase] configuration to be set in `vercel.json`:\n\n```json\n{\n  \"env\": {\n    \"FIREBASE_PATH\": \"...\",\n    \"FIREBASE_AUTH\": \"...\"\n  }\n}\n```\n\n- `firebase_path` - [Firebase] path of your database\n\n```\nhttps://[project].firebaseio.com/[prefix]\n```\n\n- `firebase_auth` - [Firebase] auth key of your database\n\n```json\n{\n  \"rules\": {\n    \".read\": \"auth == '[key]'\",\n    \".write\": \"auth == '[key]'\"\n  }\n}\n```\n\nAll variables can be passed as arguments to `make` as well:\n\n```bash\nmake plan example=transport-querystring ...\n```\n\n---\n\n## Develop\n\n```bash\n# build example locally\nmake build-dev\n# run example locally\nmake run-dev\n```\n\n---\n\n## Deploy\n\n```bash\n# deploy Grant\nmake deploy\n```\n\n---\n\n  [Grant]: https://github.com/simov/grant\n  [AWS]: https://github.com/simov/grant-aws\n  [Azure]: https://github.com/simov/grant-azure\n  [Google Cloud]: https://github.com/simov/grant-gcloud\n  [Vercel]: https://github.com/simov/grant-vercel\n\n  [cookie]: https://www.npmjs.com/package/cookie\n  [Firebase]: https://firebase.google.com/\n\n  [grant-config]: https://github.com/simov/grant#configuration\n  [grant-dynamic-state]: https://github.com/simov/grant#dynamic-state\n  [grant-response-data]: https://github.com/simov/grant#callback-data\n  [grant-types]: https://github.com/simov/grant#misc-es-modules-and-typescript\n\n  [example-makefile]: https://github.com/simov/grant-vercel/tree/master/Makefile\n  [example-transport-state]: https://github.com/simov/grant-vercel/tree/master/examples/transport-state\n  [example-transport-querystring]: https://github.com/simov/grant-vercel/tree/master/examples/transport-querystring\n  [example-transport-session]: https://github.com/simov/grant-vercel/tree/master/examples/transport-session\n  [example-dynamic-state]: https://github.com/simov/grant-vercel/tree/master/examples/dynamic-state\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimov%2Fgrant-vercel","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsimov%2Fgrant-vercel","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimov%2Fgrant-vercel/lists"}