{"id":28398403,"url":"https://github.com/primus/create-server","last_synced_at":"2025-06-13T09:33:34.548Z","repository":{"id":65996606,"uuid":"21130127","full_name":"primus/create-server","owner":"primus","description":"Easily create a HTTP server for a users given options.","archived":false,"fork":false,"pushed_at":"2022-12-31T19:33:57.000Z","size":46,"stargazers_count":12,"open_issues_count":0,"forks_count":3,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-06-01T13:16:02.267Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/primus.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":"2014-06-23T14:53:29.000Z","updated_at":"2023-08-23T11:24:57.000Z","dependencies_parsed_at":null,"dependency_job_id":"e09f2ce4-2bf3-427e-8030-d7d6f675f6ed","html_url":"https://github.com/primus/create-server","commit_stats":{"total_commits":92,"total_committers":4,"mean_commits":23.0,"dds":0.5760869565217391,"last_synced_commit":"377b7876f1c51065cb98a6c815fc5586b5001214"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/primus/create-server","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/primus%2Fcreate-server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/primus%2Fcreate-server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/primus%2Fcreate-server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/primus%2Fcreate-server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/primus","download_url":"https://codeload.github.com/primus/create-server/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/primus%2Fcreate-server/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259619158,"owners_count":22885460,"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":"2025-06-01T04:38:39.287Z","updated_at":"2025-06-13T09:33:34.534Z","avatar_url":"https://github.com/primus.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# create-server\n\n[![Version npm](https://img.shields.io/npm/v/create-server.svg?style=flat-square)](https://www.npmjs.com/package/create-server)[![CI](https://img.shields.io/github/actions/workflow/status/primus/create-server/ci.yml?branch=master\u0026label=CI\u0026style=flat-square)](https://github.com/primus/create-server/actions?query=workflow%3ACI+branch%3Amaster)[![Coverage Status](https://img.shields.io/coveralls/primus/create-server/master.svg?style=flat-square)](https://coveralls.io/r/primus/create-server?branch=master)\n\nI've found my self writing this particular piece of snippet over and over again.\nIf you need to have a common API for creating a HTTP, HTTPS or SPDY server this\nmight be the module that you've been waiting for.\n\n## Installation\n\nAdd it to your Node.js project by running\n\n```\nnpm install --save create-server\n```\n\n## Creating a server\n\nIn all code examples we assume that you've required the module and saved it as\nthe `create` variable:\n\n```js\n'use strict';\n\nvar create = require('create-server');\n```\n\nThe `create` variable is now a function which can be used to create different\ntypes of servers. The function accepts 2 different arguments:\n\n1. A number which should be the port number or object with the configuration for\n   the servers.\n2. Optionally, an object with different callback methods.\n\nThe following properties can be configured:\n\n- **port**: The port number we should listen on. Also used to determine which\n  type of server we need to create.\n- **hostname**: What interface we should listen on.\n- **spdy**: Create SPDY server instead of a HTTPS server.\n- **root**: The root folder that contains your HTTPS certs.\n- **key, cert, ca, pfx, crl** Path or array of paths which will be read out the\n  correct files. The path should be relative to the **root** option.\n- **redirect**: Start up an optional HTTP server who will redirect users to the\n  port you're listening on. The supplied value should be the port number we need\n  to listen on.\n- **listen**: Do need to start listening to the server for you?\n\nThe following properties can be provided as callback object:\n\n- **close**: Server is closed.\n- **request**: Received a new incoming request.\n- **upgrade**: Received a HTTP upgrade request.\n- **listening**: We're now listening. Receives an optional error as first\n  argument.\n- **error**: Received a new error on the server.\n- **https**: A new HTTPS server has been created.\n- **http**: A new HTTP server has been created.\n- **spdy**: A new SPDY server has been created.\n\nWhen creating a secure server, we will do our best to provide sane defaults that\nwill protect your server against known secure server attacks such as POODLE, we\nalso update the cipher list to prevent attacks such as heart bleed. This can be\noverridden by supplying your own `cypher`, `secureProtocol` and `secureOptions`\nkeys as option.\n\n## License\n\n[MIT](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprimus%2Fcreate-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprimus%2Fcreate-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprimus%2Fcreate-server/lists"}