{"id":18084824,"url":"https://github.com/coderofsalvation/coffeerest-api","last_synced_at":"2025-07-09T09:15:53.592Z","repository":{"id":57202807,"uuid":"42232353","full_name":"coderofsalvation/coffeerest-api","owner":"coderofsalvation","description":"Api scaffolding from a model specification in few lines OH MY (coffeescript)","archived":false,"fork":false,"pushed_at":"2020-05-28T18:45:01.000Z","size":9528,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-14T00:36:13.912Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"CoffeeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/coderofsalvation.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"custom":"https://gumroad.com/l/hGYGh"}},"created_at":"2015-09-10T08:29:40.000Z","updated_at":"2020-05-28T18:45:03.000Z","dependencies_parsed_at":"2022-09-15T13:22:45.015Z","dependency_job_id":null,"html_url":"https://github.com/coderofsalvation/coffeerest-api","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/coderofsalvation%2Fcoffeerest-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coderofsalvation%2Fcoffeerest-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coderofsalvation%2Fcoffeerest-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coderofsalvation%2Fcoffeerest-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/coderofsalvation","download_url":"https://codeload.github.com/coderofsalvation/coffeerest-api/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247415976,"owners_count":20935387,"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-31T15:08:20.057Z","updated_at":"2025-04-06T00:13:24.728Z","avatar_url":"https://github.com/coderofsalvation.png","language":"CoffeeScript","funding_links":["https://gumroad.com/l/hGYGh"],"categories":[],"sub_categories":[],"readme":"coffeerest-api\n==============\nUnfancy rest apis\n\n\u003cimg alt=\"\" src=\"https://github.com/coderofsalvation/coffeerest-api/raw/master/coffeerest.png\" width=\"20%\" /\u003e\n\n## Ouch! Is it that simple?\n\nYour `model.coffee` specification \n\n    module.exports = \n      host: process.env.HOST || \"localhost:8080\"\n      name: \"project foo\"\n      resources:\n        '/book/:category':\n          post:\n            description: 'adds a book'\n            payload:\n              foo: { type: \"string\", minLength: 5, required: true }\n            function: (req, res, next,lib, reply) -\u003e\n              category = req.params.category\n              reply.data = [1,2, lib.foo() ]\n              return reply \n              \n      replyschema:\n        type: 'object'\n        required: ['code','message','kind','data']\n        messages:\n          0: 'feeling groovy'\n          1: 'unknown error'\n          2: 'your payload is invalid (is object? content-type is application/json?)'                                                                                           \n          3: 'data error'\n          4: 'access denied'\n        payload:\n          code:       { type: 'integer', default: 0 }\n          message:    { type: 'string',  default: 'feeling groovy' }\n          kind:       { type: 'string',  default: 'default', enum: ['book','default'] }\n          data:       { type: 'object' }\n          errors:     { type: 'object' }\n## Extensions \n\n* [coffeerest-api-doc](https://www.npmjs.com/package/coffeerest-api-doc): automatic html and markdown REST-documentation\n* coffeerest-api-clients:  automatic REST clients) *TODO*\n* coffeerest-api-db: ORM to connect any database (using waterline) which automatically generates collection-to-restapi-endpoints \n\n## Example servercode \n\n    restify    = require('restify')        # here we use restify but express should be fine too\n    coffeerest = require('coffeerest-api')\n    model      = require('./model.coffee')\n    lib        = \n      foo: () -\u003e return 3\n\n    server = restify.createServer { name:model.name }\n    server.use restify.queryParser()\n    server.use restify.bodyParser()\n    server.use coffeerest server, { \"/v1\":model }, lib  # multiversion support\n    server.listen process.env.PORT || 8080, () -\u003e\n      console.log '%s listening at %s', server.name, server.url\n\nDone!\n\n    $ coffee server.coffee\n    registering REST resource: /v1/books/:action (post)\n    registering REST resource: /v1/book (post)\n    project foo listening at http://0.0.0.0:4455\n\n    $ curl -H 'Content-Type: application/json' http://localhost:$PORT/v1/book -X POST --data '{\"foo\":\"foobar\"}'\n    {\"code\":0,\"message\":\"feeling groovy\",\"kind\":\"default\",\"data\":[1,2,3],\"errors\":{}}\n\n    $ curl -H 'Content-Type: application/json' http://localhost:$PORT/v1/book -X POST --data '{\"foo\":\"foo\"}'\n    {\"code\":2,\"message\":\"your payload is invalid (is object? content-type is application/json?)\",\"kind\":\"default\",\"data\":{},\"errors\":[{\"uri\":\"/foo\",\"message\":\"String is less than the required minimum length\",\"attribute\":\"minLength\",\"details\":5}]}\n    \n    $ curl -H 'Content-Type: application/json' http://localhost:$PORT/v1/book -X POST --data '{}'\n    \"code\":2,\"message\":\"your payload is invalid (is object? content-type is application/json?)\",\"kind\":\"default\",\"data\":{},\"errors\":[{\"uri\":\"/foo\",\"message\":\"Property is required\",\"attribute\":\"required\",\"details\":true}]}\n\n## Philosophy\n\nDont generate code based on config (Yeoman etc), but instead extend both code and config.\nOh..and jsonschema, because jsonschema.\n\n## Magic \n\n* ignore certain extensions \n\n| pass environment var COFFEEREST_EXT_IGNORE with value '(db|frontend)' to ignore all coffeerest extensions which match either 'db' or 'frontend'\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoderofsalvation%2Fcoffeerest-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcoderofsalvation%2Fcoffeerest-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoderofsalvation%2Fcoffeerest-api/lists"}