{"id":16514039,"url":"https://github.com/naturalprogrammer/np-nest-react-sample","last_synced_at":"2025-03-02T11:16:01.102Z","repository":{"id":220926846,"uuid":"752158043","full_name":"naturalprogrammer/np-nest-react-sample","owner":"naturalprogrammer","description":"Sample monorepo for Nest Rest API with React SPA","archived":false,"fork":false,"pushed_at":"2024-02-03T15:25:15.000Z","size":103,"stargazers_count":2,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-12T23:12:09.619Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://np-nest-react-sample-my-react.vercel.app","language":"TypeScript","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/naturalprogrammer.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}},"created_at":"2024-02-03T07:36:41.000Z","updated_at":"2024-05-23T07:11:23.000Z","dependencies_parsed_at":"2024-02-05T08:28:15.151Z","dependency_job_id":"fa47fbb3-d33a-484e-bbb2-950286bf2e66","html_url":"https://github.com/naturalprogrammer/np-nest-react-sample","commit_stats":null,"previous_names":["naturalprogrammer/np-nest-react-sample"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/naturalprogrammer%2Fnp-nest-react-sample","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/naturalprogrammer%2Fnp-nest-react-sample/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/naturalprogrammer%2Fnp-nest-react-sample/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/naturalprogrammer%2Fnp-nest-react-sample/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/naturalprogrammer","download_url":"https://codeload.github.com/naturalprogrammer/np-nest-react-sample/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241494184,"owners_count":19971871,"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-10-11T16:11:13.662Z","updated_at":"2025-03-02T11:16:01.080Z","avatar_url":"https://github.com/naturalprogrammer.png","language":"TypeScript","readme":"## Sharing code between NestJS backend and React frontend typescript projects\n\nThis is a monorepo with three workspaces:\n\n- `my-common` - Shared code\n- `my-nest` - backend\n- `my-react` - frontend\n\nIt was created by following https://docs.npmjs.com/cli/v10/using-npm/workspaces. Specifically, the following steps were\nexecuted:\n\n``` \nmkdir npmw-nr\ncd npmw-nr\nnpm init\nnpm init -w my-common\nnest new my-nest\nnpm create vite@latest -- --template react-ts\n```\n\nThen, commits were added as you see.\n\nNote that we need to transpile `my-common` as both _CommonJS_ and _ESModule_, because NestJS uses CommonJS whereas\nReact\nuses ESModule. For that, `tsc-multi` is used.\n\n### Running locally\n\nTo run locally, you could use three terminals to:\n\n1) run `tsc-multi --watch` in root\n2) run `npm run dev` in _my-react_ directory\n3) run `npm run dev` in _my-nest_ directory\n\nNote that, if you do changes to common module, NestJS does not restart, where React does.\n\n### Deploying the backend\n\nTo deploy backend as a DigitalOcean App, when creating the app, set the following\n\n```\n# Build command\nnpm run build --workspace=my-common --workspace=my-nest\n// TODO: test, test:e2e\n\n# Run command\nnpm run start:prod --workspace=my-nest\n```\n\nAnd, of course, set port to 3000.\n\n### Deploying the frontend\n\nTo deploy frontend to Vercel, enter the directory as `my-react` and edit commands as below:\n\n```\n# install command\ncd .. \u0026\u0026 npm install\n\n# build command\ncd .. \u0026\u0026 tsc-multi \u0026\u0026  npm run build --workspace my-react\nOR\ncd .. \u0026\u0026 tsc-multi \u0026\u0026 cd my-react \u0026\u0026 npm run build\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnaturalprogrammer%2Fnp-nest-react-sample","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnaturalprogrammer%2Fnp-nest-react-sample","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnaturalprogrammer%2Fnp-nest-react-sample/lists"}