{"id":49003288,"url":"https://github.com/maelswarm/tasty-cookie","last_synced_at":"2026-04-18T19:07:35.682Z","repository":{"id":57376516,"uuid":"108247047","full_name":"maelswarm/tasty-cookie","owner":"maelswarm","description":null,"archived":false,"fork":false,"pushed_at":"2018-11-26T17:57:08.000Z","size":565,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-25T07:59:32.082Z","etag":null,"topics":["authentication","cookie","nodejs"],"latest_commit_sha":null,"homepage":"","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/maelswarm.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}},"created_at":"2017-10-25T09:15:28.000Z","updated_at":"2018-11-26T17:57:10.000Z","dependencies_parsed_at":"2022-08-26T12:50:35.920Z","dependency_job_id":null,"html_url":"https://github.com/maelswarm/tasty-cookie","commit_stats":null,"previous_names":["roecrew/tasty-cookie"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/maelswarm/tasty-cookie","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maelswarm%2Ftasty-cookie","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maelswarm%2Ftasty-cookie/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maelswarm%2Ftasty-cookie/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maelswarm%2Ftasty-cookie/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/maelswarm","download_url":"https://codeload.github.com/maelswarm/tasty-cookie/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maelswarm%2Ftasty-cookie/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31980847,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-18T17:30:12.329Z","status":"ssl_error","status_checked_at":"2026-04-18T17:29:59.069Z","response_time":103,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["authentication","cookie","nodejs"],"created_at":"2026-04-18T19:07:34.077Z","updated_at":"2026-04-18T19:07:35.645Z","avatar_url":"https://github.com/maelswarm.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# tasty-cookie\n\n## Quickstart\n\nDownload mongodb.\n\nRun ```mongod --dbpath \u003cpath to database\u003e```\n\nMake a new project, and run the example below.\n\nIf you actually end up using this module for development purposes, then use HTTPS!\n\n## Database Structure\n\n    database-----collections-----documents\n    \n    \"yourdb\"---.\n               |---\"users\"---.\n               |             |---\"username\"               \n               |             |---\"password\"               \n               |             |---\"cookie\"               \n               |               \n               `---\"sessions\"---.               \n                                |---\"stamp\"                                \n                                |---\"cookie\"\n\n## Example\n\n```js\n\nconst key = \"mylittleponymylittlepony\";\nconst dbpath = \"mongodb://127.0.0.1:27017/mydb\";\nconst refresh = 5000; // 5 seconds\nconst cookielifespan = 60000; // 1 minute\n\nconst express = require('express');\nconst TastyCookie require('tasty-cookie');\nconst bodyParser require('body-parser');\nconst authentication = express.Router();\nconst login = express.Router();\nconst app = express();\n\napp.use(bodyParser.json());\napp.use(bodyParser.urlencoded({ extended: true }));\n\nTastyCookie.init(dbpath, key, timeout, cookielifespan);\n\nlogin.use(function (req, res, next) {\n  TastyCookie.login(req.body.un, req.body.pw, function(cookie) {\n    req.body.myCookie = cookie;\n    next();\n  });\n});\n\nauthentication.use(function (req, res, next) {\n  TastyCookie.authenticate(req.body.myCookie, function(e) {\n    e ? next() : res.send(\"Better luck next time!\");\n  });\n});\n\napp.post(\"/auth\", authentication, function(req, res) {\n  res.send('You did it!');\n});\n\napp.post(\"/login\", login, function(req, res) {\n  res.send('Logged in!\u003cform action=\"/auth\" method=\"post\"\u003e\u003cinput type=\"hidden\" name=\"myCookie\" value=\"'+req.body.myCookie+'\"\u003e\u003cinput type=\"submit\"\u003e\u003c/form\u003e');\n});\n\napp.get(\"/\", function(req, res) {\n  res.send('Hello World!\u003cform action=\"/login\" method=\"post\"\u003e\u003cinput type=\"text\" name=\"un\" value=\"\"\u003e\u003cinput type=\"text\" name=\"pw\" value=\"\"\u003e\u003cinput type=\"submit\"\u003e\u003c/form\u003e');\n});\n\napp.listen(8080, function() {\n  console.log(\"Listening on port 8080!\");\n});\n\nprocess.on(\"SIGINT\", function() {\n  console.log(\"\\nSIGINT Closing App.\");\n  TastyCookie.close();\n  process.exit();\n});\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaelswarm%2Ftasty-cookie","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmaelswarm%2Ftasty-cookie","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaelswarm%2Ftasty-cookie/lists"}