Skip to content

Commit

Permalink
Update dependencies and remove unused code
Browse files Browse the repository at this point in the history
  • Loading branch information
MajorTom327 committed Jan 30, 2024
1 parent f3a7663 commit c571e16
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 109 deletions.
36 changes: 18 additions & 18 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -141,21 +141,21 @@ jobs:
- name: 🏗 Build
run: npm run build

- name: 🛠 Install Arc
run: npm i -g @architect/architect

- name: 🚀 Staging Deploy
if: github.ref == 'refs/heads/dev'
run: arc deploy --staging --prune
env:
CI: true
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}

- name: 🚀 Production Deploy
if: github.ref == 'refs/heads/main'
run: arc deploy --production --prune
env:
CI: true
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
# - name: 🛠 Install Arc
# run: npm i -g @architect/architect

# - name: 🚀 Staging Deploy
# if: github.ref == 'refs/heads/dev'
# run: arc deploy --staging --prune
# env:
# CI: true
# AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
# AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}

# - name: 🚀 Production Deploy
# if: github.ref == 'refs/heads/main'
# run: arc deploy --production --prune
# env:
# CI: true
# AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
# AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
48 changes: 3 additions & 45 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
# Lofi Stack (Based on Remix Grunge Stack)

![The Remix Grunge Stack](https://repository-images.githubusercontent.com/463325363/edae4f5b-1a13-47ea-b90c-c05badc2a700)
![Lofi Stack](lofi-stack.png)

Learn more about [Remix Stacks](https://remix.run/stacks).

```
npx create-remix@latest --template remix-run/grunge-stack
npx create-remix@latest --template majortom327/lofi-stack
```

## What's in the stack

- [AWS deployment](https://aws.com) with [Architect](https://arc.codes/)
- Production-ready [DynamoDB Database](https://aws.amazon.com/dynamodb/)
- [GitHub Actions](https://github.com/features/actions) for deploy on merge to production and staging environments
- Email/Password Authentication with [cookie-based sessions](https://remix.run/utils/sessions#createcookiesessionstorage)
- DynamoDB access via [`arc.tables`](https://arc.codes/docs/en/reference/runtime-helpers/node.js#arc.tables)
- Email/Password Authentication with [Remix Auth](https://github.com/sergiodxa/remix-auth) and [Auth0](https://auth0.com)
- Styling with [Tailwind](https://tailwindcss.com/)
- End-to-end testing with [Cypress](https://cypress.io)
- Local third party request mocking with [MSW](https://mswjs.io)
Expand All @@ -25,12 +21,6 @@ npx create-remix@latest --template remix-run/grunge-stack

Not a fan of bits of the stack? Fork it, change it, and use `npx create-remix --template your/repo`! Make it your own.

## Quickstart

Click this button to create a [Gitpod](https://gitpod.io) workspace with the project set up

[![Gitpod Ready-to-Code](https://img.shields.io/badge/Gitpod-Ready--to--Code-blue?logo=gitpod)](https://gitpod.io/from-referrer/)

## Development

- First run this stack's `remix.init` script and commit the changes it makes to your project.
Expand Down Expand Up @@ -58,46 +48,14 @@ This starts your app in development mode, rebuilding assets on file changes.

### Relevant code:

This is a pretty simple note-taking app, but it's a good example of how you can build a full stack app with Architect and Remix. The main functionality is creating users, logging in and out, and creating and deleting notes.

- creating users, and logging in and out [./app/models/user.server.ts](./app/models/user.server.ts)
- user sessions, and verifying them [./app/session.server.ts](./app/session.server.ts)
- creating, and deleting notes [./app/models/note.server.ts](./app/models/note.server.ts)

The database that comes with `arc sandbox` is an in memory database, so if you restart the server, you'll lose your data. The Staging and Production environments won't behave this way, instead they'll persist the data in DynamoDB between deployments and Lambda executions.

## Deployment

This Remix Stack comes with two GitHub Actions that handle automatically deploying your app to production and staging environments. By default, Arc will deploy to the `us-west-2` region, if you wish to deploy to a different region, you'll need to change your [`app.arc`](https://arc.codes/docs/en/reference/project-manifest/aws)

Prior to your first deployment, you'll need to do a few things:

- Create a new [GitHub repo](https://repo.new)

- [Sign up](https://portal.aws.amazon.com/billing/signup#/start) and login to your AWS account

- Add `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY` to [your GitHub repo's secrets](https://docs.github.com/en/actions/security-guides/encrypted-secrets). Go to your AWS [security credentials](https://console.aws.amazon.com/iam/home?region=us-west-2#/security_credentials) and click on the "Access keys" tab, and then click "Create New Access Key", then you can copy those and add them to your repo's secrets.

- Install the [AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html#getting-started-install-instructions).

- Create an [AWS credentials file](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-quickstart.html#getting-started-quickstart-new).

- Along with your AWS credentials, you'll also need to give your CloudFormation a `SESSION_SECRET` variable of its own for both staging and production environments, as well as an `ARC_APP_SECRET` for Arc itself.

```sh
npx arc env --add --env staging ARC_APP_SECRET $(openssl rand -hex 32)
npx arc env --add --env staging SESSION_SECRET $(openssl rand -hex 32)
npx arc env --add --env production ARC_APP_SECRET $(openssl rand -hex 32)
npx arc env --add --env production SESSION_SECRET $(openssl rand -hex 32)
```

If you don't have openssl installed, you can also use [1password](https://1password.com/password-generator) to generate a random secret, just replace `$(openssl rand -hex 32)` with the generated secret.

## Where do I find my CloudFormation?

You can find the CloudFormation template that Architect generated for you in the sam.yaml file.

To find it on AWS, you can search for [CloudFormation](https://console.aws.amazon.com/cloudformation/home) (make sure you're looking at the correct region!) and find the name of your stack (the name is a PascalCased version of what you have in `app.arc`, so by default it's LofiStackStaging and LofiStackProduction) that matches what's in `app.arc`, you can find all of your app's resources under the "Resources" tab.

## GitHub Actions

Expand Down
32 changes: 0 additions & 32 deletions app.arc

This file was deleted.

7 changes: 1 addition & 6 deletions app/routes/_app._index/route.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export default function Index() {
</div>

<div className="mx-auto max-w-7xl px-4 py-2 sm:px-6 lg:px-8">
<div className="mt-6 flex flex-wrap justify-center gap-8">
<div className="mt-6 flex gap-8 flex-wrap justify-center">
{[
{
src: "https://user-images.githubusercontent.com/1500684/157991167-651c8fc5-2f72-4afa-94d8-2520ecbc5ebc.svg",
Expand All @@ -87,11 +87,6 @@ export default function Index() {
alt: "DynamoDB",
href: "https://aws.amazon.com/dynamodb/",
},
{
src: "https://user-images.githubusercontent.com/1500684/157990874-31f015c3-2af7-4669-9d61-519e5ecfdea6.svg",
alt: "Architect",
href: "https://arc.codes",
},
{
src: "https://user-images.githubusercontent.com/1500684/157764276-a516a239-e377-4a20-b44a-0ac7b65c8c14.svg",
alt: "Tailwind",
Expand Down
Binary file added lofi-stack.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 0 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,7 @@
"/public/build"
],
"dependencies": {
"@architect/architect": "^10.14.2",
"@architect/functions": "^7.0.0",
"@paralleldrive/cuid2": "^2.2.2",
"@prisma/client": "^5.8.1",
"@remix-run/architect": "*",
"@remix-run/css-bundle": "*",
"@remix-run/node": "*",
"@remix-run/react": "*",
Expand Down Expand Up @@ -64,7 +60,6 @@
"@testing-library/cypress": "^10.0.1",
"@testing-library/jest-dom": "^6.1.4",
"@trivago/prettier-plugin-sort-imports": "^4.3.0",
"@types/architect__functions": "^3.13.10",
"@types/bcryptjs": "2.4.5",
"@types/eslint": "^8.44.6",
"@types/luxon": "^3.4.1",
Expand Down
4 changes: 4 additions & 0 deletions prettier.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,8 @@ module.exports = {
],
importOrderSeparation: true,
importOrderSortSpecifiers: true,
plugins: [
"@trivago/prettier-plugin-sort-imports",
"prettier-plugin-tailwindcss",
],
};
4 changes: 2 additions & 2 deletions remix.init/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const crypto = require("node:crypto");
const fs = require("node:fs/promises");
const path = require("node:path");

const { toLogicalID } = require("@architect/utils");

const PackageJson = require("@npmcli/package-json");
const inquirer = require("inquirer");
const semver = require("semver");
Expand Down Expand Up @@ -133,7 +133,7 @@ const main = async ({ packageManager, rootDirectory }) => {
`;

const newReadme = readme
.replace(new RegExp("LofiStack", "g"), toLogicalID(APP_NAME))
.replace(new RegExp("LofiStack", "g"), APP_NAME)
.replace(initInstructions, "");

updatePackageJson({ APP_NAME, packageJson });
Expand Down
1 change: 0 additions & 1 deletion server.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { createRequestHandler } from "@remix-run/architect";
import * as build from "@remix-run/dev/server-build";

if (process.env.NODE_ENV !== "production") {
Expand Down

0 comments on commit c571e16

Please sign in to comment.