{"id":17349254,"url":"https://github.com/co2-git/prontojs","last_synced_at":"2025-03-27T11:44:31.895Z","repository":{"id":24766270,"uuid":"28179494","full_name":"co2-git/prontojs","owner":"co2-git","description":"Web server based on Express","archived":false,"fork":false,"pushed_at":"2015-03-09T09:42:40.000Z","size":512,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-01T16:23:20.053Z","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/co2-git.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":"2014-12-18T10:43:46.000Z","updated_at":"2015-03-09T09:42:40.000Z","dependencies_parsed_at":"2022-08-23T05:21:03.477Z","dependency_job_id":null,"html_url":"https://github.com/co2-git/prontojs","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/co2-git%2Fprontojs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/co2-git%2Fprontojs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/co2-git%2Fprontojs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/co2-git%2Fprontojs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/co2-git","download_url":"https://codeload.github.com/co2-git/prontojs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245841692,"owners_count":20681184,"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-15T16:55:08.861Z","updated_at":"2025-03-27T11:44:31.876Z","avatar_url":"https://github.com/co2-git.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"prontojs !`very-alpha`\n========\n\n                                              888             d8b          \n                                              888             Y8P          \n                                              888                          \n            88888b.  888d888 .d88b.  88888b.  888888 .d88b.  8888 .d8888b  \n            888 \"88b 888P\"  d88\"\"88b 888 \"88b 888   d88\"\"88b \"888 88K      \n            888  888 888    888  888 888  888 888   888  888  888 \"Y8888b. \n            888 d88P 888    Y88..88P 888  888 Y88b. Y88..88P  888      X88 \n            88888P\"  888     \"Y88P\"  888  888  \"Y888 \"Y88P\"   888  88888P' \n            888                                               888          \n            888                                              d88P          \n            888                                            888P\"           \n\n\n                                        .dS$:::::.....\n                                     .d$$$$$::::::::::::...\n                                   d$$$$$$$:::::::::::::::::::..\n                                  d$$$$$$$::::::::::::::::::::::::.\n                                 d$$$$$$::::::::::::::::::::::::::::.\n                               .d$$$$$$:::::::::::::::::::::::::::::::.\n                              .d$$$$$$::::::::::::::::::::::::::::::::::\n                             .d$$$$$:::::::::::::::::::::::::::::::::::::.\n                            .d$$$$$$$$$$::::::::::::::::::::::::::::::::::.\n                           .d$$$$$$$$$$$$$$$$$$$$$$::::::::::::::::::::::::\n                          .d$$$$$$$$$$$$$$$$$$$$$$$$$$$$:::::::::::::::::::\n                          d$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$:::::::::::\n      .:::::::::.        .$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$:::::::\n      `:::::::::::::.    $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$::::\n       `::::::::::::::::'::$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$::\n        :::::::::::::::::::::::.$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$:\n         ::$$$:$$$$$$$$$$$$$$$$$$$Ss.::::::::*4$$$$$$$$$$$$$$$$$$$$$$$$$$$$\n          $$$$$$$$$$$$$$$$$$$$$$$$$$$$$Ss:::::::::*4$$$$$$$$$$$$$$$$$$$$$$$\n           `q$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$Ss:::::::::*4$$$$$$$$$$$$$$$$$$\n              `q$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$Ss:::::::::*4$$$$$$$$$$$$$\n                `q$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$Ss::::::::*44$$$$$$$\n                   .$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$Ss::::::::*4$$$\n                  :$$$$$$$$$$$$$$$$$$.    `$$$$$$$$$$$$$$$$$$$$$$Ss:::::::;\n                  `$$$$$$$$$$$$$$$$$$$$.   `:::$$:$!$$$$$$$$$$$$$$$$$$Ss::;\n                   $$$$$$$$$$$$$$$$$$$$$.    ::::$$$$$$$$$$$$$$$$$$$$$$$$$$\n                   `$$$$$$$$$$$  $$`$$$$$'      :$$$$$: \":$$$$$$$$$$$$$$$$$\n                    $$$$$$$$$$$$$!   $$$$      ::$$$$$\" $$::\":::`$$$$$$$$$$\n                    $$$$$$  `qp'   .s$$$'        :\"\"$$  $:\":\"      `$$$$$$$\n                    $$$$$$       4$$$$$$         $$\"                $$$$$$$\n                   .$$$$$$.       `$$$$'                            $$$$\n                   $$$$$$$$7      .$$$$                             `;'\n                   $$$$$$$$     .$$$$'\n                   $$$$$$$    .$$$$$$._                             ;\n                   $$$$$$$  A.$$$$$$$$Ss. 'cqp\n                   `$$$$$$ $$$$$$$$$!!                             ;\n                    $$$$$$ $$$$$$$$!~                             ;\n                    `$$$$$ $ $$$$$$$$$$  ~                       ;\n                     `$$$$$$$$$$$$!!~ ~!$~~ ~~$!~               ;\n                    .s$$$$$$$$$$$$$$ ~ ~   ~     ~             ;\n               _.sS$$$$$$$$$$$$$$$$$$$$$$$!~~     ::::      :.'$$$\n           _.sS$$$$$$$$$$$$$$$$$!$!!         ~   ::: : :: .'  $$$$\n       _.sS$$$$$$$$$$$$$$$$$$$$$$$$~~             :::::::.'   .$$$$$Ss._\n    .sS$$$$$$$$$$$$$$$$$$$$$$$$$$$$:\":\"\"       : ::::::.'     !$$$$$$$$$Ss.\n    $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$:::\"\" \"\"\"\":::::.'      .$$$$$$$$$$$$$\n    $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$:::.''         !$$$$$$$$$$$$$\n    $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$.''            .$$$$$$$$$$$$$$\n    $$$$$$$$$$$$$$$$$$$$$        \"\"\"\"\"\"\"\"\"\"\";              .$$$$$$$$$$$$$$$\n    $$$$$$$$$$$$$$$$$$$$$.       MMMMMMMMMMM;             .$$$$$$$$$$$$$$$$\n    $$$$$$$$$$$$$$$$$$$$$$.      MMMMMMMMMMMM;            !$$$$$$$$$$$$$$$$\n    $$$$$$$$$$$$$$$$$$$$$$$S.    MMMMMMMMM'   ;          .$$$$$$$$$$$$$$$$$\n    $$$$$$$$$$$$$$$$$$$$$$$$$.   MMMMMMMM'     ;        .$$$$$$$$$$$$$$$$$$\n    $$$$$$$$$$$$$$$$$$$$$$$$$$.  MMMMMMM'       ;      .$$$$$$$$$$$$$$$$$$$\n    $$$$$$$$$$$$$$$$$$$$$$$$$$$. MMMMM'          ;    .$$$$$$$$$$$$$$$$$$$$\n    $$$$$$$$$$$$$$$$$$$$$$$$$$$$MMMMMMM           ;  .$$$$$$$$$$$$$$$$$$$$$\n    $$$$$$$$$$$$$$$$$$$$$$$$$$$$$MMMMMMMMz.       ; .$$$$$$$$$$$$$$$$$$$$$$\n    $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$MMMMMMMMMz      ;.$$$$$$$$$$$$$$$$$$$$$$$\n    $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$MMMMMMMMMM.   ;.$$$$$$$$$$$$$$$$$$$$$$$$\n\n\n`prontojs` is a Node module that creates HTTP(S) daemons (*Web Servers*). `prontojs` creates web servers that focus on serving resources. You tell `prontojs` which files you want to share with the Web, under which conditions and how to open them.\n\n# Install\n\n```bash\nnpm install prontojs\n```\n\n# Usage\n\n```js\nvar pronto = require('prontojs');\nvar when = pronto.when;\n\n// Create a new web server serving images\npronto().share('images/');\n\n// Create a new web server as API\npronto().share('lib/', {\n  opener: 'js/callback',\n  args: [pronto.ifThenElse(pronto.method.is.post.or.put, pronto.payload, pronto.query)],\n  as: 'json' });\n```\n\n# Some user cases\n\n## Want to start a new HTTP server?\n\n```js\npronto();\n/** \n    GET /\n\n    HTTP 404 Not Found\n    ...\n*/\n```\n\n## Want to share a folder with the web?\n\n```\n/images\n  /birthday.jpg\n```\n\n```js\npronto().share('images/'); // Now all the files in images/ folder are served\n/** \n    GET /birthday.jpg\n\n    HTTP 200 OK\n    Content-Type: image/jpg\n    ...\n*/\n```\n\n## Want to restrict who you share it with?\n\n```js\npronto().share('images/',\n  \n  when.is.user.\n    and.\n    is.visiting.from('Russia').\n    and.\n    is.using.an.iPhone(4).\n    and.\n    method.is.GET.\n    and.\n    except.when.\n      it.is.the.week.end);\n```\n\n## Want to share your Jade files rendered into HTML?\n\n```\n/views\n  /home.jade\n```\n\n```yaml\n//- home.jade\nh1 Hello\n```\n\n```js\n// pronto.js\n\npronto().share('views');\n/** \n    GET /home.jade\n\n    HTTP 200 OK\n    Content-Type: text/html; charset=utf-8\n    \n    \u003ch1\u003eHello\u003c/h1\u003e\n*/\n```\n\n## Want to execute JS functions via HTTP?\n\n```js\n// foo.js\n\nmodule.exports = function () { return 'hello'; };\n\n// pronto.js\n\npronto().share('foo.js', { as: 'text', opener: 'js/function' } );\n/** \n    GET /foo.js\n\n    HTTP 200 OK\n    Content-Type: text/plain; charset=utf-8\n    \n    hello\n*/\n```\n\n## Want to execute JS callbacks via HTTP?\n\n```js\n// foo.js\n\nmodule.exports = function (cb) { cb(null, 'hello') };\n\n// pronto.js\n\npronto().share('foo.js', { as: 'text', opener: 'js/callback' } );\n/** \n    GET /foo.js\n\n    HTTP 200 OK\n    Content-Type: text/plain; charset=utf-8\n    \n    hello\n*/\n```\n\n## Want to execute your JS promises via HTTP?\n\n```js\n// foo.js\n\nmodule.exports = function () { return 'hello'; }\n\n// pronto.js\n\npronto().share('foo.js', { as: 'text', opener: 'js/promise' } );\n/** \n    GET /foo.js\n\n    HTTP 200 OK\n    Content-Type: text/plain; charset=utf-8\n    \n    hello\n*/\n```\n\n## Want to execute your JS emitters via HTTP?\n\n```js\n// foo.js\n\nfunction Emitter () {\n  process.nextTick(function () {\n    this.emit('OK', 'hello');\n  }.bind(this));\n}\n\nrequire('util').inherits(Emitter, require('events').EventEmiiter);\n\nmodule.exports = Emitter;\n\n// pronto.js\n\npronto().share('foo.js', { opener: 'js/emitter', as: { 'text': { on: 'OK' } } });\n/** \n    GET /foo.js\n\n    HTTP 200 OK\n    Content-Type: text/plain; charset=utf-8\n    \n    hello\n*/\n```\n\n## Want to execute your JS routes via HTTP?\n\n```js\n// foo.js\n\nmodule.exports = function (req, res, next) { res.send('hello'); }\n\n// pronto.js\n\npronto().share('foo.js', { as: 'text', opener: 'js/route' } );\n/** \n    GET /foo.js\n\n    HTTP 200 OK\n    Content-Type: text/plain; charset=utf-8\n    \n    hello\n*/\n```\n\n===\n\n# Open\n\n`prontojs` puts the focus on serving files\n\n```js\npronto().open ( 'index.html' );\n/** \n    GET /index.html\n    \n    HTTP 200 OK\n    Content-Type: text/html; charset=utf-8\"\n    \n    ...\n*/\n\npronto().open ( 'image.png' );\n/** \n    GET /image.png\n    \n    HTTP 200 OK\n    Content-Type: image/png\n    \n    ...\n*/\n```\n\n## Open as\n\n```js\npronto().open ( 'index.html', { as: 'txt' } );\n/** \n    GET /index.html\n    \n    HTTP 200 OK\n    Content-Type: text/plain; charset=utf-8\n    \n    ...\n*/\n```\n\nWe have built-in handlers for the more popular template engines:\n\n```haml\n//- index.jade\n\nh1 Hello\n```\n\n```js\n// pronto.js\n\npronto().open ( 'index.jade' );\n/** \n    GET /index.jade\n    \n    HTTP 200 OK\n    Content-Type: text/html; charset=utf-8\n    \n    \u003ch1\u003eHello\u003c/h1\u003e\n*/\n```\n\nWe have built-in handlers for the more popular preprocessors, for example SASS:\n\n```css\n/* index.scss */\n\n$color: #999;\n\nbody { h1 { color: $color } }\n```\n\n```js\n// pronto.js\n\npronto().open ( 'index.scss' );\n/** \n    GET /index.scss\n    \n    HTTP 200 OK\n    Content-Type: text/css; charset=utf-8\n    \n    body h1 { color: #999 }\n*/\n```\n\nWe have built-in handlers for the more popular interpreters:\n\n```php\n\u003c?=PHP_VERSION\n```\n\n```js\npronto().open ( 'index.php' );\n/** \n    GET /index.php\n    \n    HTTP 200 OK\n    Content-Type: text/html; charset=utf-8\n    \n    3.2.1\n*/\n```\n\n## Custom openers\n\nYou can build your custom openers:\n\n```\nindex.txt\n===\nHello John!\n```\n\n```js\nfunction countOccurencies () {\n  \n}\n\npronto().open ( 'index.css', { with: function (stream) { /* your opener here */ } } );\n```\n\n## Custom types\n\nYou can build your custom types:\n\n```js\npronto().type ( 'abc', function () { /* your opener here */  }  } );\n```\n\n## Open directories\n\nOpening a directory automatically opens all the files in this directory. Imagine the following directory:\n\n```\napp/\n  index.html\n```\n\nTo serve this directory:\n\n```js\npronto().open ( 'app/' );\n```\n\n```bash\ncurl http://localhost:3000/index.html # gets app/index.html\n```\n\n## Indexes\n\nThe example above could have been shorted to:\n\n```bash\ncurl http://localhost:3000/ # gets app/index.html\n```\n\nWhen the route points to a directory, it will get the file matching globbing pattern `index.*`. If more than one file is found, first in the list is used.\n\n```bash\ncurl http://localhost:3000/js # gets app/js/index.js\n```\n\nYou can turn off indexes like this;\n\n```js\npronto.open ( { index: false } )\n```\n\nOr you can specify your own index:\n\n```js\npronto.open ( { index: 'README.md' } );\n```\n\nThis is the one we use as default:\n\n```js\npronto.open ( { index: 'index.*' } );\n```\n\n# Exec\n\nAs seen before, some file extensions are automatically opened as executable:\n\n```js\npronto.open( 'index.py' ); // execute this file with Python\n```\n\nJS files are opened as static JS files:\n\n```js\npronto.open( 'index.js' );\n/**\n    GET /index.js\n    \n    HTTP 200 OK\n    Content-Type: text/javascript; charset=utf-8\n```\n\nIf you want to open a JS file with Node or IO, do like this:\n\n```js\n// morning.js\n\nmodule.exports = function () {\n  return \"Good morning\";\n  };\n\npronto.exec( 'morning.js', when.time.is( 'AM' ) );\n/**\n    GET /index.js\n    \n    HTTP 200 OK\n    Content-Type: text/javascript; charset=utf-8\n```\n\nYou have flexible support\n\n# Passport\n\nWe have passport.js for auth\n\n```js\npronto().passport({ strategies: ['local', 'facebook', 'twitter', 'google+', 'linkedin', 'github'] });\n```\n\n## Local strategy\n\n```\nPOST /sign/in email=john@doe.com\u0026password=1234\n\nHTTP 200 OK\nContent-Type: application/json; charset=utf-8\nCookie: ...\n\n{ \"welcome\": User }\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fco2-git%2Fprontojs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fco2-git%2Fprontojs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fco2-git%2Fprontojs/lists"}