Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
306 commits
Select commit Hold shift + click to select a range
7618c2f
Distinguish between loading and no content states
mazzzystar Sep 19, 2024
6d6aa91
beautify footer.
mazzzystar Sep 19, 2024
4603ce9
change padding.
mazzzystar Sep 19, 2024
a48d43b
change padding.
mazzzystar Sep 19, 2024
a1850ec
change padding.
mazzzystar Sep 19, 2024
e4c70a7
change padding.
mazzzystar Sep 19, 2024
b3c814c
change padding.
mazzzystar Sep 19, 2024
d579df0
add public statement.
mazzzystar Sep 19, 2024
cf4d27b
add id,it,nl,pl,th,tr,vi locale.
mazzzystar Sep 19, 2024
5c30762
add id,it,nl,pl,th,tr,vi locale.
mazzzystar Sep 19, 2024
c67cea8
prettify blog list
mazzzystar Sep 19, 2024
1c8a156
prettify blog list
mazzzystar Sep 19, 2024
c4056e3
prettify thoughts
mazzzystar Sep 19, 2024
b63191b
prettify editor button
mazzzystar Sep 19, 2024
5960375
editor text-area min height from 200->300
mazzzystar Sep 19, 2024
0d9c6f0
editor text-area min height from 200->300
mazzzystar Sep 19, 2024
e7dee1f
prettify editor
mazzzystar Sep 20, 2024
f8b631c
prettify editor
mazzzystar Sep 20, 2024
960e4dd
add preview for markdown
mazzzystar Sep 20, 2024
7fc2d4c
add preview for markdown
mazzzystar Sep 20, 2024
5d37f3b
add locale for write & preivew button.
mazzzystar Sep 20, 2024
3e83675
prettify edit button.
mazzzystar Sep 20, 2024
85ab843
add button when no blog.
mazzzystar Sep 20, 2024
5514cb1
set editor type based on user's current tab.
mazzzystar Sep 20, 2024
130ea4b
set editor type based on user's current tab.
mazzzystar Sep 20, 2024
a4ec844
show publish delay showing hint.
mazzzystar Sep 20, 2024
6c931f7
change font.
mazzzystar Sep 20, 2024
7af287f
fix blog title chinese name issue.
mazzzystar Sep 20, 2024
6f944aa
fix blog title chinese name issue.
mazzzystar Sep 20, 2024
7720898
fix blog title chinese name issue.
mazzzystar Sep 20, 2024
3203535
fix blog title chinese name issue.
mazzzystar Sep 20, 2024
1dc9324
fix blog title chinese name issue.
mazzzystar Sep 20, 2024
85d504c
fix blog title chinese name issue.
mazzzystar Sep 20, 2024
7b444cb
fix blog title chinese name issue.
mazzzystar Sep 20, 2024
6e4e5b6
fix blog title chinese name issue.
mazzzystar Sep 20, 2024
fa2c51c
fix blog title chinese name issue.
mazzzystar Sep 20, 2024
bf33971
fix title parse issue.
mazzzystar Sep 20, 2024
ea33e87
fix title parse issue.
mazzzystar Sep 20, 2024
64a1a22
fix title parse issue.
mazzzystar Sep 20, 2024
64e12ae
fix title parse issue.
mazzzystar Sep 20, 2024
c45db0d
fix title parse issue.
mazzzystar Sep 20, 2024
b46d362
fix router after publish
mazzzystar Sep 20, 2024
9a68fbe
fix router after publish
mazzzystar Sep 20, 2024
a423edf
fix router after publish
mazzzystar Sep 20, 2024
cd63af5
feat(deletion): implement deletion function
metrue Sep 20, 2024
475ed12
fix title parse issue.
mazzzystar Sep 20, 2024
b7d912e
fix title parse issue.
mazzzystar Sep 20, 2024
6371c0d
fix title parse issue.
mazzzystar Sep 20, 2024
ad820c2
fix title parse issue.
mazzzystar Sep 20, 2024
f428014
fix title parse issue.
mazzzystar Sep 20, 2024
6859c8e
fix router after publish
mazzzystar Sep 20, 2024
cc7158b
fix router after publish
mazzzystar Sep 20, 2024
5c50ef4
fix router after publish
mazzzystar Sep 20, 2024
4a7435b
local minor change
mazzzystar Sep 21, 2024
13c8619
Merge branch 'metrue-metrue/delete-thought'
mazzzystar Sep 21, 2024
16cf82a
Merge #7 deletion for thoughts.
mazzzystar Sep 21, 2024
d35fdc0
fix delete thoughts.
mazzzystar Sep 21, 2024
01ec9c6
allow edit thought
mazzzystar Sep 21, 2024
b28359b
don't change timestamp when edit thoughts
mazzzystar Sep 21, 2024
bf91e9d
try to add edit blog feature
mazzzystar Sep 21, 2024
3255c9c
add delete/edit success toast.
mazzzystar Sep 21, 2024
b28eb1b
add delete/edit success toast.
mazzzystar Sep 21, 2024
101920e
add delete/edit success toast.
mazzzystar Sep 21, 2024
0ca0e96
add delete/edit success toast.
mazzzystar Sep 21, 2024
3031d21
add delete/edit success toast.
mazzzystar Sep 21, 2024
f5b4f80
add delete/edit success toast.
mazzzystar Sep 21, 2024
11c441f
add delete/edit success toast.
mazzzystar Sep 21, 2024
ffd81da
add delete/edit success toast.
mazzzystar Sep 21, 2024
e819156
add delete/edit success toast.
mazzzystar Sep 21, 2024
dea82fa
add delete/edit success toast.
mazzzystar Sep 21, 2024
49710f0
add delete/edit success toast.
mazzzystar Sep 21, 2024
e9f9368
add delete/edit success toast.
mazzzystar Sep 21, 2024
e036dfa
add delete/edit success toast.
mazzzystar Sep 21, 2024
0683f1d
add locale for toast.
mazzzystar Sep 21, 2024
b072ac8
add locale for toast.
mazzzystar Sep 21, 2024
a1d63e7
add locale for toast.
mazzzystar Sep 21, 2024
adea401
add locale for toast.
mazzzystar Sep 21, 2024
fe80b13
add license
mazzzystar Sep 21, 2024
d3fc6b3
add license
mazzzystar Sep 21, 2024
8401bf8
add license
mazzzystar Sep 21, 2024
c99fff9
add license
mazzzystar Sep 21, 2024
5c695a3
add locale for edit/delete button.
mazzzystar Sep 21, 2024
ae89057
add original content in editor when edit.
mazzzystar Sep 21, 2024
e6f5636
add original content in editor when edit.
mazzzystar Sep 21, 2024
cb376ac
don't change date when update blog.
mazzzystar Sep 21, 2024
e390ba3
feat(drag&drop): drag and drop
metrue Sep 22, 2024
f891094
support for zh-TW and zh-HK.
mazzzystar Sep 22, 2024
3307b8e
add PWA.
mazzzystar Sep 22, 2024
56c9729
update PWA.
mazzzystar Sep 22, 2024
768050d
fix PWA keyboard issue in Safari.
mazzzystar Sep 22, 2024
7742c01
fix PWA keyboard issue in Safari.
mazzzystar Sep 22, 2024
66057f3
fix display issue when no blog post.
mazzzystar Sep 22, 2024
d4f62f4
feat(drag&drop): drag and drop
metrue Sep 22, 2024
db4826c
add local for upload success toast.
mazzzystar Sep 22, 2024
2459985
Update README.md
mazzzystar Sep 22, 2024
77344d4
fix typo for locale.
mazzzystar Sep 22, 2024
0ac8305
optimize image display.
mazzzystar Sep 23, 2024
d8daf02
fix image display.
mazzzystar Sep 23, 2024
0e2222e
add statement for why not private.
mazzzystar Sep 23, 2024
ecae7c2
optimize icon.
mazzzystar Sep 23, 2024
2b321fe
add public homepage
mazzzystar Sep 23, 2024
b774adc
add public homepage
mazzzystar Sep 23, 2024
d4dc8cc
add homepage link
mazzzystar Sep 23, 2024
5070ad5
locale for public homepage.
mazzzystar Sep 23, 2024
c982d35
locale for public homepage.
mazzzystar Sep 23, 2024
072fb89
now you can view other's blog
mazzzystar Sep 23, 2024
598acb1
sort public blog by date
mazzzystar Sep 23, 2024
5b2ffa4
theme the same for public post & thoughts.
mazzzystar Sep 23, 2024
cbb6a02
Update README.md
mazzzystar Sep 23, 2024
08f0c42
theme the same for public post & thoughts.
mazzzystar Sep 23, 2024
f2143e8
make public blog & thoughts the same style with private.
mazzzystar Sep 23, 2024
3276255
make blog content font size larger.
mazzzystar Sep 23, 2024
bded0a5
add manifest for user homepage.
mazzzystar Sep 23, 2024
8f97264
add manifest for user homepage.
mazzzystar Sep 23, 2024
d272959
add loading animation when loading other's blog.
mazzzystar Sep 23, 2024
377c6f5
fix image display path.
mazzzystar Sep 24, 2024
dfe9a32
fix image display path.
mazzzystar Sep 24, 2024
ddfb144
fix image display path.
mazzzystar Sep 24, 2024
2b4ed39
support both master & main branch
mazzzystar Sep 24, 2024
4355660
support for MacOS using Pake.
mazzzystar Sep 24, 2024
229e2ab
Update README.md
mazzzystar Sep 24, 2024
46d3b52
set default repo about to user's homepage.
mazzzystar Sep 24, 2024
8b83abf
set default repo about to user's homepage.
mazzzystar Sep 24, 2024
40132b6
set default repo about to user's homepage.
mazzzystar Sep 24, 2024
b63763c
set default repo about to user's homepage.
mazzzystar Sep 24, 2024
c2ae31b
set default repo about to user's homepage.
mazzzystar Sep 24, 2024
db1b444
update .gitignore
mazzzystar Sep 24, 2024
33cb191
use My Public Homepage.
mazzzystar Sep 24, 2024
6fdc462
speedup thoughts/blog fetch.
mazzzystar Sep 24, 2024
19f5cd4
supports for LaTex.
mazzzystar Sep 25, 2024
721ab09
add unavailable page.
mazzzystar Sep 25, 2024
26e14ae
Update README.md
mazzzystar Sep 25, 2024
ff7ff04
ensure repo exist when create thoughts.
mazzzystar Sep 25, 2024
1309018
update Tinymind.dmg
mazzzystar Sep 25, 2024
17c024c
add banner
mazzzystar Sep 25, 2024
047e244
add banner
mazzzystar Sep 25, 2024
65dc9a5
add banner
mazzzystar Sep 25, 2024
4fb5628
Update README.md
mazzzystar Sep 25, 2024
c03c3e2
update unavailable page.
mazzzystar Sep 25, 2024
1418f29
Merge branch 'main' of github.com:mazzzystar/tinymind
mazzzystar Sep 25, 2024
2b8c017
Update README.md
mazzzystar Sep 25, 2024
490993f
Update README.md
mazzzystar Sep 25, 2024
9cba8d7
Update README.md
mazzzystar Sep 25, 2024
eeea6ae
Update README.md
mazzzystar Sep 25, 2024
02ae61a
Update README.md
mazzzystar Sep 25, 2024
237a1c8
increase clarity for #howitworks
mazzzystar Sep 25, 2024
be1a185
Merge branch 'main' of github.com:mazzzystar/tinymind
mazzzystar Sep 25, 2024
1259700
Update README.md
mazzzystar Sep 25, 2024
5c10f6e
Update README.md
mazzzystar Sep 26, 2024
a14dc84
add demo page.
mazzzystar Sep 26, 2024
bf20c4b
add demo page.
mazzzystar Sep 26, 2024
2e6c450
add demo page.
mazzzystar Sep 26, 2024
16f3759
Update README.md
mazzzystar Sep 27, 2024
fae654e
add dynamic metadata for each public post.
mazzzystar Sep 28, 2024
c5803d8
add dynamic metadata for each public post.
mazzzystar Sep 28, 2024
1bc1f40
add dynamic metadata for each public post.
mazzzystar Sep 28, 2024
6559f48
feat(avatar): have personal avatar by trying assets/icon.jpg
metrue Sep 28, 2024
c11350d
Merge branch 'metrue-configurable-avatar'
mazzzystar Sep 29, 2024
2395e0d
add user's github icon as default icon.
mazzzystar Sep 30, 2024
bf1a1a7
add user's github icon as default icon.
mazzzystar Sep 30, 2024
be53877
fix broken homepage avatar.
mazzzystar Sep 30, 2024
bcd0e77
fix broken homepage avatar.
mazzzystar Sep 30, 2024
988b50d
fix broken homepage avatar.
mazzzystar Sep 30, 2024
430bd27
Update README.md
mazzzystar Sep 30, 2024
82d8ef4
fix broken homepage avatar.
mazzzystar Sep 30, 2024
106640d
refact date format.
mazzzystar Sep 30, 2024
d6291b7
refact date format.
mazzzystar Sep 30, 2024
39d6814
refact date format.
mazzzystar Sep 30, 2024
0c81d4d
refact date format.
mazzzystar Sep 30, 2024
035ff5f
refact date format.
mazzzystar Sep 30, 2024
1395704
refact date format.
mazzzystar Sep 30, 2024
b722175
refact date format.
mazzzystar Sep 30, 2024
44f166f
use client for public blog post list for speed up.
mazzzystar Sep 30, 2024
9f2c61e
shorten title in metadata.
mazzzystar Sep 30, 2024
f4410e7
accept all images url domain.
mazzzystar Sep 30, 2024
90bee98
fix issue with "C++" in title.
mazzzystar Oct 4, 2024
84de115
fix parse blog page url issue.
mazzzystar Oct 4, 2024
1a0897d
fix parse blog page url issue.
mazzzystar Oct 4, 2024
291bbc5
fix parse blog page url issue.
mazzzystar Oct 4, 2024
85320ff
fix parse blog page url issue.
mazzzystar Oct 4, 2024
d1a8745
fix parse blog page url issue.
mazzzystar Oct 4, 2024
56cc72d
use user's avatar as homepage icon.
mazzzystar Oct 10, 2024
27497f4
try domain
metrue Oct 5, 2024
0a3ee64
fix only refresh will the new post show issue.
mazzzystar Oct 28, 2024
38e3d33
disable cache to fix not showing newest content issue.
mazzzystar Oct 28, 2024
b032800
remove revalidate for blog.
mazzzystar Oct 28, 2024
fed11e9
Merge branch 'mazzzystar:main' into main
metrue Oct 29, 2024
2f217cb
update quote content UI style.
mazzzystar Nov 12, 2024
2820b1d
update public thoughts list UI for quote.
mazzzystar Nov 12, 2024
d0d7558
Merge branch 'mazzzystar:main' into main
metrue Nov 12, 2024
d932172
adjust quote text color.
mazzzystar Nov 13, 2024
47ada11
allow user paste image from clipboard.
mazzzystar Nov 20, 2024
638e7e7
optimize link style.
mazzzystar Nov 21, 2024
951b463
update link UI style.
mazzzystar Nov 21, 2024
bf0066f
don't change link style in blog list.
mazzzystar Nov 21, 2024
ccfa36f
use 'break-words' to prevent long url get out of card box.
mazzzystar Nov 21, 2024
f918b44
Merge branch 'mazzzystar:main' into main
metrue Nov 25, 2024
bb9c057
feat(styles): light style (#3)
metrue Nov 27, 2024
e03093d
fix(date): fix the date format (#5)
metrue Nov 27, 2024
66ae7cc
fix(selection): fix the selection not visible issue
metrue Nov 27, 2024
4b0cb2c
Fix thought card not shown all (#6)
metrue Nov 27, 2024
7b0dc6d
feat(sort): the latest thougth should be the one with latest timestam
metrue Nov 27, 2024
58da4bb
fix(grid): fix the grid different gap issue
metrue Nov 28, 2024
6aa978a
patch(grid): fix the grid issue of padding
metrue Nov 29, 2024
c167224
fix(style): unify the component style for though card
metrue Nov 29, 2024
f0401d7
card index (#7)
metrue Dec 1, 2024
6e50356
fix(imageUrl): fix the image url missing for the public blog issue
metrue Dec 1, 2024
4149871
fix(color): fix the button color
metrue Dec 3, 2024
8885e74
fix(url): github host image url should have 'raw' parameter
metrue Dec 4, 2024
2db5c63
fix(bg): fix the background color of thought card
metrue Dec 4, 2024
10ca693
feat(font): better font
metrue Dec 4, 2024
d482a8d
caching (#8)
metrue Dec 20, 2024
4acfe10
enable comments (#9)
metrue Dec 20, 2024
3d48f37
remove the padding
metrue Dec 21, 2024
ad9183c
move the timestamp to header of card
metrue Dec 21, 2024
26c5952
fix style of image
metrue Dec 23, 2024
50a1202
feat(username): only one user, no more multi tenant (#10)
metrue Dec 24, 2024
a75757b
fix(sha): fix no sha for update content (#11)
metrue Dec 24, 2024
7d0465b
feat(note): rename thought to note (#13)
metrue Dec 25, 2024
c084507
Page render (#12)
metrue Dec 25, 2024
3524d8e
feat(authenticated): only authenticated to show the dropdown (#15)
metrue Dec 25, 2024
1afa8b3
chore(repo): const repo
metrue Dec 25, 2024
be1c5d9
chore(ga): update my own ga
metrue Dec 25, 2024
92261d3
fix(args): remove the extra arg
metrue Dec 25, 2024
c126c81
fix(ssr): move more to ssr
metrue Dec 25, 2024
8af197d
clean up no use codes
metrue Dec 25, 2024
90307a3
fix(alignment): fix the header alignment issue
metrue Dec 25, 2024
d4f2324
feat(single_repo): content and app in same repo (#18)
metrue Dec 26, 2024
61c6bbf
update
metrue Dec 26, 2024
bc5c9fd
update
metrue Dec 26, 2024
bb3ece7
fix(md): the name should include 'md'
metrue Dec 26, 2024
280ae8b
Update blog post
metrue Dec 26, 2024
87370c6
Update blog post
metrue Dec 26, 2024
c93651d
update readme
metrue Dec 26, 2024
f2885b1
update icon
metrue Dec 26, 2024
291ac0e
Update thought
metrue Dec 26, 2024
26b74e8
Update thought
metrue Dec 26, 2024
1ecdaf9
Add new thought
metrue Dec 28, 2024
8a7f2aa
chore(data): naming the data directory (#20)
metrue Dec 28, 2024
075b620
feat(naming): thought to memo (#21)
metrue Dec 28, 2024
add23f8
chore(structure): better structure
metrue Dec 28, 2024
ebe98b6
chore(stucture): better structure
metrue Dec 28, 2024
db967a2
clean up
metrue Dec 28, 2024
3423937
fix(naming): update name
metrue Dec 28, 2024
b093e66
Add new memo
metrue Dec 28, 2024
040c3fa
fix(naming): update naming
metrue Dec 28, 2024
d74ebdd
Add new memo
metrue Dec 28, 2024
4443ab5
Update memo
metrue Dec 28, 2024
5a76b18
Update memo
metrue Dec 28, 2024
7010954
wip: trying
metrue Dec 28, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
.pnp.js
.yarn/install-state.gz


src-tauri/
# testing
/coverage

Expand Down
5 changes: 5 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.next/
public/
styles/
*.md
out/
10 changes: 10 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"printWidth": 100,
"trailingComma": "es5",
"tabWidth": 2,
"semi": false,
"singleQuote": true,
"jsxSingleQuote": true,
"maxLineLength": 80,
"endOfLine": "lf"
}
25 changes: 25 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
MIT License

Permission is hereby granted, free of charge, to any
person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the
Software without restriction, including without
limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software
is furnished to do so, subject to the following
conditions:

The above copyright notice and this permission notice
shall be included in all copies or substantial portions
of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
36 changes: 9 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,32 +1,14 @@
# TinyMind
## Cofe

TinyMind is a website that lets you write and sync your blog posts, short thoughts, and memos by signing in with GitHub. Here's how it works:
Cofe is designed to be a simple and easy-to-use blog and memo taking app, originally forked from [tinymind](https://github.com/mazzzystar/tinymind).

1. We create a public repo called "tinymind-blog" in your GitHub account.
2. When you write anything on our webpage, it automatically commits to your `yourname/tinymind-blog` repo.
3. This ensures a seamless way to create content and maintain data persistence.
![screnshot](https://github.com/metrue/cofe/blob/main/data/assets/images/Cofe-app.png?raw=true)

## Data Privacy & Permissions
### HOW TO RUN

We only have write access to your public repositories. Your privacy matters:
Register a new OAuth App on Github, and get the `GITHUB_ID` and `GITHUB_SECRET`,
then run the following command to start the blog:

- Content stored only in your GitHub repo
- No data kept on our servers
- You have full control through your GitHub account

## TODO

- [ ] Create a page to showcase all public writers using TinyMind (creator list)
- [ ] Implement shareable user main pages (like https://tinywind.me/mazzzystar)

## Tech Stack

Built with Next.js, React, TypeScript, NextAuth.js, and Tailwind CSS.

## Contribute

Contributions are welcome! Feel free to submit a Pull Request.

## License

[Your chosen license here]
```bash
GITHUB_USERNAME='metrue' GITHUB_ID='GITHUB_ID' GITHUB_SECRET='GITHUB_SECRET' NEXTAUTH_SECRET='NEXTAUTH_SECRET' npm run de
```
101 changes: 101 additions & 0 deletions api/github/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
import { NextRequest, NextResponse } from 'next/server';
import { createBlogPost, createMemo, deleteBlogPost, deleteMemo, updateBlogPost, updateMemo } from '@/lib/githubApi';

import { authOptions } from "@/lib/auth";
import { createGitHubAPIClient } from '@/lib/client';
import { getServerSession } from "next-auth/next";

export const dynamic = 'force-dynamic'; // Disable caching for this route
export const revalidate = 60; // Revalidate every 60 seconds

// Add cache control headers
const headers = {
'Cache-Control': 'public, s-maxage=60, stale-while-revalidate=30',
'Content-Type': 'application/json',
};

export async function POST(request: NextRequest) {
try {
console.log('POST request received');
const session = await getServerSession(authOptions);

if (!session || !session.accessToken) {
console.log('No valid session found');
return NextResponse.json({ error: 'Unauthorized' }, { status: 401, headers });
}

const { action, ...data } = await request.json();
console.log('Action:', action);
console.log('Data:', JSON.stringify(data, null, 2));

switch (action) {
case 'createBlogPost':
await createBlogPost(data.title, data.content, session.accessToken);
return NextResponse.json({ message: 'Blog post created successfully' }, { headers });
case 'updateBlogPost':
await updateBlogPost(data.id, data.title, data.content, session.accessToken);
return NextResponse.json({ message: 'Blog post updated successfully' }, { headers });
case 'deleteBlogPost':
await deleteBlogPost(data.id, session.accessToken);
return NextResponse.json({ message: 'Blog post deleted successfully' }, { headers });
case 'createMemo':
await createMemo(data.content, data.image, session.accessToken);
return NextResponse.json({ message: 'Memo created successfully' }, { headers });
case 'updateMemo':
await updateMemo(data.id, data.content, session.accessToken);
return NextResponse.json({ message: 'Memo updated successfully' }, { headers });
case 'deleteMemo':
await deleteMemo(data.id, session.accessToken);
return NextResponse.json({ message: 'Memo deleted successfully' }, { headers });
default:
return NextResponse.json({ error: 'Invalid action' }, { status: 400, headers });
}
} catch (error) {
console.error('Error in /api/github POST:', error);
if (error instanceof Error) {
console.error('Error stack:', error.stack);
return NextResponse.json({ error: error.message, stack: error.stack }, { status: 500, headers });
}
return NextResponse.json({ error: 'An unexpected error occurred' }, { status: 500, headers });
}
}

export async function GET(request: NextRequest) {
try {
const session = await getServerSession(authOptions);

if (!session || !session.accessToken) {
console.log('No valid session found');
return NextResponse.json({ error: 'Unauthorized' }, { status: 401, headers });
}

const { searchParams } = new URL(request.url);
const action = searchParams.get('action');
const id = searchParams.get('id');

const client = createGitHubAPIClient(session.accessToken)

switch (action) {
case 'getBlogPosts':
const posts = await client.getBlogPosts();
return NextResponse.json(posts, { headers });
case 'getBlogPost':
if (!id) {
return NextResponse.json({ error: 'Missing id parameter' }, { status: 400, headers });
}
const post = await client.getBlogPost(`${id}.md`);
return NextResponse.json(post, { headers });
case 'getMemos':
const memos = await client.getMemos()
return NextResponse.json(memos, { headers });
default:
return NextResponse.json({ error: 'Invalid action' }, { status: 400, headers });
}
} catch (error) {
console.error('Error in /api/github GET:', error);
if (error instanceof Error) {
return NextResponse.json({ error: error.message }, { status: 500, headers });
}
return NextResponse.json({ error: 'An unexpected error occurred' }, { status: 500, headers });
}
}
69 changes: 0 additions & 69 deletions app/api/github/route.ts

This file was deleted.

Loading