{"id":27874041,"url":"https://github.com/maxmonis/authapp","last_synced_at":"2025-05-05T01:18:45.143Z","repository":{"id":223595049,"uuid":"743311550","full_name":"maxmonis/AuthApp","owner":"maxmonis","description":"User authentication monorepo with Node/Express backend and example frontends using React, Angular, or Vanilla TS","archived":false,"fork":false,"pushed_at":"2024-08-04T02:00:59.000Z","size":289,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-05T01:18:40.998Z","etag":null,"topics":["mean-stack","mern-stack","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/maxmonis.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":"2024-01-15T00:03:31.000Z","updated_at":"2024-08-04T02:01:02.000Z","dependencies_parsed_at":"2024-02-21T04:23:26.281Z","dependency_job_id":"51efd1ed-8532-45dc-b644-f0cb4fa026d6","html_url":"https://github.com/maxmonis/AuthApp","commit_stats":null,"previous_names":["maxmonis/authapp"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxmonis%2FAuthApp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxmonis%2FAuthApp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxmonis%2FAuthApp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxmonis%2FAuthApp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/maxmonis","download_url":"https://codeload.github.com/maxmonis/AuthApp/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252420920,"owners_count":21745154,"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":["mean-stack","mern-stack","typescript"],"created_at":"2025-05-05T01:18:44.478Z","updated_at":"2025-05-05T01:18:45.133Z","avatar_url":"https://github.com/maxmonis.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# AuthApp\n\n[TypeScript](https://www.typescriptlang.org/) monorepo with\n[Express](https://expressjs.com/) backend and [React](https://react.dev/)\nfrontend. Allows creation and authentication of users stored in a\n[MongoDB](https://www.mongodb.com/) database. Uses\n[nodemailer](https://nodemailer.com/) and\n[jsonwebtoken](https://www.npmjs.com/package/jsonwebtoken) for email\nverification and to facilitate updates to password.\n\n## Prerequisites\n\nBefore you begin, ensure you have the following installed on your machine:\n\n- [Node.js](https://nodejs.org/): runtime environment - required version\n  indicated in [.nvmrc](/.nvmrc)\n- [npm](https://www.npmjs.com/): package manager - comes with the Node.js\n  installation\n- [nvm](https://github.com/nvm-sh/nvm): version manager - ensures correct\n  version of Node.js used\n\nData will be managed by MongoDB, so create a database on their site. It's free\nto use and easy to set up.\n\nYou'll also need a gmail account and a password which authorizes sending\nautomated emails from it (this is different from the password used to log into\nthe account, and is simple to obtain by following Google's instructions).\n\n## Installation\n\nClone the repository onto your local machine and navigate to the project\ndirectory:\n\n```\ngit clone https://github.com/maxmonis/AuthApp.git\n```\n\n```\ncd AuthApp\n```\n\nInstall the dependencies of both the server and client:\n\n```\nnpm run setup\n```\n\nCreate a gitignored file called `.env` at the root of the project:\n\n```\ntouch .env\n```\n\nNow add the following environment variables therein:\n\n- `BASE_URL`: the address at which the app is hosted (`http://localhost:3000` in\n  development)\n- `JWT_SECRET`: the secret string of your choosing which jsonwebtoken will use\n  for encryption and decryption\n- `MONGO_URI`: the URI of the database you will use in MongoDB\n- `NODEMAILER_EMAIL`: the gmail address from which automated emails will be sent\n  by nodemailer\n- `NODEMAILER_PASSWORD`: the password which authorizes sending automated emails\n  from said address\n\n## Configuration\n\nBefore starting the application in development, run the following command to\nensure you're using the correct version of Node.js:\n\n```\nnvm use\n```\n\nNote that this command only needs to be run at the start of a session, not each\ntime you restart the application.\n\nYou may be prompted to install the required Node.js version if you have not\nalready.\n\n## Development\n\nSimultaneously start the client application while using\n[Nodemon](https://www.npmjs.com/package/nodemon) to run the server and\nautomatically restart it when changes are detected:\n\n```\nnpm run dev\n```\n\nThis will start the server on `http://localhost:5000` while concurrently\nstarting the client on `http://localhost:3000`.\n\nIf you want to work on the backend without the frontend, run:\n\n```\nnpm run server\n```\n\nThis will start the server on `http://localhost:5000` and update whenever\nchanges are detected.\n\nConversely, if you want to work on the client without the server, you can run\nthe application using a [Mock Service Worker](https://mswjs.io/) mock backend:\n\n```\nnpm run dev:msw\n```\n\nThis will start the app in watch mode on `http://localhost:3000` and facilitates\ndevelopment even without being connected to the internet.\n\nNote that this relies on the gitignored file `/app/public/mockServiceWorker.js`.\nIt should have been created automatically during installation but if not you can\nadd it now:\n\n```\ncd app \u0026\u0026 npx msw init public \u0026\u0026 cd ..\n```\n\nThis is a one time thing, once the file is created the browser mocking will work\nin perpetuity.\n\n## Testing\n\nUnit tests rely on the same Mock Service Worker handlers and can be run with:\n\n```\nnpm test\n```\n\nFor a detailed coverage report run:\n\n```\nnpm run coverage\n```\n\nAs of `v0.1.0` 100% coverage has been achieved:\n\n\u003cimg width=\"593\" alt=\"Screen Shot 2024-02-03 at 12 50 51 PM\" src=\"https://github.com/maxmonis/AuthApp/assets/51540371/39f6970e-d31d-403b-b81f-4cc68ce7511a\"\u003e\n\nThere are currently only tests for the client side, as I'm not a backend\ndeveloper.\n\n## Deployment\n\nThe following commands build the TypeScript files and start the server:\n\n```\nnpm run build\n```\n\n```\nnpm start\n```\n\n## Project Structure\n\nThe basic structure is as follows:\n\n- `api`: Express server\n  - `server.ts`: configures and starts the server\n- `dist`: gitignored output directory for compiled backend code\n- `app`: React application\n  - `build`: gitignored output directory for compiled frontend code\n\n## Angular App\n\nI also wanted to try out [Angular](https://angular.dev/) so I build another\nfrontend which uses the same API. It's in the `ng-app` folder and can be\ninteracted with in development using the following scripts, which do the same\nthings as the corresponding React ones which are explained above:\n\n```\nnpm run setup:ng\n```\n\n```\nnpm run dev:ng\n```\n\nIt has the same basic functionality as the React app, but without tests or mocks\nas of now. Note that you'll need to change the `BASE_URL` environment variable\nto `http://localhost:4200`.\n\n## Vanilla App\n\nI also wanted to try out vanilla TypeScript development using\n[Vite](https://vitejs.dev/) so I build a third frontend which uses the same API.\nIt's in the `ts-app` folder and can be interacted with in development using the\nfollowing scripts, which do the same things as the corresponding React and\nAngular ones which are explained above:\n\n```\nnpm run setup:ts\n```\n\n```\nnpm run dev:ts\n```\n\nIt has the same basic functionality as the React app, but without tests or mocks\nas of now. Note that you'll need to change the `BASE_URL` environment variable\nto `http://localhost:5173`.\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](/LICENSE)\nfile for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaxmonis%2Fauthapp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmaxmonis%2Fauthapp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaxmonis%2Fauthapp/lists"}