Skip to content

Commit 63e00fa

Browse files
committed
Fix formatted files, add prettier config, fix dotenvx scripts
1 parent 37deaf3 commit 63e00fa

File tree

12 files changed

+91
-86
lines changed

12 files changed

+91
-86
lines changed

.eslintrc.cjs

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
/** @type {import('eslint').Linter.Config} */
88
module.exports = {
99
parserOptions: {
10-
ecmaVersion: "latest",
11-
sourceType: "module",
10+
ecmaVersion: 'latest',
11+
sourceType: 'module',
1212
ecmaFeatures: {
1313
jsx: true,
1414
},
@@ -19,70 +19,70 @@ module.exports = {
1919
es6: true,
2020
},
2121
ignorePatterns: [
22-
"build/*",
23-
"node_modules/*",
24-
".wrangler/*",
25-
"tmp/*",
26-
"pnpm-lock.yaml",
27-
".eslintcache",
22+
'build/*',
23+
'node_modules/*',
24+
'.wrangler/*',
25+
'tmp/*',
26+
'pnpm-lock.yaml',
27+
'.eslintcache',
2828
],
2929

3030
// Base config
31-
extends: ["eslint:recommended", "prettier"],
31+
extends: ['eslint:recommended', 'prettier'],
3232

3333
overrides: [
3434
// React
3535
{
36-
files: ["**/*.{js,jsx,ts,tsx}"],
37-
plugins: ["react", "jsx-a11y"],
36+
files: ['**/*.{js,jsx,ts,tsx}'],
37+
plugins: ['react', 'jsx-a11y'],
3838
extends: [
39-
"plugin:react/recommended",
40-
"plugin:react/jsx-runtime",
41-
"plugin:react-hooks/recommended",
42-
"plugin:jsx-a11y/recommended",
39+
'plugin:react/recommended',
40+
'plugin:react/jsx-runtime',
41+
'plugin:react-hooks/recommended',
42+
'plugin:jsx-a11y/recommended',
4343
],
4444
settings: {
4545
react: {
46-
version: "detect",
46+
version: 'detect',
4747
},
48-
formComponents: ["Form"],
48+
formComponents: ['Form'],
4949
linkComponents: [
50-
{ name: "Link", linkAttribute: "to" },
51-
{ name: "NavLink", linkAttribute: "to" },
50+
{ name: 'Link', linkAttribute: 'to' },
51+
{ name: 'NavLink', linkAttribute: 'to' },
5252
],
53-
"import/resolver": {
53+
'import/resolver': {
5454
typescript: {},
5555
},
5656
},
5757
},
5858

5959
// Typescript
6060
{
61-
files: ["**/*.{ts,tsx}"],
62-
plugins: ["@typescript-eslint", "import", "drizzle"],
63-
parser: "@typescript-eslint/parser",
61+
files: ['**/*.{ts,tsx}'],
62+
plugins: ['@typescript-eslint', 'import', 'drizzle'],
63+
parser: '@typescript-eslint/parser',
6464
settings: {
65-
"import/internal-regex": "^~/",
66-
"import/resolver": {
65+
'import/internal-regex': '^~/',
66+
'import/resolver': {
6767
node: {
68-
extensions: [".ts", ".tsx"],
68+
extensions: ['.ts', '.tsx'],
6969
},
7070
typescript: {
7171
alwaysTryTypes: true,
7272
},
7373
},
7474
},
7575
extends: [
76-
"plugin:@typescript-eslint/recommended",
77-
"plugin:import/recommended",
78-
"plugin:import/typescript",
79-
"plugin:drizzle/recommended",
76+
'plugin:@typescript-eslint/recommended',
77+
'plugin:import/recommended',
78+
'plugin:import/typescript',
79+
'plugin:drizzle/recommended',
8080
],
8181
},
8282

8383
// Node
8484
{
85-
files: [".eslintrc.js"],
85+
files: ['.eslintrc.js'],
8686
env: {
8787
node: true,
8888
},

.prettierrc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"trailingComma": "all",
3+
"tabWidth": 2,
4+
"semi": true,
5+
"singleQuote": true
6+
}

app/root.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { type LoaderFunctionArgs, json } from "@remix-run/cloudflare";
2-
import { Links, Meta, Outlet, Scripts, useLoaderData } from "@remix-run/react";
3-
import { books } from "db/schema";
4-
import { drizzle } from "drizzle-orm/d1";
1+
import { type LoaderFunctionArgs, json } from '@remix-run/cloudflare';
2+
import { Links, Meta, Outlet, Scripts, useLoaderData } from '@remix-run/react';
3+
import { books } from 'db/schema';
4+
import { drizzle } from 'drizzle-orm/d1';
55

66
export const loader = async ({ context }: LoaderFunctionArgs) => {
77
const db = drizzle(context.cloudflare.env.DB);

app/services/auth/session.ts

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
1-
import { createCookieSessionStorage } from "@remix-run/node";
2-
import { Authenticator } from "remix-auth";
3-
import { FormStrategy } from "remix-auth-form";
4-
import { AppDB, getDB } from "../db/utilities";
5-
import { AppLoadContext } from "@remix-run/cloudflare";
6-
import { pbkdf2Sync } from "crypto";
7-
8-
// export the whole sessionStorage object
1+
import { createCookieSessionStorage } from '@remix-run/node';
2+
import { Authenticator } from 'remix-auth';
3+
import { FormStrategy } from 'remix-auth-form';
4+
import { AppDB, getDB } from '../db/utilities';
5+
import { AppLoadContext } from '@remix-run/cloudflare';
6+
import { pbkdf2Sync } from 'crypto';
7+
98
const sessionStorage = createCookieSessionStorage({
109
cookie: {
11-
name: "_session",
12-
sameSite: "lax",
13-
path: "/",
10+
name: '_session',
11+
sameSite: 'lax',
12+
path: '/',
1413
httpOnly: true,
1514
...(process.env.SESSION_SECRET
1615
? { secrets: [process.env.SESSION_SECRET] }
1716
: {}),
18-
secure: process.env.NODE_ENV === "production",
17+
secure: process.env.NODE_ENV === 'production',
1918
},
2019
});
2120

@@ -24,8 +23,8 @@ export const authenticator = new Authenticator(sessionStorage).use(
2423
if (context) {
2524
const db = getDB(context as AppLoadContext);
2625

27-
const username = form.get("username")?.toString();
28-
const password = form.get("password")?.toString();
26+
const username = form.get('username')?.toString();
27+
const password = form.get('password')?.toString();
2928

3029
if (username && password) {
3130
const user = await login(username, password, db);
@@ -34,7 +33,7 @@ export const authenticator = new Authenticator(sessionStorage).use(
3433
}
3534
}
3635
}),
37-
"user-pass",
36+
'user-pass',
3837
);
3938

4039
export const login = async (username: string, password: string, db: AppDB) => {
@@ -47,7 +46,7 @@ export const login = async (username: string, password: string, db: AppDB) => {
4746
}
4847

4948
const validPassword =
50-
pbkdf2Sync(password, user.salt, 1000, 64, "sha512").toString("hex") ===
49+
pbkdf2Sync(password, user.salt, 1000, 64, 'sha512').toString('hex') ===
5150
user.password;
5251

5352
if (!validPassword) {

app/services/db/utilities.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { AppLoadContext } from "@remix-run/cloudflare";
2-
import { drizzle } from "drizzle-orm/d1";
3-
import * as schema from "db/schema";
1+
import { AppLoadContext } from '@remix-run/cloudflare';
2+
import { drizzle } from 'drizzle-orm/d1';
3+
import * as schema from 'db/schema';
44

55
export const getDB = (context: AppLoadContext) =>
66
drizzle(context.cloudflare.env.DB, { schema });

app/types/load-context.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import type { PlatformProxy } from "wrangler";
1+
import type { PlatformProxy } from 'wrangler';
22

3-
type Cloudflare = Omit<PlatformProxy<Env>, "dispose">;
3+
type Cloudflare = Omit<PlatformProxy<Env>, 'dispose'>;
44

5-
declare module "@remix-run/cloudflare" {
5+
declare module '@remix-run/cloudflare' {
66
interface AppLoadContext {
77
cloudflare: Cloudflare;
88
}

db/schema.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
import { sqliteTable, text, integer } from "drizzle-orm/sqlite-core";
1+
import { sqliteTable, text, integer } from 'drizzle-orm/sqlite-core';
22

3-
export const books = sqliteTable("books", {
4-
id: integer("id").primaryKey(),
5-
title: text("title").unique().notNull(),
6-
author: text("author").notNull(),
7-
description: text("description").notNull(),
3+
export const books = sqliteTable('books', {
4+
id: integer('id').primaryKey(),
5+
title: text('title').unique().notNull(),
6+
author: text('author').notNull(),
7+
description: text('description').notNull(),
88
});
99

10-
export const users = sqliteTable("users", {
11-
id: integer("id").primaryKey(),
12-
username: text("username").unique().notNull(),
13-
password: text("password").notNull(),
14-
salt: text("salt").notNull(),
10+
export const users = sqliteTable('users', {
11+
id: integer('id').primaryKey(),
12+
username: text('username').unique().notNull(),
13+
password: text('password').notNull(),
14+
salt: text('salt').notNull(),
1515
});

drizzle.config.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,33 @@
1-
import { defineConfig } from "drizzle-kit";
1+
import { defineConfig } from 'drizzle-kit';
22

33
const {
44
LOCAL_DB_PATH,
55
WRANGLER_CONFIG,
6-
DB_NAME = "math-rock-stack",
6+
DB_NAME = 'math-rock-stack',
77
} = process.env;
88

99
export default defineConfig(
1010
LOCAL_DB_PATH
1111
? {
12-
dialect: "sqlite",
13-
schema: "./db/schema.ts",
12+
dialect: 'sqlite',
13+
schema: './db/schema.ts',
1414
dbCredentials: {
1515
url: LOCAL_DB_PATH,
1616
},
1717
}
1818
: {
19-
dialect: "sqlite",
20-
schema: "./db/schema.ts",
21-
out: "./migrations",
22-
driver: "d1",
19+
dialect: 'sqlite',
20+
schema: './db/schema.ts',
21+
out: './migrations',
22+
driver: 'd1',
2323
dbCredentials: {
2424
wranglerConfigPath:
25-
new URL("wrangler.toml", import.meta.url).pathname +
25+
new URL('wrangler.toml', import.meta.url).pathname +
2626
// This is a hack to inject additional cli flags to wrangler
2727
// since drizzle-kit doesn't support specifying environments
2828
WRANGLER_CONFIG
2929
? ` ${WRANGLER_CONFIG}`
30-
: "",
30+
: '',
3131
dbName: DB_NAME,
3232
},
3333
},

functions/[[path]].ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { createPagesFunctionHandler } from "@remix-run/cloudflare-pages";
1+
import { createPagesFunctionHandler } from '@remix-run/cloudflare-pages';
22

33
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
44
// @ts-ignore - the server build file is generated by `remix vite:build`
55
// eslint-disable-next-line import/no-unresolved
6-
import * as build from "../build/server";
6+
import * as build from '../build/server';
77

88
export const onRequest = createPagesFunctionHandler({ build });

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@
77
"main": "build/client/index.js",
88
"scripts": {
99
"dev": "dotenvx run -f .env.local -- remix vite:dev --open",
10-
"build": "dotenv run -f .env.prod -- remix vite:build",
10+
"build": "dotenvx run -f .env.prod -- remix vite:build",
1111
"lint": "eslint . --cache",
1212
"format:check": "prettier . --check",
1313
"format:write": "prettier . --write",
1414
"cf-typegen": "wrangler types",
1515
"db:update": "drizzle-kit up",
1616
"db:migrate:create": "drizzle-kit generate:sqlite",
1717
"db:migrate:apply:local": "dotenvx run -f .env.local -- sh scripts/db-migrate.sh",
18-
"db:migrate:apply:prod": "dotenvx run -- -f .env.prod sh scripts/db-migrate-prod.sh",
18+
"db:migrate:apply:prod": "dotenvx run -f .env.prod -- sh scripts/db-migrate-prod.sh",
1919
"db:studio:local": "LOCAL_DB_PATH=$(find .wrangler/state/v3/d1/miniflare-D1DatabaseObject -type f -name '*.sqlite' -print -quit) drizzle-kit studio",
2020
"db:sync": "dotenvx run -f .env.local -- sh scripts/db-sync.sh"
2121
},

vite.config.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import {
22
vitePlugin as remix,
33
cloudflareDevProxyVitePlugin as remixCloudflareDevProxy,
4-
} from "@remix-run/dev";
5-
import { defineConfig } from "vite";
6-
import tsconfigPaths from "vite-tsconfig-paths";
4+
} from '@remix-run/dev';
5+
import { defineConfig } from 'vite';
6+
import tsconfigPaths from 'vite-tsconfig-paths';
77

88
export default defineConfig({
99
plugins: [remixCloudflareDevProxy(), remix(), tsconfigPaths()],

worker-configuration.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
// by running `wrangler types`
33

44
interface Env {
5-
CLOUDFLARE_ACCOUNT_ID: "887644ede3080f7152aa22e9ecf52f0f";
5+
CLOUDFLARE_ACCOUNT_ID: '887644ede3080f7152aa22e9ecf52f0f';
66
DB: D1Database;
77
}

0 commit comments

Comments
 (0)