Skip to content

Commit 6fd63d2

Browse files
committed
init
0 parents  commit 6fd63d2

File tree

123 files changed

+36605
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

123 files changed

+36605
-0
lines changed

.editorconfig

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Editor configuration, see http://editorconfig.org
2+
root = true
3+
4+
[*]
5+
charset = utf-8
6+
indent_style = space
7+
indent_size = 2
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true
10+
11+
[*.md]
12+
max_line_length = off
13+
trim_trailing_whitespace = false

.eslintrc.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"root": true,
3+
"ignorePatterns": ["**/*"],
4+
"plugins": ["@nrwl/nx"],
5+
"overrides": [
6+
{
7+
"files": ["*.ts", "*.tsx"],
8+
"extends": ["plugin:@nrwl/nx/typescript"],
9+
"rules": {
10+
"@typescript-eslint/no-explicit-any": ["off"]
11+
}
12+
},
13+
{
14+
"files": ["*.js", "*.jsx"],
15+
"extends": ["plugin:@nrwl/nx/javascript"],
16+
"rules": {}
17+
}
18+
]
19+
}

.github/workflows/main.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# This is a basic workflow to help you get started with Actions
2+
3+
name: CI
4+
5+
# Controls when the workflow will run
6+
on:
7+
# Triggers the workflow on push or pull request events but only for the main branch
8+
push:
9+
branches: [main]
10+
pull_request:
11+
branches: [main]
12+
13+
# Allows you to run this workflow manually from the Actions tab
14+
workflow_dispatch:
15+
16+
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
17+
jobs:
18+
# This workflow contains a single job called "build"
19+
build:
20+
# The type of runner that the job will run on
21+
runs-on: ubuntu-latest
22+
23+
# Steps represent a sequence of tasks that will be executed as part of the job
24+
steps:
25+
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
26+
- uses: actions/checkout@v3
27+
- uses: actions/setup-node@v3
28+
with:
29+
node-version: '14.x'

