• Stars
    star
    388
  • Rank 110,734 (Top 3 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created over 2 years ago
  • Updated about 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

🚀 The Ultimate Monorepo Starter for Node.js Serverless Applications

Nx Serverless

The Ultimate Monorepo Starter for Node.js Serverless Applications

 First-Class Typescript Support
 DynamoDB Single Table Design
 Shared API Gateway
 Environments Configuration
 CORS
 JWT Auth Middleware
 Http Params Validation
 Typed Proxy Handlers
 Auto Generators
 Localstack
 ESLint
 Jest
 Github Actions


serverless esbuild npm peer dependency version (scoped) code style: prettier GitHub license PRs Welcome Maintained

Prerequisites

  • Docker
  • Node.js

Getting Started

About the App

The application contains three services:

Auth Service:

The auth service is responsible for authentication. It exposes one route for signing up:

curl --request POST 'http://localhost:3001/dev/auth/sign-up' \
--data-raw '{
    "email": "[email protected]",
    "name": "Netanel Basal"
}'

The request returns a JWT, which is used for accessing protected routes.

Users Service:

The users service is responsible for managing users. It exposes one route:

curl 'http://localhost:3003/dev/user' --header 'Authorization: token TOKEN'

The request returns the logged-in user.

Todos Service:

The todos service is responsible for managing todos. A user has many todos. It exposes CRUD routes:

// Get user todos
curl 'http://localhost:3005/dev/todos' --header 'Authorization: token TOKEN'

// Get a single todo
curl 'http://localhost:3005/dev/todos/:id' --header 'Authorization: token TOKEN'

// Create a todo
curl --request POST 'http://localhost:3005/dev/todos' \
--header 'Authorization: token TOKEN'
--data-raw '{
    "title": "Learn Serverless"
}'

// Update a todo
curl  --request PUT 'http://localhost:3005/dev/todos/:id' \
--header 'Authorization: token TOKEN' \
--data-raw '{
    "completed": true
}'

DynamoDB GUI

Download NoSQL Workbench for DynamoDB and connect to http://localhost:4566.

Commands

nx serve <service-name>
nx deploy <service-name>
nx remove <service-name>
nx build <service-name>
nx lint <service-name>
nx test <service-name>

// Use different enviroment
NODE_ENV=prod nx deploy <service-name> 
NODE_ENV=stg nx deploy <service-name> 

// Run only affected
nx affected:test
nx affected:deploy

Generators

// Generate a service
yarn g:service tags

// Generate handler
yarn g:handler handler-name

// Generate http handler
yarn g:http-handler create-tag

// Generate a model
yarn g:model tag


CI/CD Pipeline with Github Actions

The pipeline has been configured to run everytime a push/pull_request is made to the main branch. You should uncomment the ci.yml workflow.

Workflow Steps

  • Checkout: The checkout action is used to checkout the source code.

  • Node setup: The setup-node action is used to optionally download and cache distribution of the requested Node.js version.

  • lint and test: The lint and test runs only on affected projects.

  • Configure AWS credentials: The credentials needed are AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY and should be set as Github secrets.

  • 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.

By merging the pull request to the main branch, NODE_ENV is set to prod, and the deployment is done to production.

The workflow file can have as many environments as you need.

Further help

Contribution

Found an issue? feel free to raise an issue with information to reproduce.

Pull requests are welcome to improve.

License

MIT

This project is a fork of nx-serverless

Monster icons created by Smashicons - Flaticon

More Repositories

1

falso

All the Fake Data for All Your Real Needs 🙂
TypeScript
3,098
star
2

spectator

🦊 🚀 A Powerful Tool to Simplify Your Angular Tests
TypeScript
2,068
star
3

transloco

🚀 😍 The internationalization (i18n) library for Angular
TypeScript
1,856
star
4

until-destroy

🦊 RxJS operator that unsubscribe from observables on destroy
TypeScript
1,733
star
5

elf

🧙‍♀️ A Reactive Store with Magical Powers
TypeScript
1,527
star
6

content-loader

⚪️ SVG component to create placeholder loading, like Facebook cards loading.
TypeScript
733
star
7

hot-toast

🍞 Smoking hot Notifications for Angular. Lightweight, customizable and beautiful by default.
TypeScript
687
star
8

cashew

🐿 A flexible and straightforward library that caches HTTP requests in Angular
TypeScript
677
star
9

reactive-forms

(Angular Reactive) Forms with Benefits 😉
TypeScript
609
star
10

tailwind

🔥 A schematic that adds Tailwind CSS to Angular applications
TypeScript
608
star
11

query

🚀 Powerful asynchronous state management, server-state utilities and data fetching for Angular Applications
TypeScript
555
star
12

forms-manager

🦄 The Foundation for Proper Form Management in Angular
TypeScript
517
star
13

error-tailor

🦄 Making sure your tailor-made error solution is seamless!
TypeScript
478
star
14

helipopper

🚁 A Powerful Tooltip and Popover for Angular Applications
TypeScript
392
star
15

dialog

👻 A simple to use, highly customizable, and powerful modal for Angular Applications
TypeScript
371
star
16

hotkeys

🤖 A declarative library for handling hotkeys in Angular applications
TypeScript
325
star
17

edit-in-place

A flexible and unopinionated edit in place library for Angular applications
TypeScript
252
star
18

svg-icon

👻 A lightweight library that makes it easier to use SVG icons in your Angular Application
TypeScript
251
star
19

inspector

🕵️ An angular library that lets you inspect and change Angular component properties
TypeScript
218
star
20

dirty-check-forms

🐬Detect Unsaved Changes in Angular Forms
TypeScript
199
star
21

input-mask

🎭 @ngneat/input-mask is an angular library that creates an input mask
TypeScript
199
star
22

lib

🤖 Lets you focus on the stuff that matters
TypeScript
180
star
23

transloco-keys-manager

🦄 The Key to a Better Translation Experience
TypeScript
174
star
24

dag

🐠 An Angular service for managing directed acyclic graphs
TypeScript
153
star
25

bind-query-params

Sync URL Query Params with Angular Form Controls
TypeScript
147
star
26

from-event

🦊 ViewChild and FromEvent — a Match Made in Angular Heaven
TypeScript
137
star
27

overview

🤖 A collection of tools to make your Angular views more modular, scalable, and maintainable
TypeScript
118
star
28

aim

Angular Inline Module Schematics
TypeScript
97
star
29

cmdk

Fast, composable, unstyled command menu for Angular. Directly inspired from pacocoursey/cmdk
TypeScript
91
star
30

copy-to-clipboard

✂️ Modern copy to clipboard. No Flash.
TypeScript
78
star
31

variabless

JS & CSS - A Match Made in Heaven 💎
HTML
78
star
32

loadoff

🤯 When it comes to loaders, take a load off your mind...
TypeScript
78
star
33

effects

🪄 A framework-agnostic RxJS effects implementation
TypeScript
63
star
34

avvvatars

Beautifully crafted unique avatar placeholder for your next angular project.
TypeScript
46
star
35

react-rxjs

🔌 "Plug and play" for Observables in React Apps!
TypeScript
37
star
36

subscribe

Subscription Handling Directive
TypeScript
34
star
37

elf-ng-router-store

Bindings to connect Angular router to Elf
TypeScript
24
star
38

ng-standalone-nx

TypeScript
24
star
39

lit-file-generator

🎁 A lit generator for a component, directive, and controller.
JavaScript
19
star
40

storage

TypeScript
18
star
41

material-schematics

TypeScript
3
star
42

svg-icon-demo

TypeScript
1
star