Skip to content

Commit

Permalink
Test user for preview
Browse files Browse the repository at this point in the history
  • Loading branch information
benjaminleonard committed Dec 18, 2024
1 parent d7788ee commit 2a4357e
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 14 deletions.
9 changes: 6 additions & 3 deletions app/routes/notes.$id.delete.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,13 @@
*/
import { json, redirect, type ActionFunction } from '@remix-run/node'

import { isAuthenticated } from '~/services/authn.server'
// import { isAuthenticated } from '~/services/authn.server'

export const action: ActionFunction = async ({ request, params }) => {
const user = await isAuthenticated(request)
export const action: ActionFunction = async ({ params }) => {
// const user = await isAuthenticated(request)
const user = {
id: process.env.NOTES_TEST_USER_ID || '',
}

if (!user) throw new Response('User not found', { status: 401 })

Expand Down
7 changes: 5 additions & 2 deletions app/routes/notes.$id.publish.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,13 @@
*/
import { json, type ActionFunction } from '@remix-run/node'

import { isAuthenticated } from '~/services/authn.server'
// import { isAuthenticated } from '~/services/authn.server'

export const action: ActionFunction = async ({ request, params }) => {
const user = await isAuthenticated(request)
// const user = await isAuthenticated(request)
const user = {
id: process.env.NOTES_TEST_USER_ID || '',
}

if (!user) throw new Response('User not found', { status: 401 })

Expand Down
8 changes: 6 additions & 2 deletions app/routes/notes.$id_.edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import { useState } from 'react'

import { NoteForm } from '~/components/note/NoteForm'
import { Sidebar } from '~/components/note/Sidebar'
import { isAuthenticated } from '~/services/authn.server'

// import { isAuthenticated } from '~/services/authn.server'

export const loader: LoaderFunction = async ({ params: { id } }) => {
const response = await fetch(`${process.env.NOTES_API}/notes/${id}`, {
Expand All @@ -34,7 +35,10 @@ export const action: ActionFunction = async ({ request, params }) => {
const title = formData.get('title')
const body = formData.get('body')

const user = await isAuthenticated(request)
// const user = await isAuthenticated(request)
const user = {
id: process.env.NOTES_TEST_USER_ID || '',
}
if (!user) throw new Response('User not found', { status: 401 })

const response = await fetch(`${process.env.NOTES_API}/notes/${params.id}`, {
Expand Down
9 changes: 6 additions & 3 deletions app/routes/notes._index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,13 @@

import { redirect, type LoaderFunction } from '@remix-run/node'

import { isAuthenticated } from '~/services/authn.server'
// import { isAuthenticated } from '~/services/authn.server'

export const loader: LoaderFunction = async ({ request }) => {
const user = await isAuthenticated(request)
export const loader: LoaderFunction = async () => {
// const user = await isAuthenticated(request)
const user = {
id: process.env.NOTES_TEST_USER_ID || '',
}

if (!user) throw new Response('Not authorized', { status: 401 })

Expand Down
11 changes: 7 additions & 4 deletions app/routes/notes.new.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,17 @@
*/
import { json, redirect, type ActionFunction, type LoaderFunction } from '@remix-run/node'

import { isAuthenticated } from '~/services/authn.server'
// import { isAuthenticated } from '~/services/authn.server'

export const action: ActionFunction = async ({ request }) => {
const user = await isAuthenticated(request)
export const action: ActionFunction = async () => {
// const user = await isAuthenticated(request)
const user = {
id: process.env.NOTES_TEST_USER_ID || '',
}

if (!user) throw new Response('User not found', { status: 401 })

const response = await fetch('${process.env.NOTES_API}/notes', {
const response = await fetch(`${process.env.NOTES_API}/notes`, {
method: 'POST',
headers: {
'x-api-key': process.env.NOTES_API_KEY || '',
Expand Down
5 changes: 5 additions & 0 deletions notes/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,10 @@
"nanoid": "^5.0.7",
"tsc": "",
"zod": "^3.22.4"
},
"scripts": {
"start": "bun run index.ts",
"drop": "cd db && ./drop.sh",
"seed": "cd db && ./init.sh"
}
}

0 comments on commit 2a4357e

Please sign in to comment.