{"id":15498732,"url":"https://github.com/jankapunkt/meteor-method-factory","last_synced_at":"2026-04-27T21:31:51.574Z","repository":{"id":81102685,"uuid":"95552708","full_name":"jankapunkt/meteor-method-factory","owner":"jankapunkt","description":"A common factory to create standardized validated methods.","archived":false,"fork":false,"pushed_at":"2017-12-06T16:21:33.000Z","size":26,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-28T17:27:00.966Z","etag":null,"topics":["factory","meteor","meteor-method","validated-method"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jankapunkt.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":"2017-06-27T11:48:12.000Z","updated_at":"2017-07-20T15:08:06.000Z","dependencies_parsed_at":null,"dependency_job_id":"678b9c7f-c091-42c9-b9a6-35828af0bb08","html_url":"https://github.com/jankapunkt/meteor-method-factory","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/jankapunkt/meteor-method-factory","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jankapunkt%2Fmeteor-method-factory","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jankapunkt%2Fmeteor-method-factory/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jankapunkt%2Fmeteor-method-factory/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jankapunkt%2Fmeteor-method-factory/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jankapunkt","download_url":"https://codeload.github.com/jankapunkt/meteor-method-factory/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jankapunkt%2Fmeteor-method-factory/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32356598,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-27T20:07:02.737Z","status":"ssl_error","status_checked_at":"2026-04-27T20:07:00.910Z","response_time":128,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: 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":["factory","meteor","meteor-method","validated-method"],"created_at":"2024-10-02T08:47:29.033Z","updated_at":"2026-04-27T21:31:51.555Z","avatar_url":"https://github.com/jankapunkt.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.org/jankapunkt/meteor-method-factory.svg?branch=master)](https://travis-ci.org/jankapunkt/meteor-method-factory)\n[![Project Status: Active – The project has reached a stable, usable state and is being actively developed.](http://www.repostatus.org/badges/latest/active.svg)](http://www.repostatus.org/#active)\n\n\n# Meteor Method Factory\n\nCreate validated method by given input.\n\n## Roadmap\n\nTODO / TO BE IMPLEMENTED\n\n- checkRoles\n- hooks (before, after)\n- wrap params for main functions into object with attributes\n- applyOptions as parameter\n- pass Schema as optional param in order to omit dependencies between Mongo.Collection and SimpleSchema (for those who don't use collection2-core)\n- update method for custom fields, in order to not require to update the whole document for now\n\n\n## Changelog\n\n0.1.2 - Added and tested `getCloneMethodDefault`\n\n0.1.1 - Method validations are now rethrowing errors as meteor errors with detailed information.\n\n\n## API\n\n\n### Main Functions\n\n######General\n\n- All the functions make use of [mdg:validated-method](https://github.com/meteor/validated-method) and require a Mongo.Collection instance and a method name.\n- Before generating the method, there is a call to `checkCollection` to avoid runtime errors regarding missing collections.\n- All methods validate by the Mongo.Collection schema. Make sure you have a Schema attached to each collection.\n- Validation errors are rethrown as Meteor.Error in order to give clients more transparency about failures.\n- User access is checked at runtime (TODO: add also optional roles checking)\n- The Method call parameter describes the parameters, that are necessary to be passed when using `Meteor.call`\n\n###### getInsertMethodDefault(Mongo.Collection collection, String methodName)\n\nCreates and returns a validated insert method, that adds inserts a (schema-valid) document into the given collection\n\nMethod call parameter: Object insertDoc (without _id and all fields required by collection schema)\n\nNote: denies documents that have already have an ID and thus exist in the database. If you want to clone existing documentes use `getCloneMethodDefault`.\n\n\n###### getUpdateMethodDefault(Mongo.Collection collection, String methodName)\n\nCreates and returns a validated update method, that adds updates a (schema-valid) document into the given collection.\n\nMethod call parameter: Object updateDoc (with _id and all fields required by collection schema)\n\nNote: this method needs all required fields of the schema to be present in the updateDoc, including the _id. It is a full-document update. \n\n###### getAutoFormUpdateMethod(Mongo.Collection collection, String methodName)\n\nCreates and returns a validated update method, that is conform the the aldeed:autoform method-update schema.\n\n\nMethod call parameter: \n\nObject updateDoc with schema\n\nupdateDoc._id - the id of the doc to be updated\nupdateDoc.modifier - the doc to be updated including all fields required by the schema.\n\nSee [aldeed:autoform - method-update](https://github.com/aldeed/meteor-autoform#method-update) for more\n\n###### getRemoveMethodDefault(Mongo.Collection collection, String methodName)\n\nCreates and returns a validated remove method, that is conform that removes a document by a given id.\n\nMethod call parameter: {_id:String}\n\n###### getFindOneMethodDefault(Mongo.Collection collection, String methodName)\n\nCreates and returns a validated method to find a single document by id.\n\nMethod call parameter: {_id:String}\n\n###### getCloneMethodDefault(Mongo.Collection collection, String methodName)\n\nCreates and returns a validated insert method, that inserts a (schema-valid) document into the given collection by an existing document, using an exact copy of it's field entries.\n\nMethod call parameter: Object insertDoc (witg _id and all fields required by collection schema)\n\n\n###### rateLimit([ValiatedMethod] methods, Number maxCount = 5, Number timeOut = 1000)\n\nBasically the rateLimit form the meteor example projects. Requires your created validated methods as an array in order to rate limit their calls.\n\n### Helpers\n\n###### checkUser(String userId)\n\nChecks if the given user by userId is a) not undefined and b) exists within the current applications user collection.\n \nReturns true, if successful. Throws Errors, if failing.\n\n###### checkSchema(SimpleSchema schema)\n\nChecks, whether a given schema is an instance of `SimpleSchema`. It does not check the schema validity, which is done in each validate method.\nThrows Errors, if failing.\n\n###### checkCollection(Mongo.Collection collection)\n\nChecks, whether a given collection is a Mongo.Collection (or extending it.)\nThrows Errors, if failing.\n\n###### checkDoc(Object doc, Mongo.Collection collection)\n\nChecks, whether the given doc exists in the given collection.\n\n### ALLOW/DENY\n\nNote: that it is suggested to NOT use client side allow/deny and thus deny all client actions. \nHowever, if you can't resist or for whatever good reason need to use them, here are some handy generic functions to create them.\nNote2: makes use of [alanning:roles](https://github.com/alanning/meteor-roles) in order to verify client side db access. Roles require an array of strings as roles and a string as name of the group/domain.\n \n###### getDefaultAllowSettings(Mongo.Collection collection, [String] roles, String domain)\n\nReturns an object with insert, update and remove functions, created by `getAllowInsert`, `getAllowUpdate` and `getAllowRemove`.\nBy doing so, it uses the same collection/roles/domain settings for all the three sub-calls.\n\n\n###### getAllowInsert(Mongo.Collection collection, [String] roles, String domain)\n\nCreates an insert allow method for the given collection, roles and domain.\n\n###### getAllowUpdate(Mongo.Collection collection, [String] roles, String domain)\n\nCreates an update allow method for the given collection, roles and domain.\n\n###### getAllowRemove(Mongo.Collection collection, [String] roles, String domain)\n\nCreates a remove allow method for the given collection, roles and domain.\n\n\n\n## Contributions\n\n### General\n\nPR and feature requests are very welcome. Please use the included `test` project to verify your new written code.\n\n### Dependencies\n\nIf you create new dependencies, please check, if they are really necessary.\n\n### Testing\n\nYou can either use watch mode tests or cli tests. In any case you need to cd into the project's test project and install the dependencies first.\n\n```bash\ncd meteor-method-factory/tests\nmeteor npm install\n```\n\nFor watch mode call\n\n```bash\nmeteor npm run test\n```\n\nFor cli mode call\n\n```bash\nmeteor reset #cleans the project and avoids the 'missing select error'\nmeteor npm run testcli\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjankapunkt%2Fmeteor-method-factory","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjankapunkt%2Fmeteor-method-factory","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjankapunkt%2Fmeteor-method-factory/lists"}