{"id":19206016,"url":"https://github.com/whiletruu/peers-against-humanity-backend","last_synced_at":"2025-10-05T06:58:12.802Z","repository":{"id":79430103,"uuid":"84410052","full_name":"WhileTruu/peers-against-humanity-backend","owner":"WhileTruu","description":null,"archived":false,"fork":false,"pushed_at":"2017-06-08T08:24:49.000Z","size":496,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-23T06:29:43.194Z","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/WhileTruu.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-03-09T07:09:50.000Z","updated_at":"2017-04-30T07:55:48.000Z","dependencies_parsed_at":"2023-04-29T16:58:22.127Z","dependency_job_id":null,"html_url":"https://github.com/WhileTruu/peers-against-humanity-backend","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/WhileTruu/peers-against-humanity-backend","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WhileTruu%2Fpeers-against-humanity-backend","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WhileTruu%2Fpeers-against-humanity-backend/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WhileTruu%2Fpeers-against-humanity-backend/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WhileTruu%2Fpeers-against-humanity-backend/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/WhileTruu","download_url":"https://codeload.github.com/WhileTruu/peers-against-humanity-backend/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WhileTruu%2Fpeers-against-humanity-backend/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278420211,"owners_count":25983814,"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","status":"online","status_checked_at":"2025-10-05T02:00:06.059Z","response_time":54,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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-11-09T13:14:28.973Z","updated_at":"2025-10-05T06:58:12.796Z","avatar_url":"https://github.com/WhileTruu.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Peers Against Humanity backend\n\n## Table of Contents\n\n- [Available Scripts](#available-scripts)\n  - [npm start](#npm-start)\n  - [npm test](#npm-test)\n  - [npm run build](#npm-run-build)\n  - [npm run database:rollback](#npm-run-database-rollback)\n  - [npm run database:latest](#npm-run-database-latest)\n  - [npm run database:seed](#npm-run-database-seed)\n- [Environment variables](#environment-variables)\n- [Installing a Dependency](#installing-a-dependency)\n- [Running Tests](#running-tests)\n  - [Filename Conventions](#filename-conventions)\n  - [Command Line Interface](#command-line-interface)\n  - [Version Control Integration](#version-control-integration)\n  - [Writing Tests](#writing-tests)\n  - [Testing Components](#testing-components)\n  - [Using Third Party Assertion Libraries](#using-third-party-assertion-libraries)\n  - [Initializing Test Environment](#initializing-test-environment)\n  - [Focusing and Excluding Tests](#focusing-and-excluding-tests)\n  - [Coverage Reporting](#coverage-reporting)\n  - [Continuous Integration](#continuous-integration)\n- [Deployment](#deployment)\n- [Notes](#notes)\n\n## Available Scripts\n\nIn the project directory, you can run:\n\n### `npm start`\n\nRuns the app, there's not really much difference between production and development modes, the only one being the PORT you specify in the environment variable.\u003cbr\u003e\n\n### `npm test:unit`\n\nLaunches the test runner in the interactive watch mode and runs unit tests.\u003cbr\u003e\nSee the section about [running tests](#running-tests) for more information.\n\n### `npm test:integration`\n\nLaunches the test runner in the interactive watch mode and runs integration tests.\u003cbr\u003e\nSee the section about [running tests](#running-tests) for more information.\n\n### `npm run build`\n\nBuilds the app for production to the `build` folder.\n\nSee the section about [deployment](#deployment) for more information.\n\n### `npm run database:rollback`\n\nRollback the last batch of mirations in the database matching your NODE_ENV.\n\n### `npm run database:latest`\n\nUpdates the database matching your NODE_ENV to the latest migration.\n\n### `npm run database:seed`\n\nAdds required default data to the database matching your NODE_ENV.\n\n## Environment variables\nYou can temporarily set environment variables by running the following command in your shell.\n```\nexport ENV_VARIABLE_NAME=env_variable\n```\nOr to make the variable(s) permanent write those commands into your `.bashrc` or `.zshrc` or `.yourshellrc`\n\n### `NODE_ENV`\nSpecifies the environment to run the, well, mostly db in. Might have some effect in app as well.\n\n### `CONNECTION_STRING`\nThe database connection string.\n\n### `SECRET`\nA string used to sign user tokens with.\n\n### `PORT`\nThe port to run the app on. If left unspecified, the default is 8080.\n\n## Installing a Dependency\n\n```\nyarn add \u003clibrary-name\u003e\n```\n\n## Running Tests\n\nPeers Against Humanity backend uses [Jest](https://facebook.github.io/jest/) as its test runner.\n\n### Filename Conventions\n\nJest will look for test files with any of the following popular naming conventions:\n\n* Files with `.js` suffix in `__tests__` folders.\n* Files with `.test.js` suffix.\n* Files with `.spec.js` suffix.\n\nThe command `npm run test:integration` will look for files with `.integration.spec.js` suffix.\n\nThe command `npm run test:unit` will look for files with `.unit.spec.js` suffix.\n\nThe `.test.js` / `.spec.js` files (or the `__tests__` folders) can be located at any depth under the `src` top level folder.\n\nTest files (or `__tests__` folders) should be placed next to the code they are testing so that relative imports appear shorter. For example, if `Yolo.test.js` and `Yolo.js` are in the same folder, the test just needs to `import Yolo from './Yolo'` instead of a long relative path. Colocation also helps find tests more quickly in larger projects.\n\n### Command Line Interface\n\nWhen you run `npm test`, Jest will launch in the watch mode. Every time you save a file, it will re-run the tests.\n\nThe watcher includes an interactive command-line interface with the ability to run all tests, or focus on a search pattern. It is designed this way so that you can keep it open and enjoy fast re-runs. You can learn the commands from the “Watch Usage” note that the watcher prints after every run:\n\n![Jest watch mode](http://facebook.github.io/jest/img/blog/15-watch.gif)\n\n### Version Control Integration\n\nBy default, when you run `npm test`, Jest will only run the tests related to files changed since the last commit. This is an optimization designed to make your tests runs fast regardless of how many tests you have. However it assumes that you don’t often commit the code that doesn’t pass the tests.\n\nJest will always explicitly mention that it only ran tests related to the files changed since the last commit. You can also press `a` in the watch mode to force Jest to run all tests.\n\nJest will always run all tests on a [continuous integration](#continuous-integration) server or if the project is not inside a Git or Mercurial repository.\n\n### Writing Tests\n\nTo create tests, add `it()` (or `test()`) blocks with the name of the test and its code. You may optionally wrap them in `describe()` blocks for logical grouping but this is neither required nor recommended.\n\nJest provides a built-in `expect()` global function for making assertions. A basic test could look like this:\n\n```js\nimport sum from './sum';\n\nit('sums numbers', () =\u003e {\n  expect(sum(1, 2)).toEqual(3);\n  expect(sum(2, 2)).toEqual(4);\n});\n```\n\nAll `expect()` matchers supported by Jest are [extensively documented here](http://facebook.github.io/jest/docs/api.html#expect-value).\u003cbr\u003e\nYou can also use [`jest.fn()` and `expect(fn).toBeCalled()`](http://facebook.github.io/jest/docs/api.html#tobecalled) to create “spies” or mock functions.\n\n### Using Third Party Assertion Libraries\n\nWe recommend that you use `expect()` for assertions and `jest.fn()` for spies. If you are having issues with them please [file those against Jest](https://github.com/facebook/jest/issues/new), and we’ll fix them. We intend to keep making them better for React, supporting, for example, [pretty-printing React elements as JSX](https://github.com/facebook/jest/pull/1566).\n\nHowever, if you are used to other libraries, such as [Chai](http://chaijs.com/) and [Sinon](http://sinonjs.org/), or if you have existing code using them that you’d like to port over, you can import them normally like this:\n\n```js\nimport sinon from 'sinon';\nimport { expect } from 'chai';\n```\n\nand then use them in your tests like you normally do.\n\n### Initializing Test Environment\n\n\u003eNote: this feature is available with `react-scripts@0.4.0` and higher.\n\nIf your app uses a browser API that you need to mock in your tests or if you just need a global setup before running your tests, add a `src/setupTests.js` to your project. It will be automatically executed before running your tests.\n\nFor example:\n\n#### `src/setupTests.js`\n```js\nconst localStorageMock = {\n  getItem: jest.fn(),\n  setItem: jest.fn(),\n  clear: jest.fn()\n};\nglobal.localStorage = localStorageMock\n```\n\n### Focusing and Excluding Tests\n\nYou can replace `it()` with `xit()` to temporarily exclude a test from being executed.\u003cbr\u003e\nSimilarly, `fit()` lets you focus on a specific test without running any other tests.\n\n### Coverage Reporting\n\nJest has an integrated coverage reporter that works well with ES6 and requires no configuration.\u003cbr\u003e\nRun `npm test -- --coverage` (note extra `--` in the middle) to include a coverage report like this:\n\n![coverage report](http://i.imgur.com/5bFhnTS.png)\n\nNote that tests run much slower with coverage so it is recommended to run it separately from your normal workflow.\n\n### Continuous Integration\n\nBy default `npm test` runs the watcher with interactive CLI. However, you can force it to run tests once and finish the process by setting an environment variable called `CI`.\n\nWhen creating a build of your application with `npm run build` linter warnings are not checked by default. Like `npm test`, you can force the build to perform a linter warning check by setting the environment variable `CI`. If any warnings are encountered then the build fails.\n\nPopular CI servers already set the environment variable `CI` by default but you can do this yourself too:\n\n### On CI servers\n#### Travis CI\n\n1. Following the [Travis Getting started](https://docs.travis-ci.com/user/getting-started/) guide for syncing your GitHub repository with Travis.  You may need to initialize some settings manually in your [profile](https://travis-ci.org/profile) page.\n1. Add a `.travis.yml` file to your git repository.\n```\nlanguage: node_js\nnode_js:\n  - 4\n  - 6\ncache:\n  directories:\n    - node_modules\nscript:\n  - npm test\n  - npm run build\n```\n1. Trigger your first build with a git push.\n1. [Customize your Travis CI Build](https://docs.travis-ci.com/user/customizing-the-build/) if needed.\n\n### On your own environment\n##### Windows (cmd.exe)\n\n```cmd\nset CI=true\u0026\u0026npm test\n```\n\n```cmd\nset CI=true\u0026\u0026npm run build\n```\n\n(Note: the lack of whitespace is intentional.)\n\n##### Linux, OS X (Bash)\n\n```bash\nCI=true npm test\n```\n\n```bash\nCI=true npm run build\n```\n\nThe test command will force Jest to run tests once instead of launching the watcher.\n\n\u003e  If you find yourself doing this often in development, please [file an issue](https://github.com/facebookincubator/create-react-app/issues/new) to tell us about your use case because we want to make watcher the best experience and are open to changing how it works to accommodate more workflows.\n\nThe build command will check for linter warnings and fail if any are found.\n\n## Deployment\n\nInstall docker! :D\u003cbr\u003e\nMake sure the docker service is running and then run ``docker compose up -d``, which should run the database container in the background. (You can check with ``docker ps``.)\n`npm run build` creates a `build` directory with a production build of the app.\u003cbr\u003e\n`npm run start` runs the server, which to function properly requires a database with tables and default data. The command requires the SECRET environment variable to be set, the CONNECTION_STRING variable is also needed, since the backend is not of much use without the connection.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwhiletruu%2Fpeers-against-humanity-backend","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwhiletruu%2Fpeers-against-humanity-backend","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwhiletruu%2Fpeers-against-humanity-backend/lists"}