Giter Club home page Giter Club logo

onewheel-blog's Introduction

Remix Indie Stack

The Remix Indie Stack

Learn more about Remix Stacks.

npx create-remix --template remix-run/indie-stack

What's in the 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 workspace with the project set up and Fly pre-installed

Gitpod Ready-to-Code

Development

  • Initial setup: If you just generated this project, this step has been done for you.

    npm run setup
  • Start dev server:

    npm run dev

This starts your app in development mode, rebuilding assets on file changes.

The database seed script creates a new user with some data you can use to get started:

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 Prisma and Remix. The main functionality is creating users, logging in and out, and creating and deleting notes.

Deployment

This Remix Stack comes with two GitHub Actions that handle automatically deploying your app to production and staging environments.

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

  • Install Fly

  • Sign up and log in to Fly

    fly auth signup

    Note: If you have more than one Fly account, ensure that you are signed into the same account in the Fly CLI as you are in the browser. In your terminal, run fly auth whoami and ensure the email matches the Fly account signed into the browser.

  • Create two apps on Fly, one for staging and one for production:

    fly apps create onewheel-blog-fl0t
    fly apps create onewheel-blog-fl0t-staging
    • Initialize Git.
    git init
  • Create a new GitHub Repository, and then add it as the remote for your project. Do not push your app yet!

    git remote add origin <ORIGIN_URL>
  • Add a FLY_API_TOKEN to your GitHub repo. To do this, go to your user settings on Fly and create a new token, then add it to your repo secrets with the name FLY_API_TOKEN.

  • Add a SESSION_SECRET to your fly app secrets, to do this you can run the following commands:

    fly secrets set SESSION_SECRET=$(openssl rand -hex 32) --app onewheel-blog-fl0t
    fly secrets set SESSION_SECRET=$(openssl rand -hex 32) --app onewheel-blog-fl0t-staging

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

  • Create a persistent volume for the sqlite database for both your staging and production environments. Run the following:

    fly volumes create data --size 1 --app onewheel-blog-fl0t
    fly volumes create data --size 1 --app onewheel-blog-fl0t-staging

Now that everything is set up you can commit and push your changes to your repo. Every commit to your main branch will trigger a deployment to your production environment, and every commit to your dev branch will trigger a deployment to your staging environment.

Connecting to your database

The sqlite database lives at /data/sqlite.db in your deployed application. You can connect to the live database by running fly ssh console -C database-cli.

Getting Help with Deployment

If you run into any issues deploying to Fly, make sure you've followed all of the steps above and if you have, then post as many details about your deployment (including your app name) to the Fly support community. They're normally pretty responsive over there and hopefully can help resolve any of your deployment issues and questions.

GitHub Actions

We use GitHub Actions for continuous integration and deployment. Anything that gets into the main branch will be deployed to production after running tests/build/etc. Anything in the dev branch will be deployed to staging.

Testing

Cypress

We use Cypress for our End-to-End tests in this project. You'll find those in the cypress directory. As you make changes, add to an existing file or create a new file in the cypress/e2e directory to test your changes.

We use @testing-library/cypress for selecting elements on the page semantically.

To run these tests in development, run npm run test:e2e:dev which will start the dev server for the app as well as the Cypress client. Make sure the database is running in docker as described above.

We have a utility for testing authenticated features without having to go through the login flow:

cy.login();
// you are now logged in as a new user

We also have a utility to auto-delete the user at the end of your test. Just make sure to add this in each test file:

afterEach(() => {
  cy.cleanupUser();
});

That way, we can keep your local db clean and keep your tests isolated from one another.

Vitest

For lower level tests of utilities and individual components, we use vitest. We have DOM-specific assertion helpers via @testing-library/jest-dom.

Type Checking

This project uses TypeScript. It's recommended to get TypeScript set up for your editor to get a really great in-editor experience with type checking and auto-complete. To run type checking across the whole project, run npm run typecheck.

Linting

This project uses ESLint for linting. That is configured in .eslintrc.js.

Formatting

We use Prettier for auto-formatting in this project. It's recommended to install an editor plugin (like the VSCode Prettier plugin) to get auto-formatting on save. There's also a npm run format script you can run to format all files in the project.

onewheel-blog's People

Contributors

jdeppen avatar kentcdodds avatar michaeldeboey avatar ngorror avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

onewheel-blog's Issues

(Issue solved) npm run build passes but npm run start fails (Error: Invariant failed)

UPDATE: the only way this got resolved was by adding ADMIN_EMAIL to the deploy step. Not sure this is the right way to do things in production. Any advice on setting secrets in github instead?

