Skip to content

Commit 82be457

Browse files
committed
[add] File model & controller based on AWS S3 compatible API
[add] WebAuthn model & controller based on Passwordless ID [add] Email One-Time-Password based on Supabase SDK
1 parent 654f55f commit 82be457

File tree

17 files changed

+1733
-39
lines changed

17 files changed

+1733
-39
lines changed

.dockerignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
ReadMe.md
22
node_modules/
33
dist/
4-
.*/
4+
.*
55
!.npmrc
6+
!.env*
67
start.sh
78
eslint.config.mjs
89
*.pem

.env.example

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
APP_SECRET = random_string
2+
DATABASE_URL = postgresql://your-account:[email protected]:5432/postgres
3+
4+
GITHUB_PAT = # set by admin
5+
6+
SUPABASE_PROJECT_URL = https://your-id.supabase.co
7+
SUPABASE_ANON_KEY = your.jwt
8+
9+
AWS_S3_END_POINT = https://your-id.r2.cloudflarestorage.com
10+
AWS_S3_BUCKET = your-bucket-name
11+
AWS_S3_ACCESS_KEY_ID = your-access-key-id
12+
AWS_S3_SECRET_ACCESS_KEY = your-secret-access-key
13+
AWS_S3_PUBLIC_HOST = https://pub-your-id.r2.dev

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@ test/client.ts
55
dist/
66
type/*.d.ts
77
.env*
8+
!.env.example
89
.data/
910
.vscode/settings.json

ReadMe.md

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,17 +46,24 @@
4646

4747
## API Usage
4848

49-
- Entry: http://localhost:8080/
50-
- Document: http://localhost:8080/docs/
51-
- Schema: http://localhost:8080/docs/spec/
52-
- Type: https://github.com/idea2app/REST-Node-ts/pkgs/npm/rest-node-ts
49+
- Entry: http://localhost:8080/
50+
- Document: http://localhost:8080/docs/
51+
- Schema: http://localhost:8080/docs/spec/
52+
- Type: https://github.com/idea2app/REST-Node-ts/pkgs/npm/rest-node-ts
5353

5454
## Environment variables
5555

56-
| Name | Usage |
57-
| :------------: | :--------------------------: |
58-
| `APP_SECRET` | encrypt Password & Token |
59-
| `DATABASE_URL` | PostgreSQL connection string |
56+
| Name | Usage |
57+
| :------------------------: | :--------------------------: |
58+
| `APP_SECRET` | encrypt Password & Token |
59+
| `DATABASE_URL` | PostgreSQL connection string |
60+
| `SUPABASE_PROJECT_URL` | [Supabase][24] project URL |
61+
| `SUPABASE_ANON_KEY` | Supabase anon key |
62+
| `AWS_S3_END_POINT` | [AWS S3][25] endpoint URL |
63+
| `AWS_S3_BUCKET` | AWS S3 bucket name |
64+
| `AWS_S3_ACCESS_KEY_ID` | AWS S3 access key id |
65+
| `AWS_S3_SECRET_ACCESS_KEY` | AWS S3 secret access key |
66+
| `AWS_S3_PUBLIC_HOST` | AWS S3 public host |
6067

6168
## Development
6269

@@ -143,3 +150,5 @@ git push origin master --tags
143150
[21]: https://github.com/kaiyuanshe/kaiyuanshe.github.io/blob/bb4675a56bf1d6b207231313da5ed0af7cf0ebd6/.github/workflows/pull-request.yml#L32-L56
144151
[22]: https://github.com/idea2app/REST-Node-ts/issues/new/choose
145152
[23]: https://github.com/idea2app/REST-Node-ts/projects
153+
[24]: https://supabase.com/
154+
[25]: https://aws.amazon.com/s3/

package.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@idea2app/rest-node-ts",
3-
"version": "1.0.0",
3+
"version": "1.2.0",
44
"license": "LGPL-3.0",
55
"author": "[email protected]",
66
"description": "RESTful API service scaffold based on Node.js & TypeScript",
@@ -18,9 +18,15 @@
1818
"node": ">=22"
1919
},
2020
"dependencies": {
21+
"@aws-sdk/client-s3": "^3.779.0",
22+
"@aws-sdk/s3-request-presigner": "^3.779.0",
2123
"@koa/cors": "^5.0.0",
2224
"@koa/multer": "^3.1.0",
2325
"@koa/router": "^13.1.0",
26+
"@passwordless-id/webauthn": "^2.3.0",
27+
"@smithy/smithy-client": "^4.1.6",
28+
"@supabase/auth-js": "^2.69.1",
29+
"@supabase/supabase-js": "^2.49.4",
2430
"class-transformer": "^0.5.1",
2531
"class-validator": "^0.14.1",
2632
"cross-env": "^7.0.3",
@@ -95,6 +101,7 @@
95101
"preset": "ts-jest"
96102
},
97103
"scripts": {
104+
"install": "mv .env.example .env || true",
98105
"prepare": "husky || true",
99106
"dev": "cross-env TS_NODE_TRANSPILE_ONLY=true node -r ts-node/register --watch source/",
100107
"lint": "lint-staged",

0 commit comments

Comments
 (0)