Skip to content

Instantly share code, notes, and snippets.

View Rykuno's full-sized avatar

Donny Blaine Rykuno

View GitHub Profile
export const requireAuth: MiddlewareHandler<{
Variables: {
session: Session;
user: User;
};
}> = createMiddleware(async (c, next) => {
const user = c.var.user;
if (!user) throw new HTTPException(StatusCodes.UNAUTHORIZED, { message: 'Unauthorized' });
return next();
});
import { superValidate } from 'sveltekit-superforms/server';
import type { PageServerLoad } from './$types';
import { fail } from '@sveltejs/kit';
import {
insertSurveyQuestionSchema,
selectSurveyAnswerSchema,
surveyAnswers,
surveyQuestions
} from '$lib/server/database/schema';
import { db } from '$lib/server/database';
create table "public"."profiles" (
"id" uuid not null,
"updated_at" timestamp with time zone,
"username" text,
"full_name" text,
"avatar_url" text,
"website" text
);
@Rykuno
Rykuno / cookies.ts
Created January 9, 2022 16:55
NextJS: Cookie setting and unsetting
import { serialize, CookieSerializeOptions } from "cookie";
import { NextApiResponse } from "next";
/**
* This sets `cookie` using the `res` object
*/
interface Cookie {
name: string;
value: unknown;

import Card from './Components/Card';

Using absolute imports instead of relative can make refactoring a project much easier.



App.js

import React, { Component } from "react";
import Editor from "draft-js-plugins-editor";
import { makeStyles } from "@material-ui/core/styles";
import createInlineToolbarPlugin from "draft-js-inline-toolbar-plugin";
import {
ItalicButton,
BoldButton,
UnderlineButton,
CodeButton