{"id":13527486,"url":"https://github.com/ngneat/nx-serverless","last_synced_at":"2025-05-07T18:15:39.066Z","repository":{"id":37205787,"uuid":"489893090","full_name":"ngneat/nx-serverless","owner":"ngneat","description":"🚀 The Ultimate Monorepo Starter for Node.js Serverless Applications","archived":false,"fork":false,"pushed_at":"2022-09-14T10:47:00.000Z","size":5012,"stargazers_count":402,"open_issues_count":7,"forks_count":26,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-05-07T18:15:31.530Z","etag":null,"topics":["aws","aws-lambda","dynamodb","lambda","monorepo","nodejs","nx","serverless","typescript"],"latest_commit_sha":null,"homepage":"https://netbasal.com","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/ngneat.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}},"created_at":"2022-05-08T08:56:56.000Z","updated_at":"2025-03-17T16:21:36.000Z","dependencies_parsed_at":"2023-01-17T14:01:53.865Z","dependency_job_id":null,"html_url":"https://github.com/ngneat/nx-serverless","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ngneat%2Fnx-serverless","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ngneat%2Fnx-serverless/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ngneat%2Fnx-serverless/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ngneat%2Fnx-serverless/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ngneat","download_url":"https://codeload.github.com/ngneat/nx-serverless/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252931507,"owners_count":21827112,"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":["aws","aws-lambda","dynamodb","lambda","monorepo","nodejs","nx","serverless","typescript"],"created_at":"2024-08-01T06:01:49.093Z","updated_at":"2025-05-07T18:15:39.046Z","avatar_url":"https://github.com/ngneat.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"\u003cbr /\u003e\n\u003cp align=\"center\"\u003e\n \u003cimg width=\"25%\" height=\"25%\" src=\"./logo.png\"\u003e\n\u003c/p\u003e\n\n\u003ch1 align=\"center\"\u003eNx Serverless\u003c/h1\u003e\n\n\u003e The Ultimate Monorepo Starter for Node.js Serverless Applications\n\n✅ \u0026nbsp;First-Class Typescript Support\u003cbr\u003e\n✅ \u0026nbsp;DynamoDB Single Table Design\u003cbr\u003e\n✅ \u0026nbsp;Shared API Gateway\u003cbr\u003e\n✅ \u0026nbsp;Environments Configuration\u003cbr\u003e\n✅ \u0026nbsp;CORS\u003cbr\u003e\n✅ \u0026nbsp;JWT Auth Middleware\u003cbr\u003e\n✅ \u0026nbsp;Http Params Validation\u003cbr\u003e\n✅ \u0026nbsp;Typed Proxy Handlers\u003cbr\u003e\n✅ \u0026nbsp;Auto Generators\u003cbr\u003e\n✅ \u0026nbsp;Localstack\u003cbr\u003e\n✅ \u0026nbsp;ESLint\u003cbr\u003e\n✅ \u0026nbsp;Jest\u003cbr\u003e\n✅ \u0026nbsp;Github Actions\n\n\u003chr /\u003e\n\n[![serverless](http://public.serverless.com/badges/v3.svg)](http://www.serverless.com)\n[![](https://img.shields.io/badge/monorepo-Nx-blue)](https://nx.dev/)\n![esbuild](https://badges.aleen42.com/src/esbuild.svg)\n![npm peer dependency version (scoped)](https://img.shields.io/npm/dependency-version/eslint-config-prettier/peer/eslint)\n![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)\n[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/sudokar/nx-serverless/blob/master/LICENSE)\n[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/sudokar/nx-serverless)\n![Maintained](https://img.shields.io/maintenance/yes/2022.svg)\n\n\n## Prerequisites\n\n- Docker\n- Node.js\n\n## Getting Started\n\n- Run git clone https://github.com/ngneat/nx-serverless.git your-app-name\n- Run `npm install`\n- Run `npm run localstack` ( Check that it works by going to http://localhost:4566/health)\n- Run `npx nx deploy core --stage local` to create the table\n- Update the `environment` files based on your configuration\n- Run `npm run serve`\n\n## About the App\n\nThe application contains three services:\n\n#### Auth Service:\n\nThe auth service is responsible for authentication. It exposes one route for signing up:\n\n```bash\ncurl --request POST 'http://localhost:3001/dev/auth/sign-up' \\\n--data-raw '{\n    \"email\": \"netanel@gmail.com\",\n    \"name\": \"Netanel Basal\"\n}'\n```\n\nThe request returns a JWT, which is used for accessing protected routes.\n\n#### Users Service:\n\nThe users service is responsible for managing users. It exposes one route:\n\n```bash\ncurl 'http://localhost:3003/dev/user' --header 'Authorization: token TOKEN'\n```\n\nThe request returns the logged-in user.\n\n#### Todos Service:\n\nThe todos service is responsible for managing todos. A user has many todos. It exposes CRUD routes:\n\n```bash\n// Get user todos\ncurl 'http://localhost:3005/dev/todos' --header 'Authorization: token TOKEN'\n\n// Get a single todo\ncurl 'http://localhost:3005/dev/todos/:id' --header 'Authorization: token TOKEN'\n\n// Create a todo\ncurl --request POST 'http://localhost:3005/dev/todos' \\\n--header 'Authorization: token TOKEN'\n--data-raw '{\n    \"title\": \"Learn Serverless\"\n}'\n\n// Update a todo\ncurl  --request PUT 'http://localhost:3005/dev/todos/:id' \\\n--header 'Authorization: token TOKEN' \\\n--data-raw '{\n    \"completed\": true\n}'\n```\n\n## DynamoDB GUI\n[Download](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/workbench.settingup.html) NoSQL Workbench for DynamoDB and connect to `http://localhost:4566`.\n\n\u003cp align=\"center\"\u003e\n \u003cimg width=\"100%\" height=\"100%\" src=\"./dynamo.png\"\u003e\n\u003c/p\u003e\n\n## Commands\n\n```bash\nnx serve \u003cservice-name\u003e\nnx deploy \u003cservice-name\u003e\nnx remove \u003cservice-name\u003e\nnx build \u003cservice-name\u003e\nnx lint \u003cservice-name\u003e\nnx test \u003cservice-name\u003e\n\n// Use different enviroment\nNODE_ENV=prod nx deploy \u003cservice-name\u003e \nNODE_ENV=stg nx deploy \u003cservice-name\u003e \n\n// Run only affected\nnx affected:test\nnx affected:deploy\n```\n\n## Generators\n\n```bash\n// Generate a service\nyarn g:service tags\n\n// Generate handler\nyarn g:handler handler-name\n\n// Generate http handler\nyarn g:http-handler create-tag\n\n// Generate a model\nyarn g:model tag\n```\n\n\u003cimg src=\"demo.gif\"\u003e\n\n\u003chr /\u003e\n\n## CI/CD Pipeline with Github Actions\n\nThe pipeline has been configured to run everytime a push/pull_request is made to the `main` branch. You should uncomment the `ci.yml` workflow.\n\n#### Workflow Steps\n\n- Checkout: The `checkout` action is used to checkout the source code.\n\n- Node setup: The `setup-node` action is used to optionally download and cache distribution of the requested Node.js version.\n\n- lint and test: The `lint` and `test` runs only on affected projects.\n\n- Configure AWS credentials: The credentials needed are `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY` and should be set as Github __secrets__.\n\n- Each branch should be prefixed with the `environment` name. For example, if we have a `stg-feature-name` branch and open a pull request to the `main` branch, it will set `NODE_ENV` to `stg` and deploy to this environment. \n\nBy merging the pull request to the `main` branch, `NODE_ENV` is set to `prod`, and the deployment is done to production.\n\nThe workflow file can have as many environments as you need.\n\n## Further help\n\n- Visit [Serverless Documentation](https://www.serverless.com/framework/docs/) to learn more about Serverless framework\n- Visit [Nx Documentation](https://nx.dev) to learn more about Nx dev toolkit\n- Visit [LocalStack](https://localstack.cloud/) to learn more about it\n## Contribution\n\nFound an issue? feel free to raise an issue with information to reproduce.\n\nPull requests are welcome to improve.\n\n## License\n\nMIT\n\nThis project is a fork of [nx-serverless](https://github.com/sudokar/nx-serverless)\n\n\u003ca href=\"https://www.flaticon.com/free-icons/monster\" title=\"monster icons\"\u003eMonster icons created by Smashicons - Flaticon\u003c/a\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fngneat%2Fnx-serverless","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fngneat%2Fnx-serverless","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fngneat%2Fnx-serverless/lists"}