Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
project_ss23_gameunity
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Yusuf Akgül
project_ss23_gameunity
Commits
01eacd87
Commit
01eacd87
authored
1 year ago
by
DESKTOP-9FO96TP\hehexd
Browse files
Options
Downloads
Patches
Plain Diff
fixed refresh for build
parent
68454f82
No related branches found
No related tags found
1 merge request
!17
Fix tweeting
Pipeline
#35602
passed
1 year ago
Stage: build
Stage: test
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
app/(content)/(home)/home/page.tsx
+1
-0
1 addition, 0 deletions
app/(content)/(home)/home/page.tsx
app/api/messages/route.ts
+11
-7
11 additions, 7 deletions
app/api/messages/route.ts
components/post-messages.tsx
+3
-2
3 additions, 2 deletions
components/post-messages.tsx
with
15 additions
and
9 deletions
app/(content)/(home)/home/page.tsx
+
1
−
0
View file @
01eacd87
...
...
@@ -2,6 +2,7 @@ import LikeButton from "@/components/like-button";
import
PostMessageForm
from
"
@/components/post-messages
"
;
import
{
prisma
}
from
"
@/lib/db
"
;
import
{
Prisma
}
from
"
@prisma/client
"
;
/* export const revalidate = 5; */
// revalidate this page every 60 seconds
type
messageType
=
Prisma
.
PostUncheckedCreateInput
type
messageItemProps
=
{
...
...
This diff is collapsed.
Click to expand it.
app/api/messages/route.ts
+
11
−
7
View file @
01eacd87
...
...
@@ -3,10 +3,11 @@ import { NextRequest, NextResponse } from "next/server"
import
{
getServerSession
}
from
"
next-auth/next
"
import
{
authOptions
}
from
"
../auth/[...nextauth]/route
"
;
import
{
Prisma
}
from
"
@prisma/client
"
;
import
{
revalidatePath
,
revalidateTag
}
from
"
next/cache
"
;
type
post
=
Prisma
.
PostUncheckedCreateInput
export
async
function
POST
(
req
:
NextRequest
)
{
const
session
=
await
getServerSession
(
authOptions
);
if
(
!
session
)
{
...
...
@@ -14,11 +15,9 @@ export async function POST(req: NextRequest) {
}
const
userId
=
session
.
user
.
id
const
data
=
await
req
.
json
()
console
.
log
(
"
router data:
"
+
data
,
"
status:
"
)
console
.
log
(
"
router data:
"
+
data
.
content
,
"
status:
"
)
try
{
await
prisma
.
post
.
create
({
...
...
@@ -30,6 +29,8 @@ export async function POST(req: NextRequest) {
}
})
console
.
log
(
"
created
"
)
const
path
=
req
.
nextUrl
.
searchParams
.
get
(
'
path
'
)
||
'
/
'
;
revalidatePath
(
path
);
return
NextResponse
.
json
({
status
:
201
,
message
:
'
Message Created
'
})
...
...
@@ -40,10 +41,13 @@ export async function POST(req: NextRequest) {
}
export
async
function
GET
(
req
:
NextRequest
,
res
:
NextResponse
)
{
const
data
=
await
req
.
json
()
console
.
log
(
"
router data:
"
+
data
,
"
status:
"
)
try
{
const
data
=
await
req
.
json
()
console
.
log
(
"
router data:
"
+
data
,
"
status:
"
)
}
catch
(
error
)
{
}
console
.
log
(
data
)
try
{
const
messages
=
await
prisma
.
post
.
findMany
({
orderBy
:
{
...
...
This diff is collapsed.
Click to expand it.
components/post-messages.tsx
+
3
−
2
View file @
01eacd87
...
...
@@ -14,11 +14,12 @@ export default function PostMessageForm(props: { data: Post[] | null }) {
async
function
postMessage
(
e
:
any
)
{
e
.
preventDefault
()
console
.
log
(
formData
)
/* formData.userId = 1 */
const
response
=
await
fetch
(
'
http://localhost:3000/api/messages
'
,
{
method
:
'
POST
'
,
body
:
JSON
.
stringify
(
formData
)
body
:
JSON
.
stringify
(
formData
),
next
:
{
tags
:
[
'
collection
'
]
}
})
startTransition
(()
=>
{
// Refresh the current route and fetch new data from the server without
// losing client-side browser or React state.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment