{"id":18084923,"url":"https://github.com/coderofsalvation/restify-generator","last_synced_at":"2025-04-12T20:10:08.869Z","repository":{"id":10581770,"uuid":"12790958","full_name":"coderofsalvation/restify-generator","owner":"coderofsalvation","description":"generates a restify RESTserver from a iodocs json schema","archived":false,"fork":false,"pushed_at":"2020-05-28T19:24:29.000Z","size":13,"stargazers_count":4,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-12T20:09:49.358Z","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":"gpl-2.0","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":"2013-09-12T18:10:43.000Z","updated_at":"2020-05-28T19:24:31.000Z","dependencies_parsed_at":"2022-09-09T20:31:07.773Z","dependency_job_id":null,"html_url":"https://github.com/coderofsalvation/restify-generator","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%2Frestify-generator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coderofsalvation%2Frestify-generator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coderofsalvation%2Frestify-generator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coderofsalvation%2Frestify-generator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/coderofsalvation","download_url":"https://codeload.github.com/coderofsalvation/restify-generator/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248625493,"owners_count":21135513,"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:39.154Z","updated_at":"2025-04-12T20:10:08.849Z","avatar_url":"https://github.com/coderofsalvation.png","language":"JavaScript","funding_links":["https://gumroad.com/l/hGYGh"],"categories":[],"sub_categories":[],"readme":"restify-generator\n=================\n\ngenerates a restify RESTserver from a iodocs json schema\n\nWhy\n===\nTo easily generate a startingpoint/skeleton RESTserver from a design which is robust: think first, then code.\nAlso, the same design can be used with iodocs in order to generate a REST documentation/dasboard.\n\nInstallation\n============\n\n    git clone https://github.com/coderofsalvation/restify-generator.git\n    cd restify-generator\n    npm install restify\n    mkdir api\n    cd bin\n    ./generate serverapi ../data/schema.json ../data/server.template ../serverapi.js api\n    node serverapi.js\n    myserver listening on 8001\n\nVoila!\n\nHow to design a REST schema\n===========================\nlook [here](https://github.com/coderofsalvation/restify-generator/blob/master/data/schema.json)\n\nExample script\n==============\nI used this bashscript to quickly generate/update my API with several versions:\n\n\n    #!/bin/bash\n    mypath=\"$(dirname $(readlink -f \"$0\"))\"\n    cd $mypath;\n\n    serverfile=\"$mypath/server\"\n\n    # clone restify-generator if not exists and install restify if not installed\n    [[ ! -d \"$mypath/restify-generator\" ]] \u0026\u0026 git clone https://github.com/coderofsalvation/restify-generator.git \n    [[ ! -d \"node_modules\"              ]] \u0026\u0026 npm install restify\n\n    generateVersion(){\n      version=\"$1\"\n      cd \"$mypath/restify-generator/bin\"\n      [[ \"$1\" == \"clean\" ]] \u0026\u0026 rm -r \"$mypath/RESTresources/v$version\"\n      [[ ! -d \"$mypath/RESTresources/v$version\" ]] \u0026\u0026 mkdir -p \"$mypath/RESTresources/v$version\"\n      ./generate myproject \"$mypath/data/v$version/schema.json\" \\\n                               \"$mypath/data/server.template\" \\\n                               \"$serverfile\" \\\n                               \"$(readlink -f \"../../\")\"\n      chmod 755 \"$serverfile\"\n    }\n\n    generateVersion 1\n\nThis produced:\n\n    $ ls \n    RESTresources/v1/writeIRC.js\n    server\n\nThis was the contents of the 'server' file:    \n\n    #!/usr/bin/node\n    /**\n     * Restify RESTserver\n     * \n     * usage: chmod 755 server; ./server\n     * how to test: curl -is http://localhost:8001/hello/mark -H 'accept: text/plain'\n     */\n    \n    var restify = require('restify');\n    \n    function notImplemented(req, res, next) {\n      res.send('not implemented ' + req.params.name);\n    }\n    \n    var server = restify.createServer({\n      name: 'myproject',\n    });\n    \n    server.listen(8001, function() {\n      console.log('%s listening at %s', server.name, server.url);\n    });\n    \n    server.post('/v1/writeIRC', function(req, res, next ){\n      require('./RESTresources/v1/writeIRC.js').handle( req, res, next, myproject );\n    });\n\nand this the contents of the 'writeIRC' RESTresources I defined in data/schema.json.\n(NOTE: it doesnt get overwritten if the file already exist) :\n\n    /***\n     * POST /v1/writeIRC\n     *\n     * posts a message on a irc (channel)\n     */\n\n    function handle(req, res, next, myproject ){\n      var response  = myproject.response;\n      var code = response.code = 0;\n      response.message = myproject.codes[code]; response.data = req.query;  res.send( response );\n    }\n\n    module.exports.handle = handle;\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoderofsalvation%2Frestify-generator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcoderofsalvation%2Frestify-generator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoderofsalvation%2Frestify-generator/lists"}