Skip to content

Commit

Permalink
Merge pull request #3 from serverless-stack/v1-migration
Browse files Browse the repository at this point in the history
Update SST to V1
  • Loading branch information
fwang committed May 24, 2022
2 parents 0c39320 + 4ee722d commit c3595c1
Show file tree
Hide file tree
Showing 41 changed files with 34,840 additions and 42,875 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
node_modules

# testing
/coverage
Expand Down
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ We create a [note taking app](https://demo.serverless-stack.com) from scratch. U
This repo is a full-stack serverless app built with [SST](https://github.com/serverless-stack/serverless-stack).

- The `stacks/` directory defines our AWS infrastructure using AWS CDK.
- The `src/` directory contains the Lambda functions that power the CRUD API.
- The `backend/` directory contains the Lambda functions that power the CRUD API.
- The `frontend/` directory contains the React app.

It's a single-page React app powered by a serverless CRUD API. We also cover how add user authentication, handle file uploads, and process credit card payments with Stripe.
Expand All @@ -24,7 +24,7 @@ $ git clone https://github.com/serverless-stack/demo-notes-app

Install dependencies.

``` bash
```bash
$ npm install
```

Expand All @@ -34,36 +34,36 @@ This project refers to a `.env.local` file with a secret that we are not checkin

Start the [Live Lambda Dev Environment](https://docs.serverless-stack.com/live-lambda-development).

``` bash
```bash
$ npx sst start
```

Install dependencies for the frontend React app.

``` bash
```bash
$ cd frontend
$ npm install
```

Start the React local dev environment from the `frontend/` dir.

``` bash
```bash
$ npm start
```

#### Running Tests

From the project root.

``` bash
$ npx sst test
```bash
$ npm test
```

#### Deploying to Prod

Run this in the project root to deploy it to prod.

``` bash
```bash
$ npx sst deploy
```

Expand Down
4 changes: 2 additions & 2 deletions src/billing.js → backend/functions/billing.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Stripe from "stripe";
import handler from "./util/handler";
import { calculateCost } from "./util/cost";
import handler from "../util/handler";
import { calculateCost } from "../util/cost";

export const main = handler(async (event) => {
const { storage, source } = JSON.parse(event.body);
Expand Down
4 changes: 2 additions & 2 deletions src/create.js → backend/functions/create.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as uuid from "uuid";
import handler from "./util/handler";
import dynamoDb from "./util/dynamodb";
import handler from "../util/handler";
import dynamoDb from "../util/dynamodb";

export const main = handler(async (event) => {
const data = JSON.parse(event.body);
Expand Down
4 changes: 2 additions & 2 deletions src/delete.js → backend/functions/delete.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import handler from "./util/handler";
import dynamoDb from "./util/dynamodb";
import handler from "../util/handler";
import dynamoDb from "../util/dynamodb";

export const main = handler(async (event) => {
const params = {
Expand Down
4 changes: 2 additions & 2 deletions src/get.js → backend/functions/get.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import handler from "./util/handler";
import dynamoDb from "./util/dynamodb";
import handler from "../util/handler";
import dynamoDb from "../util/dynamodb";

export const main = handler(async (event) => {
const params = {
Expand Down
4 changes: 2 additions & 2 deletions src/list.js → backend/functions/list.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import handler from "./util/handler";
import dynamoDb from "./util/dynamodb";
import handler from "../util/handler";
import dynamoDb from "../util/dynamodb";

export const main = handler(async (event) => {
const params = {
Expand Down
4 changes: 2 additions & 2 deletions src/update.js → backend/functions/update.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import handler from "./util/handler";
import dynamoDb from "./util/dynamodb";
import handler from "../util/handler";
import dynamoDb from "../util/dynamodb";

export const main = handler(async (event) => {
const data = JSON.parse(event.body);
Expand Down
14 changes: 14 additions & 0 deletions backend/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "@demo-notes-app/backend",
"version": "0.0.0",
"type": "module",
"scripts": {},
"dependencies": {
"aws-sdk": "^2.1138.0",
"stripe": "^9.1.0",
"uuid": "^8.3.2"
},
"devDependencies": {
"@types/aws-lambda": "^8.10.97"
}
}
3 changes: 2 additions & 1 deletion test/cost.test.js → backend/test/cost.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { calculateCost } from "../src/util/cost";
import { expect, test } from "vitest";
import { calculateCost } from "../util/cost";

test("Lowest tier", () => {
const storage = 10;
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/util/debug.js → backend/util/debug.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import AWS from "aws-sdk";
let logs;

// Log AWS SDK calls
AWS.config.logger = { log: debug };
AWS.config.logger = debug;

export default function debug() {
logs.push({
Expand Down
File renamed without changes.
File renamed without changes.
1 change: 0 additions & 1 deletion frontend/.env

This file was deleted.

14 changes: 7 additions & 7 deletions frontend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ In the project directory, you can run:
### `npm start`

Runs the app in the development mode.\
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
Open [http://localhost:3000](http://localhost:3000) to view it in your browser.

The page will reload if you make edits.\
You will also see any lint errors in the console.
The page will reload when you make changes.\
You may also see any lint errors in the console.

### `npm test`

Expand All @@ -31,13 +31,13 @@ See the section about [deployment](https://facebook.github.io/create-react-app/d

### `npm run eject`

**Note: this is a one-way operation. Once you `eject`, you cant go back!**
**Note: this is a one-way operation. Once you `eject`, you can't go back!**

If you arent satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
If you aren't satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.

Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point youre on your own.
Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you're on your own.

You dont have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldnt feel obligated to use this feature. However we understand that this tool wouldnt be useful if you couldnt customize it when you are ready for it.
You don't have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn't feel obligated to use this feature. However we understand that this tool wouldn't be useful if you couldn't customize it when you are ready for it.

## Learn More

Expand Down
Loading

0 comments on commit c3595c1

Please sign in to comment.