This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { NextResponse } from 'next/server'; | |
import { verifyToken } from '../middleware/utils'; | |
export async function middleware(req) { | |
const { cookies } = req; | |
const { origin } = req.nextUrl; | |
const jwt = cookies.token; // get jwt token | |
const protectedPaths = ['/share']; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import bcrypt from 'bcryptjs'; | |
import jwt from 'jsonwebtoken'; | |
import { PrismaClient } from '@prisma/client'; | |
import HTTPMethod from 'http-method-enum'; | |
import HTTP_STATUS_CODES from 'http-status-enum'; | |
import { serialize } from 'cookie'; | |
const prisma = new PrismaClient(); | |
const KEY = process.env.JWT_KEY; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { serialize } from 'cookie'; | |
export default function logout(req, res) { | |
const { cookies } = req; | |
const jwt = cookies.token; | |
if (!jwt) { | |
return res.status(401).json({ | |
status: 'error', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
interface FlyingCreature | |
{ | |
public function fly(); | |
} | |
interface FeatheredCreature | |
{ | |
public function molt(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
abstract class Debugger | |
{ | |
abstract public function debug($message); | |
} | |
class BrowserDebugger extends Debugger | |
{ | |
public function debug($message) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Singleton | |
{ | |
private static $instance = null; | |
/** | |
* prevent from creating multiple instances | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
abstract class Vecihle | |
{ | |
public $engine; | |
public $wheel; | |
public $doors; | |
} | |
class Car extends Vecihle |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Car | |
{ | |
public function hello() | |
{ | |
echo "Hello!"; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
interface CarInterface | |
{ | |
public function getBrand(): string; | |
public function getPrice(): int; | |
} | |
interface MotorcycleInterface | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Customer | |
{ | |
public function hello() | |
{ | |
echo "Hello from customer!"; | |
} | |
} |
OlderNewer