{"id":13402662,"url":"https://github.com/toptal/haste-server","last_synced_at":"2025-04-09T11:03:28.692Z","repository":{"id":1945762,"uuid":"2875354","full_name":"toptal/haste-server","owner":"toptal","description":"open source pastebin written in node.js","archived":false,"fork":false,"pushed_at":"2024-08-03T00:17:55.000Z","size":1904,"stargazers_count":2936,"open_issues_count":17,"forks_count":795,"subscribers_count":146,"default_branch":"master","last_synced_at":"2024-11-06T22:02:47.746Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://www.toptal.com/developers/hastebin/about","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/toptal.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":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2011-11-29T14:19:46.000Z","updated_at":"2024-11-06T19:05:43.000Z","dependencies_parsed_at":"2023-07-06T19:46:58.291Z","dependency_job_id":"2833b114-32fa-4471-af90-c77ca8b753dd","html_url":"https://github.com/toptal/haste-server","commit_stats":{"total_commits":330,"total_committers":50,"mean_commits":6.6,"dds":"0.33333333333333337","last_synced_commit":"b52b394bad909ddf151073987671e843540d91d6"},"previous_names":["seejohnrun/haste-server"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toptal%2Fhaste-server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toptal%2Fhaste-server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toptal%2Fhaste-server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toptal%2Fhaste-server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/toptal","download_url":"https://codeload.github.com/toptal/haste-server/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248027402,"owners_count":21035594,"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-07-30T19:01:19.126Z","updated_at":"2025-04-09T11:03:28.659Z","avatar_url":"https://github.com/toptal.png","language":"JavaScript","funding_links":[],"categories":["JavaScript","others","Apps"],"sub_categories":["FileSharing"],"readme":"# Important announcement:\n\n## [Soon a new version of Hastebin will be launched!](https://github.com/toptal/haste-server/issues/429)\n\n[Check here what you need to know.](https://github.com/toptal/haste-server/issues/429)\n\n.    \n.    \n.    \n\n# Haste\n\nHaste is an open-source pastebin software written in node.js, which is easily\ninstallable in any network.  It can be backed by either redis or filesystem,\nand has a very easy adapter interface for other stores.  A publicly available\nversion can be found at [hastebin.com](http://hastebin.com)\n\nMajor design objectives:\n\n* Be really pretty\n* Be really simple\n* Be easy to set up and use\n\nHaste works really well with a little utility called\n[haste-client](https://github.com/seejohnrun/haste-client), allowing you\nto do things like:\n\n`cat something | haste`\n\nwhich will output a URL to share containing the contents of `cat something`'s\nSTDOUT.  Check the README there for more details and usages.\n\n## Tested Browsers\n\n* Firefox 8\n* Chrome 17\n* Safari 5.3\n\n## Installation\n\n1.  Download the package, and expand it\n2.  Explore the settings inside of config.js, but the defaults should be good\n3.  `npm install`\n4.  `npm start` (you may specify an optional `\u003cconfig-path\u003e` as well)\n\n## Settings\n\n* `host` - the host the server runs on (default localhost)\n* `port` - the port the server runs on (default 7777)\n* `keyLength` - the length of the keys to user (default 10)\n* `maxLength` - maximum length of a paste (default 400000)\n* `staticMaxAge` - max age for static assets (86400)\n* `recompressStaticAssets` - whether or not to compile static js assets (true)\n* `documents` - static documents to serve (ex: http://hastebin.com/about.com)\n  in addition to static assets.  These will never expire.\n* `storage` - storage options (see below)\n* `logging` - logging preferences\n* `keyGenerator` - key generator options (see below)\n* `rateLimits` - settings for rate limiting (see below)\n\n## Rate Limiting\n\nWhen present, the `rateLimits` option enables built-in rate limiting courtesy\nof `connect-ratelimit`.  Any of the options supported by that library can be\nused and set in `config.js`.\n\nSee the README for [connect-ratelimit](https://github.com/dharmafly/connect-ratelimit)\nfor more information!\n\n## Key Generation\n\n### Phonetic\n\nAttempts to generate phonetic keys, similar to `pwgen`\n\n``` json\n{\n  \"type\": \"phonetic\"\n}\n```\n\n### Random\n\nGenerates a random key\n\n``` json\n{\n  \"type\": \"random\",\n  \"keyspace\": \"abcdef\"\n}\n```\n\nThe _optional_ keySpace argument is a string of acceptable characters\nfor the key.\n\n## Storage\n\n### File\n\nTo use file storage (the default) change the storage section in `config.js` to\nsomething like:\n\n``` json\n{\n  \"path\": \"./data\",\n  \"type\": \"file\"\n}\n```\n\nwhere `path` represents where you want the files stored.\n\nFile storage currently does not support paste expiration, you can follow [#191](https://github.com/seejohnrun/haste-server/issues/191) for status updates.\n\n### Redis\n\nTo use redis storage you must install the `redis` package in npm, and have\n`redis-server` running on the machine.\n\n`npm install redis`\n\nOnce you've done that, your config section should look like:\n\n``` json\n{\n  \"type\": \"redis\",\n  \"host\": \"localhost\",\n  \"port\": 6379,\n  \"db\": 2\n}\n```\n\nYou can also set an `expire` option to the number of seconds to expire keys in.\nThis is off by default, but will constantly kick back expirations on each view\nor post.\n\nAll of which are optional except `type` with very logical default values.\n\nIf your Redis server is configured for password authentification, use the `password` field.\n\n### Postgres\n\nTo use postgres storage you must install the `pg` package in npm\n\n`npm install pg`\n\nOnce you've done that, your config section should look like:\n\n``` json\n{\n  \"type\": \"postgres\",\n  \"connectionUrl\": \"postgres://user:password@host:5432/database\"\n}\n```\n\nYou can also just set the environment variable for `DATABASE_URL` to your database connection url.\n\nYou will have to manually add a table to your postgres database:\n\n`create table entries (id serial primary key, key varchar(255) not null, value text not null, expiration int, unique(key));`\n\nYou can also set an `expire` option to the number of seconds to expire keys in.\nThis is off by default, but will constantly kick back expirations on each view\nor post.\n\nAll of which are optional except `type` with very logical default values.\n\n### MongoDB\n\nTo use mongodb storage you must install the 'mongodb' package in npm\n\n`npm install mongodb`\n\nOnce you've done that, your config section should look like:\n\n``` json\n{\n  \"type\": \"mongo\",\n  \"connectionUrl\": \"mongodb://localhost:27017/database\"\n}\n```\n\nYou can also just set the environment variable for `DATABASE_URL` to your database connection url.\n\nUnlike with postgres you do NOT have to create the table in your mongo database prior to running.\n\nYou can also set an `expire` option to the number of seconds to expire keys in.\nThis is off by default, but will constantly kick back expirations on each view or post.\n\n### Memcached\n\nTo use memcache storage you must install the `memcached` package via npm\n\n`npm install memcached`\n\nOnce you've done that, your config section should look like:\n\n``` json\n{\n  \"type\": \"memcached\",\n  \"host\": \"127.0.0.1\",\n  \"port\": 11211\n}\n```\n\nYou can also set an `expire` option to the number of seconds to expire keys in.\nThis behaves just like the redis expirations, but does not push expirations\nforward on GETs.\n\nAll of which are optional except `type` with very logical default values.\n\n### RethinkDB\n\nTo use the RethinkDB storage system, you must install the `rethinkdbdash` package via npm\n\n`npm install rethinkdbdash`\n\nOnce you've done that, your config section should look like this:\n\n``` json\n{\n  \"type\": \"rethinkdb\",\n  \"host\": \"127.0.0.1\",\n  \"port\": 28015,\n  \"db\": \"haste\"\n}\n```\n\nIn order for this to work, the database must be pre-created before the script is ran.\nAlso, you must create an `uploads` table, which will store all the data for uploads.\n\nYou can optionally add the `user` and `password` properties to use a user system.\n\n### Google Datastore\n\nTo use the Google Datastore storage system, you must install the `@google-cloud/datastore` package via npm\n\n`npm install @google-cloud/datastore`\n\nOnce you've done that, your config section should look like this:\n\n``` json\n{\n  \"type\": \"google-datastore\"\n}\n```\n\nAuthentication is handled automatically by [Google Cloud service account credentials](https://cloud.google.com/docs/authentication/getting-started), by providing authentication details to the GOOGLE_APPLICATION_CREDENTIALS environmental variable.\n\n### Amazon S3\n\nTo use [Amazon S3](https://aws.amazon.com/s3/) as a storage system, you must\ninstall the `aws-sdk` package via npm:\n\n`npm install aws-sdk`\n\nOnce you've done that, your config section should look like this:\n\n```json\n{\n  \"type\": \"amazon-s3\",\n  \"bucket\": \"your-bucket-name\",\n  \"region\": \"us-east-1\"\n}\n```\n\nAuthentication is handled automatically by the client. Check\n[Amazon's documentation](https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/setting-credentials-node.html)\nfor more information. You will need to grant your role these permissions to\nyour bucket:\n\n```json\n{\n    \"Version\": \"2012-10-17\",\n    \"Statement\": [\n        {\n            \"Action\": [\n                \"s3:GetObject\",\n                \"s3:PutObject\"\n            ],\n            \"Effect\": \"Allow\",\n            \"Resource\": \"arn:aws:s3:::your-bucket-name-goes-here/*\"\n        }\n    ]\n}\n```\n\n## Docker\n\n### Build image\n\n```bash\ndocker build --tag haste-server .\n```\n\n### Run container\n\nFor this example we will run haste-server, and connect it to a redis server\n\n```bash\ndocker run --name haste-server-container --env STORAGE_TYPE=redis --env STORAGE_HOST=redis-server --env STORAGE_PORT=6379 haste-server\n```\n\n### Use docker-compose example\n\nThere is an example `docker-compose.yml` which runs haste-server together with memcached\n\n```bash\ndocker-compose up\n```\n\n### Configuration\n\nThe docker image is configured using environmental variables as you can see in the example above.\n\nHere is a list of all the environment variables\n\n### Storage\n\n|          Name          | Default value |                                                  Description                                                  |\n| :--------------------: | :-----------: | :-----------------------------------------------------------------------------------------------------------: |\n|      STORAGE_TYPE      |   memcached   |    Type of storage . Accepted values: \"memcached\",\"redis\",\"postgres\",\"rethinkdb\", \"amazon-s3\", and \"file\"     |\n|      STORAGE_HOST      |   127.0.0.1   |                 Storage host. Applicable for types: memcached, redis, postgres, and rethinkdb                 |\n|      STORAGE_PORT      |     11211     |           Port on the storage host. Applicable for types: memcached, redis, postgres, and rethinkdb           |\n| STORAGE_EXPIRE_SECONDS |    2592000    | Number of seconds to expire keys in. Applicable for types. Redis, postgres, memcached. `expire` option to the |\n|       STORAGE_DB       |       2       |                    The name of the database. Applicable for redis, postgres, and rethinkdb                    |\n|    STORAGE_PASSWORD    |               |                       Password for database. Applicable for redis, postges, rethinkdb .                       |\n|    STORAGE_USERNAME    |               |                           Database username. Applicable for postgres, and rethinkdb                           |\n|   STORAGE_AWS_BUCKET   |               |                          Applicable for amazon-s3. This is the name of the S3 bucket                          |\n|   STORAGE_AWS_REGION   |               |                      Applicable for amazon-s3. The region in which the bucket is located                      |\n|    STORAGE_FILEPATH    |               |                            Path to file to save data to. Applicable for type file                             |\n\n### Logging\n\n|       Name        | Default value | Description |\n| :---------------: | :-----------: | :---------: |\n|   LOGGING_LEVEL   |    verbose    |             |\n|   LOGGING_TYPE=   |    Console    |\n| LOGGING_COLORIZE= |     true      |\n\n### Basics\n\n|           Name           |  Default value   |                                        Description                                        |\n| :----------------------: | :--------------: | :---------------------------------------------------------------------------------------: |\n|           HOST           |     0.0.0.0      |                         The hostname which the server answers on                          |\n|           PORT           |       7777       |                          The port on which the server is running                          |\n|        KEY_LENGTH        |        10        |                              the length of the keys to user                               |\n|        MAX_LENGTH        |      400000      |                                 maximum length of a paste                                 |\n|      STATIC_MAX_AGE      |      86400       |                                 max age for static assets                                 |\n| RECOMPRESS_STATIC_ASSETS |       true       |                        whether or not to compile static js assets                         |\n|    KEYGENERATOR_TYPE     |     phonetic     |             Type of key generator. Acceptable values: \"phonetic\", or \"random\"             |\n|  KEYGENERATOR_KEYSPACE   |                  |                  keySpace argument is a string of acceptable characters                   |\n|        DOCUMENTS         | about=./about.md | Comma separated list of static documents to serve. ex: \\n about=./about.md,home=./home.md |\n\n### Rate limits\n\n|                 Name                 |             Default value             |                                       Description                                        |\n| :----------------------------------: | :-----------------------------------: | :--------------------------------------------------------------------------------------: |\n|   RATELIMITS_NORMAL_TOTAL_REQUESTS   |                  500                  | By default anyone uncategorized will be subject to 500 requests in the defined timespan. |\n| RATELIMITS_NORMAL_EVERY_MILLISECONDS |                 60000                 |             The timespan to allow the total requests for uncategorized users             |\n| RATELIMITS_WHITELIST_TOTAL_REQUESTS  |                                       |      By default client names in the whitelist will not have their requests limited.      |\n|  RATELIMITS_WHITELIST_EVERY_SECONDS  |                                       |      By default client names in the whitelist will not have their requests limited.      |\n|         RATELIMITS_WHITELIST         | example1.whitelist,example2.whitelist |           Comma separated list of the clients which are in the whitelist pool            |\n| RATELIMITS_BLACKLIST_TOTAL_REQUESTS  |                                       |    By default client names in the blacklist will be subject to 0 requests per hours.     |\n|  RATELIMITS_BLACKLIST_EVERY_SECONDS  |                                       |     By default client names in the blacklist will be subject to 0 requests per hours     |\n|         RATELIMITS_BLACKLIST         | example1.blacklist,example2.blacklist |           Comma separated list of the clients which are in the blacklistpool.            |\n\n## Author\n\nJohn Crepezzi \u003cjohn.crepezzi@gmail.com\u003e\n\n## License\n\n(The MIT License)\n\nCopyright © 2011-2012 John Crepezzi\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of\nthis software and associated documentation files (the ‘Software’), to deal in\nthe Software without restriction, including without limitation the rights to\nuse, copy, modify, merge, publish, distribute, sublicense, and/or sell copies\nof the Software, and to permit persons to whom the Software is furnished to do\nso, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED ‘AS IS’, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE\n\n### Other components:\n\n* jQuery: MIT/GPL license\n* highlight.js: Copyright © 2006, Ivan Sagalaev\n* highlightjs-coffeescript: WTFPL - Copyright © 2011, Dmytrii Nagirniak\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftoptal%2Fhaste-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftoptal%2Fhaste-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftoptal%2Fhaste-server/lists"}