{"_id":"@curveball/curveball","_rev":"5-e1380463b58d32636afb38370ac4a6de","name":"@curveball/curveball","dist-tags":{"latest":"0.3.1"},"versions":{"0.3.1":{"name":"@curveball/curveball","version":"0.3.1","description":"Curveball is a framework writting in Typescript for Node.js","main":"dist/index.js","scripts":{"prepublish":"make build","test":"make lint test","tsc":"tsc"},"repository":{"type":"git","url":"git+https://github.com/evert/curveball.git"},"files":["package.json","README.md","dist","LICENSE"],"keywords":["http","framework","nodejs","typescript","push"],"author":{"name":"Evert Pot","url":"https://evertpot.com/"},"license":"MIT","bugs":{"url":"https://github.com/evert/curveball/issues"},"homepage":"https://github.com/evert/curveball#readme","devDependencies":{"@types/accepts":"^1.3.5","@types/chai":"^4.1.4","@types/co-body":"0.0.3","@types/mocha":"^5.2.3","@types/node":"^10.3.6","@types/node-fetch":"^2.1.1","@types/sinon":"^5.0.1","chai":"^4.1.2","mocha":"^5.2.0","node-fetch":"^2.1.2","nyc":"^12.0.2","sinon":"^6.0.1","ts-node":"^7.0.0","tslint":"^5.10.0","typescript":"^2.9.2"},"types":"dist/","nyc":{"extension":[".ts"]},"dependencies":{"accepts":"^1.3.5","raw-body":"^2.3.3"},"gitHead":"8246434bf14554b5f5f8cb450d1dc53945d73148","_id":"@curveball/curveball@0.3.1","_npmVersion":"6.1.0","_nodeVersion":"9.11.2","_npmUser":{"name":"evrt","email":"me@evertpot.com"},"dist":{"integrity":"sha512-zE/04MSJiZPONz+dHlTTDT2RS38B/AIYemkKBJ6fOMRf3iJw7/R8FMEjx7CWP1RjAOwdZdWehFglNCOCCZK6RQ==","shasum":"6526a64969f5b2ee971a0a8060113ffa15fe0954","tarball":"https://registry.npmjs.org/@curveball/curveball/-/curveball-0.3.1.tgz","fileCount":40,"unpackedSize":49910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbNvT0CRA9TVsSAnZWagAAYY4P/ipUIIwdfWpzHKeWXXVW\nGovy33bSONTpUluE+zkcEOrmG/PUFQIeWOcX27BJFwuMLwaBQ+wj2YvULxQh\nDLHUcbKsKOSjrdfSubHSqeh5dr5VFROvemW7ls+YKHljFz9niL+IRWTvNRNF\nWjGjE7b4ftJmfl1WixPQn5UO19btv/RwfV7XgnEwG/qrCIdjr4smI5zbCZ4z\n5XZc+DOBrUMPT/zti5jWLHenAMbXP9jDydS+h6+rocROLgY1+Xgstpfxs8VQ\nYR+En/7L4yEEQrZJfcwVIrhUlunrPIHCRju+3H/HcRvR7FHHHccrsvUIm13T\n5oy4FZHriJ+mZiS76wkrtCuzh8zwkHArL5Zya2EaF9T3goweQ91H8iMYkjUa\nhs2i01DSbdUjcwTjkSdGjtRZsyVKrNQ34GkxhtP4AQf4LoeAmOz5aLEW6mr/\ndogZP4JqVJgDNRuRpYVAZJ6BPYPRim0cuoorLa5caNz/8NlCCwvN40A/7oAH\nMbsTHYjLDqFTn3WgXv1PnFxCPat9L+rOQvYhVjw091IaAflSzDFScFkCP+jZ\n6MdYgBdVLvZZ4O1rcdGPBjlD1zXk6ayZZtfC1cOZ+/0v7LBHBg0GcyKyxtDh\nRw/3pC67LMVAftQBWAjIjS/XVBdsn9/DfP/mob+wY6mwZ0rt48pkOM0ZUm9b\nKaDc\r\n=1IoG\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCtmKMnEFoH6zM4MOX7oqVrlD1bogQu/j6TIYKt+4W6/wIgFkYXEyXprcZpajj9ysVNGrrr1tfeSbjqkywnYQp+6YE="}]},"maintainers":[{"name":"evrt","email":"me@evertpot.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/curveball_0.3.1_1530328308352_0.8654034175331968"},"_hasShrinkwrap":false,"deprecated":"Package deprecated. Please use @curveball/core instead"}},"time":{"created":"2018-06-30T03:11:48.109Z","0.3.1":"2018-06-30T03:11:48.440Z","modified":"2022-04-05T02:20:52.131Z"},"maintainers":[{"email":"hello@beckypollard.com","name":"beckypollard"},{"email":"me@evertpot.com","name":"evrt"},{"email":"4d.69.68.6f.6b@gmail.com","name":"mihok"},{"email":"juhangsin@gmail.com","name":"juhangsin"}],"description":"Curveball is a framework writting in Typescript for Node.js","homepage":"https://github.com/evert/curveball#readme","keywords":["http","framework","nodejs","typescript","push"],"repository":{"type":"git","url":"git+https://github.com/evert/curveball.git"},"author":{"name":"Evert Pot","url":"https://evertpot.com/"},"bugs":{"url":"https://github.com/evert/curveball/issues"},"license":"MIT","readme":"Curveball\n=========\n\nCurveball is a framework for building web services in Node.js. It fullfills a\nsimilar role to [Express][1] and it's heavily inspired by [Koa][2].\n\nThis web framework has the following goals:\n\n* A minimal foundation.\n* Completely written in and for [TypeScript][3].\n* Modern Ecmascript features.\n* Async/await-based middleware.\n* Native support for HTTP/2, including easy access to HTTP/2 Push.\n* Native support for modern HTTP features, such as [`103 Early Hints`][http-103].\n\nIf you used Koa in the past, this is going to look pretty familiar. I'm a big\nfan of Koa myself and would recommend it over this project if you don't need\nany of the things this project offers.\n\nInstallation\n------------\n\n    npm install curveball\n\n\nGetting started\n---------------\n\nCurveball only provides a basic framework. Using it means implementing or\nusing curveball middleware. For example, if you want a router, use or build\na Router middleware.\n\nAll of the following examples are written in typescript, but it is also\npossible to use the framework with plain javascript.\n\n```typescript\nimport { Application, Context } from 'curveball';\n\nconst app = new Application();\napp.use((ctx: Context) => {\n\n  ctx.response.status = 200;\n  ctx.body = 'Hello world!'\n\n});\n```\n\nSending 1xx Informational responses\n-----------------------------------\n\nCurveball has native support for sending informational responses. Examples are:\n\n* [`100 Continue`][http-100] to let a client know even before the request\n  completed that it makes sense to continue, or that it should break off the\n  request.\n* [`102 Processing`][http-102] to periodically indicate that the server is\n  still working on the response. This might not be very useful anymore.\n* [`103 Early Hints`][http-103] a new standard to let a client or proxy know\n  early in the process that some headers might be coming, allowing clients or\n  proxies to for example pre-fetch certain resources even before the initial\n  request completes.\n\nHere's an example of a middleware using `103 Early Hints`:\n\n```typescript\nimport { Application, Context, Middleware } from 'curveball';\n\nconst app = new Curveball();\napp.use(async (ctx: Context, next: Middleware) => {\n\n  await ctx.response.sendInformational(103, {\n    'Link' : [\n      '</style.css> rel=\"prefetch\" as=\"style\"',\n      '</script.js> rel=\"prefetch\" as=\"script\"',\n    ]\n  });\n  await next();\n\n});\n```\n\nAPI\n---\n\n\n### The Context class\n\nThe Context object has the following properties:\n\n* `request` - An instance of `Request`.\n* `response` - An instance of `Response`.\n* `state` - An object you can use to store request-specific state information.\n  this object can be used to pass information between middlewares. A common\n  example is that an authentication middlware might set 'currently logged in\n  user' information here.\n\n\n### The Request interface\n\nThe Request interface represents the HTTP request. It has the following\nproperties and methods:\n\n* `headers` - An instance of `Headers`.\n* `path` - The path of the request, for example `/foo.html`.\n* `method` - For example, `POST`.\n* `requestTarget` - The full `requestTarget` from the first line of the HTTP\n  request.\n* `body` - This might represent the body, but is initially just empty. It's\n  up to middlewares to do something with raw body and parse it.\n* `rawBody()` - This function uses the [raw-body][5] function to parse the\n  body from the request into a string or Buffer. You can only do this once,\n  so a middleware should use this function to populate `body`.\n* `query` - An object containing the query parametes.\n* `type` - The `Content-Type` without additional parameters.\n* `accepts` - Uses the [accepts][6] package to do content-negotiation.\n\n\n### The Response interface\n\nThe Response interface represents a HTTP response. It has the following\nproperties and methods:\n\n* `headers` - An instance of `Headers`.\n* `status` - The HTTP status code, for example `200` or `404`.\n* `body` - The response body. Can be a string, a buffer or an Object. If it's\n  an object, the server will serialize it as JSON.\n* `type` - The `Content-Type` without additional parameters.\n* `sendInformational(status, headers?)` - Sends a `100 Continue`,\n  `102 Processing` or `103 Early Hints` response with optional headers.\n\n\n### The Headers inteface\n\nThe Headers interface represents HTTP headers for both the `Request` and\n`Response`.\n\nIt has the following methods:\n\n* `set(name, value)` - Sets a HTTP header.\n* `get(name)` - Returns the value of a HTTP header, or null.\n* `delete(name)` - Deletes a HTTP header.\n* `append(name, value)` - Adds a HTTP header, but doesn't erase an existing\n  one with the same name.\n* `getAll()` - Returns all HTTP headers as a key-value object.\n\n\n### Status\n\n* Basic framework is in place.\n* Many features still missing.\n\n[1]: https://expressjs.com/ \"Express\"\n[2]: https://koajs.com/ \"Koa\"\n[3]: https://www.typescriptlang.org/ \"TypeScript\"\n[5]: https://www.npmjs.com/package/raw-body\n[6]: https://www.npmjs.com/package/accepts\n[http-100]: https://tools.ietf.org/html/rfc7231#section-6.2.1 \"RFC7231: 100 Continue\"\n[http-102]: https://tools.ietf.org/html/rfc2518#section-10.1 \"RFC2518: 102 Processing\"\n[http-103]: https://tools.ietf.org/html/rfc8297 \"RFC8297: 103 Early Hints\"\n","readmeFilename":"README.md"}