{"id":17358921,"url":"https://github.com/tannerkrewson/simple-job-queue","last_synced_at":"2025-10-25T09:12:31.281Z","repository":{"id":80582257,"uuid":"124969933","full_name":"tannerkrewson/simple-job-queue","owner":"tannerkrewson","description":"a simple job queue in node","archived":false,"fork":false,"pushed_at":"2018-03-13T22:52:59.000Z","size":25,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-01T19:45:00.551Z","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/tannerkrewson.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":"2018-03-13T00:44:27.000Z","updated_at":"2018-03-13T22:53:00.000Z","dependencies_parsed_at":null,"dependency_job_id":"3a1dcf71-e3c9-4fda-97a3-94aa475bc79e","html_url":"https://github.com/tannerkrewson/simple-job-queue","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/tannerkrewson%2Fsimple-job-queue","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tannerkrewson%2Fsimple-job-queue/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tannerkrewson%2Fsimple-job-queue/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tannerkrewson%2Fsimple-job-queue/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tannerkrewson","download_url":"https://codeload.github.com/tannerkrewson/simple-job-queue/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245878924,"owners_count":20687297,"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-15T19:07:32.402Z","updated_at":"2025-10-25T09:12:31.185Z","avatar_url":"https://github.com/tannerkrewson.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# simple-job-queue\n\n## Install\n1. Run MySQL on the default port (3306) with the following properties:\n```\nhost     : 'localhost'\nuser     : 'root'\npassword : 'password'\n// If you need to use a different user, change the settings in /controllers/queue.js.\n```\n2. Run the following commands to prep the database:\n```\nCREATE DATABASE `simple-job-queue`;\nUSE `simple-job-queue`;\nCREATE TABLE `jobs` (\n  `id` bigint(11) NOT NULL AUTO_INCREMENT,\n  `status` tinyint(4) DEFAULT NULL,\n  `url` text,\n  `result` longtext,\n  PRIMARY KEY (`id`),\n  UNIQUE KEY `id_UNIQUE` (`id`)\n);\n```\n3. Run this command: `npm install`.\n4. Finally, to start the server, run: `npm start`.\n\n## Usage\nGo to `localhost:3000` to use an HTML interface to interact with the API.\n\n### Queue new job\nGiven a URL, creates a new job to fetch its content. Returns the id of the job.\n\n* **URL:** `/job`\n\n* **Method:** `POST`\n\n* **Data Params**\n\t* `url`: string with a HTTP/HTTPS URL\n\n* **Success Response:**\n\t* `201 Created`\n\t\t* **Content:** `{\"id\":13,\"url\":\"http://google.com/\"}`\n\n* **Error Response:**\n\t* `400 Bad Request`: Bad URL\n\t* `500 Internal Server Error`: Failed to add to database\n\n### Check job status\nGiven a valid job id, returns the status, and if the job was successful, its\nresults.\n\n* **Job Status Codes**\n\t* `0`: Job not completed, still in queue\n\t* `1`: Job was successful, results present in request\n\t* `-1`: Job failed\n\n* **URL:** `/job`\n\n* **Method:** `GET`\n\n* **URL Params**\n\t* `?id=[integer]`: id of a job\n\n* **Success Response:**\n\t* `200 OK`\n\t\t* **Content:** `{\"id\":13,\"status\":1,\"url\":\"http://google.com/\",\"result\":\"\u003cHTML\u003e...\u003c/HTML\u003e\"}`\n\n* **Error Response:**\n\t* `404 Not Found`: Invalid job id\n\n## Implementation\nAn [async](https://github.com/caolan/async) queue is used in\n`/controllers/queue.js`. Not only does it queue up fetches, but it also queues\nany interaction with the database.\n\nIf this project were to be developed further, here are a few things I would\nwant to add:\n* Abstract database credentials into a config file or NODE_ENV.\n* Secure from MySQL injections\n* More informative job status codes\n* Store the queue in the database itself in case the server crashes\n* Store job result in a separate table\n* Add tests for internal functions, as well as the external API itself\n* Use a different kind of id for jobs\n* Endpoint for getting multiple or all jobs\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftannerkrewson%2Fsimple-job-queue","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftannerkrewson%2Fsimple-job-queue","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftannerkrewson%2Fsimple-job-queue/lists"}