.gitignore

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# See http://help.github.com/ignore-files/ for more about ignoring files.
2+
3+
# compiled output
4+
/dist
5+
/tmp
6+
/out-tsc
7+
8+
# dependencies
9+
/node_modules
10+
11+
# IDEs and editors
12+
/.idea
13+
.project
14+
.classpath
15+
.c9/
16+
*.launch
17+
.settings/
18+
*.sublime-workspace
19+
20+
# IDE - VSCode
21+
.vscode/*
22+
!.vscode/settings.json
23+
!.vscode/tasks.json
24+
!.vscode/launch.json
25+
!.vscode/extensions.json
26+
27+
# misc
28+
/.sass-cache
29+
/connect.lock
30+
/coverage
31+
/libpeerconnection.log
32+
npm-debug.log
33+
yarn-error.log
34+
testem.log
35+
/typings
36+
37+
# System Files
38+
.DS_Store
39+
Thumbs.db
40+
41+
.serverless
42+
.vscode
43+
.dynamodb
44+
.webpack

.husky/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
_

.husky/pre-commit

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
. "$(dirname "$0")/_/husky.sh"
3+
4+
npm run lint-staged --concurrent 5

.prettierignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Add files here to ignore them from prettier formatting
2+
3+
/dist
4+
/coverage
5+
.esbuild

.prettierrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"singleQuote": true
3+
}

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2022 Netanel Basal
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
<br />
2+
<p align="center">
3+
<img width="25%" height="25%" src="./logo.png">
4+
</p>
5+
6+
<h1 align="center">Nx Serverless</h1>
7+
8+
> The Ultimate Monorepo Starter for Node.js Serverless Applications
9+
10+
&nbsp;First-Class Typescript Support<br>
11+
&nbsp;DynamoDB Single Table Design<br>
12+
&nbsp;Shared API Gateway<br>
13+
&nbsp;Enviroments Configuration<br>
14+
&nbsp;JWT Auth Middleware<br>
15+
&nbsp;Http Params Validation<br>
16+
&nbsp;Typed Proxy Handlers<br>
17+
&nbsp;Auto Generators<br>
18+
&nbsp;Localstack<br>
19+
&nbsp;ESLint<br>
20+
&nbsp;Jest
21+
22+
<hr />
23+
24+
[![serverless](http://public.serverless.com/badges/v3.svg)](http://www.serverless.com)
25+
[![](https://img.shields.io/badge/monorepo-Nx-blue)](https://nx.dev/)
26+
![esbuild](https://badges.aleen42.com/src/esbuild.svg)
27+
![npm peer dependency version (scoped)](https://img.shields.io/npm/dependency-version/eslint-config-prettier/peer/eslint)
28+
![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)
29+
[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/sudokar/nx-serverless/blob/master/LICENSE)
30+
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/sudokar/nx-serverless)
31+
![Maintained](https://img.shields.io/maintenance/yes/2022.svg)
32+
33+
34+
## Prerequisites
35+
36+
- Docker
37+
- Node.js
38+
39+
## Getting Started
40+
41+
- Run git clone https://github.com/ngneat/nx-serverless.git your-app-name
42+
- Run `npm install`
43+
- Run `npm run localstack`
44+
- Update the `environment` files based on your configuration.
45+
- Run `npm run serve`
46+
47+
## About the App
48+
49+
The application contains three services:
50+
51+
#### Auth Service:
52+
53+
The auth service is responsible for authentication. It exposes one route for signing up:
54+
55+
```bash
56+
curl --request POST 'http://localhost:3001/dev/auth/sign-up' \
57+
--data-raw '{
58+
"email": "netanel@gmail.com",
59+
"name": "Netanel Basal"
60+
}'
61+
```
62+
63+
The request returns a JWT, which is used for accessing protected routes.
64+
65+
#### Users Service:
66+
67+
The users service is responsible for managing users. It exposes one route:
68+
69+
```bash
70+
curl 'http://localhost:3003/dev/user' --header 'Authorization: token TOKEN'
71+
```
72+
73+
The request returns the logged-in user.
74+
75+
#### Todos service:
76+
77+
The todos service is responsible for managing todos. A user has many todos. It exposes CRUD routes:
78+
79+
```bash
80+
// Get user todos
81+
curl 'http://localhost:3005/dev/todos' --header 'Authorization: token TOKEN'
82+
83+
// Get single todo
84+
curl 'http://localhost:3005/dev/todos/:id' --header 'Authorization: token TOKEN'
85+
86+
// Create a todo
87+
curl --request POST 'http://localhost:3005/dev/todos' \
88+
--header 'Authorization: token TOKEN'
89+
--data-raw '{
90+
"title": "Learn Serverless"
91+
}'
92+
93+
// Update a todo
94+
curl --request PUT 'http://localhost:3005/dev/todos/01G2HGJADWKDPKWHJAVZJ1QP9S' \
95+
--header 'Authorization: token TOKEN' \
96+
--data-raw '{
97+
"completed": true
98+
}'
99+
```
100+
101+
## Commands
102+
103+
```bash
104+
nx serve <service-name>
105+
nx deploy <service-name>
106+
nx remove <service-name>
107+
nx build <service-name>
108+
nx lint <service-name>
109+
nx test <service-name>
110+
111+
// Use different enviroment
112+
NODE_ENV=prod nx deploy <service-name>
113+
NODE_ENV=stg nx deploy <service-name>
114+
115+
// Run only affected
116+
nx affected:test
117+
nx affected:deploy
118+
```
119+
120+
## Generators
121+
122+
```bash
123+
// Generate a service
124+
npx nx workspace-generator service tags
125+
126+
// Generate handler
127+
npx nx workspace-generator handler --name=create-tag --project=tags
128+
129+
// Generate http handler
130+
npx nx workspace-generator http-handler --name=create-tag --project=tags
131+
132+
// Generate a model
133+
npx nx workspace-generator model --name=tag --project=tags
134+
```
135+
136+
## Further help
137+
138+
- Visit [Serverless Documentation](https://www.serverless.com/framework/docs/) to learn more about Serverless framework
139+
- Visit [Nx Documentation](https://nx.dev) to learn more about Nx dev toolkit
140+
141+
## Contribution
142+
143+
Found an issue? feel free to raise an issue with information to reproduce.
144+
145+
Pull requests are welcome to improve.
146+
147+
## License
148+
149+
MIT
150+
151+
This project is a fork of [nx-serverless](https://github.com/sudokar/nx-serverless)
152+
153+
<a href="https://www.flaticon.com/free-icons/monster" title="monster icons">Monster icons created by Smashicons - Flaticon</a>

0 commit comments

Comments
 (0)