npm run build passes but npm run start fails. This is the error I get:

(npm run dev works and the site starts up _and functions end to end as expected).

❯ npm run start:mocks

> start:mocks
> binode --require ./mocks -- @remix-run/serve:remix-serve build

🔶 Mock server running

/Users/../Documents/code/js/remix/onewheel-blog/node_modules/tiny-invariant/dist/tiny-invariant.cjs.js:10
        throw new Error(prefix);
              ^
Error: Invariant failed
    at invariant (/Users/../Documents/code/js/remix/onewheel-blog/node_modules/tiny-invariant/dist/tiny-invariant.cjs.js:10:15)
    at getEnv (/Users/../Documents/code/js/remix/onewheel-blog/build/index.js:41:44)
    at Object.<anonymous> (/Users/../Documents/code/js/remix/onewheel-blog/build/index.js:48:14)
    at Module._compile (node:internal/modules/cjs/loader:1159:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1213:10)
    at Module.load (node:internal/modules/cjs/loader:1037:32)
    at Function.Module._load (node:internal/modules/cjs/loader:878:12)
    at Module.require (node:internal/modules/cjs/loader:1061:19)
    at require (node:internal/modules/cjs/helpers:103:18)
    at Object.<anonymous> (/Users/../Documents/code/js/remix/onewheel-blog/node_modules/@remix-run/serve/dist/cli.js:48:13)

The place where it crashes I think is right here: https://github.com/amite/remix-full-stack-blog/blob/a58b9813b0f9c01d95fd7a52eb38e14fe37a3338/app/env.server.ts#L4

export function getEnv() {
  invariant(process.env.ADMIN_EMAIL, "ADMIN_EMAIL should be defined");
  console.log("process.env.ADMIN_EMAIL: ", process.env.ADMIN_EMAIL);

  return {
    ADMIN_EMAIL: process.env.ADMIN_EMAIL,
  };
}

Somehow in production mode its not able to read process.env.ADMIN_EMAIL I think.

When I try to push to github, I get the same error as filed in this issue: #7

My repo is right here: https://github.com/amite/remix-full-stack-blog

I am running on node v18.11.0
My OS is Monterey
Link to failed job: https://github.com/amite/remix-full-stack-blog/actions/runs/3298870582/jobs/5441547406

What should I do get rid of this invariant error?

Failed at running Fly Registry Auth

I took this course with the aim of learning more about Remix. When sending a commit to git and running deploy.ci, an error occurs with the fly registry, the deploy.ci settings should be as shown in the image below?

image

Error:

image

Node version: v16.14.2
NPM version: 8.5.0

When executing "npm run dev" there will be an error message.

Hi, I followed the steps below based on your course on egghead.

  1. npx create-remix --template remix-run/indie-stack onewheel-blog
  2. cd onewheel-blog
  3. npm run dev

Then the following error message appears.

image

Node version: 16.17.0
npm version: 8.15.0
platform: Ubuntu-22.04

Form Submit on Enter

Hi,

i might have found an issue in your code:

<button
type="submit"
name="intent"
value="delete"
className="rounded bg-red-500 py-2 px-4 text-white hover:bg-red-600 focus:bg-red-400 disabled:bg-red-300"
disabled={isDeleting}
>
{isDeleting ? "Deleting..." : "Delete"}
</button>
)}
<button
type="submit"
name="intent"
value={isNewPost ? "create" : "update"}
className="rounded bg-blue-500 py-2 px-4 text-white hover:bg-blue-600 focus:bg-blue-400 disabled:bg-blue-300"
disabled={isCreating || isUpdating}
>
{isNewPost ? (isCreating ? "Creating..." : "Create Post") : null}
{isNewPost ? null : isUpdating ? "Updating..." : "Update"}
</button>
</div>

when updating the form and hitting enter, the first "submit" button will be pressed, which in this case is delete, which is kind of unexpeced, I guess… is there some way to prevent this?

I just saw this video by Ryan Florence, similar approach, but using a different form.

403 Error when initializing the remix template

Description of bug

I was going through the Remix blog tutorial I ran the following terminal command:

npx create-remix --template remix-run/indie-stack blog-tutorial

and I received this error

There was a problem fetching the file from GitHub. The request responded with a 403 status. Please try again later.

When I run the command without "--template", I can only create a basic project; all pre-configured stacks fail (indie, blues, grunge stacks).
Does anyone have any suggestions? Could anyone also run the command and specify their npm and node versions.


Node version: v16.15.0
npm version: 8.5.5

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.