Fix Homepage Slow Button Loading #27
@@ -1,3 +1,8 @@
|
||||
{
|
||||
"extends": "next/core-web-vitals"
|
||||
"extends": "next/core-web-vitals",
|
||||
"rules": {
|
||||
"no-unused-vars": ["error", { "vars": "all", "args": "after-used", "ignoreRestSiblings": false }],
|
||||
"jsx-a11y/alt-text": "off",
|
||||
"@next/next/no-img-element": "off"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
## API Reference for ChatMaps
|
||||
|
||||
Base URL: https://chatma.ps/api
|
||||
|Endpoint|Methods|Documentation for Endpoint
|
||||
|--------|-------|--------------------------|
|
||||
|/login|POST, GET|[README.md](./onboard/README.md)
|
||||
|/register|POST|[README.md](./register/README.md)
|
||||
|/signout|GET|[README.md](./signout/README.md)
|
||||
|/user|GET|[README.md](./user/README.md)
|
||||
|/onboard|POST|[README.md](./onboard/README.md)
|
||||
@@ -1,4 +1,4 @@
|
||||
import { initializeApp, getApps, cert } from "firebase-admin/app";
|
||||
import { initializeApp, getApps } from "firebase-admin/app";
|
||||
import admin from "firebase-admin";
|
||||
|
||||
export function customInitApp() {
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
## API Reference for ChatMaps (/login)
|
||||
<hr/>
|
||||
|
||||
### POST
|
||||
Inputs:
|
||||
|
||||
|
||||
Output:
|
||||
|
||||
|
||||
### GET
|
||||
Inputs:
|
||||
|Name|Type|DataType|
|
||||
|----|----|--------|
|
||||
session|cookie|String|
|
||||
|
||||
Output:
|
||||
|Condition|HTTP Status Code|Body|Body DataType|
|
||||
|---------|----------------|----|-------------|
|
||||
|No session token in the cookies|401|{isLogged: false}|JSON
|
||||
|Successfully validated session token|200|*|JSON
|
||||
|Validation of session token failed|401|{isLogged: false}|JSON
|
||||
@@ -67,7 +67,7 @@ async function handleEmailAndPassword(email, password) {
|
||||
}
|
||||
|
||||
// Handles POST requests (login requests)
|
||||
export async function POST(req, res) {
|
||||
export async function POST(req) {
|
||||
try {
|
||||
var { email, password } = await req?.json()
|
||||
return await handleEmailAndPassword(email, password); // need session token
|
||||
@@ -77,7 +77,7 @@ export async function POST(req, res) {
|
||||
}
|
||||
|
||||
// Handles GET requests (is session still valid requests)
|
||||
export async function GET(req) {
|
||||
export async function GET() {
|
||||
var session = cookies().get("session")?.value || "";
|
||||
//Validate if the cookie exist in the request
|
||||
if (!session) {
|
||||
|
||||
@@ -29,7 +29,7 @@ async function onboard(firstName, lastName, req) {
|
||||
|
||||
|
||||
// Handles POST requests (login requests)
|
||||
export async function POST(req, res) {
|
||||
export async function POST(req) {
|
||||
try {
|
||||
var { firstName, lastName } = await req?.json()
|
||||
return await onboard(firstName, lastName, req);
|
||||
|
||||
@@ -15,7 +15,7 @@ export async function registerUser(email, password) {
|
||||
}
|
||||
|
||||
// POST request handler
|
||||
export async function POST(req, res) {
|
||||
export async function POST(req) {
|
||||
try {
|
||||
// Extract email and password from the request body
|
||||
var { email, password } = await req?.json();
|
||||
|
||||
@@ -2,7 +2,7 @@ import { cookies } from "next/headers";
|
||||
import { NextResponse } from "next/server";
|
||||
|
||||
|
||||
export async function GET(req) {
|
||||
export async function GET() {
|
||||
cookies().delete('user')
|
||||
cookies().delete('session')
|
||||
cookies().delete('uid')
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { NextResponse } from "next/server";
|
||||
import { cookies } from "next/headers";
|
||||
|
||||
export async function GET(req) {
|
||||
export async function GET() {
|
||||
var userData = cookies().get("user")?.value || false
|
||||
return userData != false? NextResponse.json(JSON.parse(userData)): NextResponse.json({},{status: 203})
|
||||
}
|
||||
@@ -37,7 +37,6 @@ function Geo() {
|
||||
if('geolocation' in navigator) {
|
||||
// Retrieve latitude & longitude coordinates from `navigator.geolocation` Web API
|
||||
navigator.geolocation.getCurrentPosition(({ coords }) => {
|
||||
const { latitude, longitude } = coords;
|
||||
setData(coords)
|
||||
setLoading(false)
|
||||
})
|
||||
|
||||
@@ -4,7 +4,7 @@ import { useForm, Form } from "react-hook-form";
|
||||
import "../globals.css"
|
||||
|
||||
function Register() {
|
||||
var { register, control, setError, formState: { errors, isSubmitting, isSubmitted } } = useForm()
|
||||
var { register, control, formState: { errors, isSubmitting, isSubmitted } } = useForm()
|
||||
var router = useRouter();
|
||||
var emailRegex = /(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])/
|
||||
return (
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
// src/middleware.js
|
||||
import { NextResponse } from "next/server";
|
||||
import { cookies } from "next/headers";
|
||||
|
||||
export async function middleware(req, res) {
|
||||
export async function middleware(req) {
|
||||
const session = await req.cookies.get("session");
|
||||
if (req.nextUrl.pathname !== "/login" && req.nextUrl.pathname != "/register") {
|
||||
// Login if not logged in
|
||||
|
||||
Reference in New Issue
Block a user