Skip to content

Instantly share code, notes, and snippets.

View ziedHamdi's full-sized avatar
💭
Exploring opportunities

Zied Hamdi ziedHamdi

💭
Exploring opportunities
View GitHub Profile
@ziedHamdi
ziedHamdi / [...nextauth].js
Created October 4, 2021 11:40
pages/api/auth/[...nextauth].js
import NextAuth from 'next-auth'
import Providers from 'next-auth/providers'
import jwt from 'jsonwebtoken'
import {TOKEN_SECRET} from "../../../lib/auth";
import logger from "../../../lib/logger";
export default NextAuth({
// Configure one or more authentication providers
providers: [
Providers.Facebook({
@ziedHamdi
ziedHamdi / graphqlSetupVisitor.js
Last active October 4, 2021 12:10
/server/middleware/graphqlSetupVisitor.js adds graphql to express
const graphQlServer = graphqlHTTP(async (req, res, graphQLParams) => {
const infraToken = req.header('infraToken');
let user = null;
if (infraToken) {
try {
var _jwt$verify;
_logger.default.debug("infra token found ");
@ziedHamdi
ziedHamdi / app.conf
Created November 16, 2021 12:17
Nginx simplest configuration
server {
listen 80;
location / {
proxy_pass http://next_server:3000;
}
location /api/rest/ {
proxy_pass http://graphql_server:4000;
}
}
@ziedHamdi
ziedHamdi / nginx.dockerfile
Created November 16, 2021 12:23
Nginx image that includes certbot installed in
FROM nginx:1.21-alpine
COPY ./data/nginx/. /etc/nginx/conf.d/.
RUN apk add python3 python3-dev py3-pip build-base libressl-dev musl-dev libffi-dev rust cargo
RUN pip3 install pip --upgrade
RUN pip3 install certbot-nginx
RUN mkdir /etc/letsencrypt
version: "3.9"
services:
nginx:
container_name: nginx
image: 'nginx:0.1'
ports:
- "80:80"
- "443:443"
volumes:
version: "3.9"
services:
nginx:
container_name: nginx
image: 'nginx:0.1'
ports:
- "80:80"
- "443:443"
volumes:
#!/bin/bash
# GRAPHQL_SERVER_VERSION=$1
# NEXT_SERVER_VERSION=$2
# set variables from .env to system: https://gist.github.com/mihow/9c7f559807069a03e302605691f85572
if [ -f .env ]
then
export $(cat .env | sed 's/#.*//g' | xargs)
fi
#!/bin/bash
# GRAPHQL_SERVER_VERSION=$1
# NEXT_SERVER_VERSION=$2
# set variables from .env to system: https://gist.github.com/mihow/9c7f559807069a03e302605691f85572
if [ -f .env ]
then
export $(cat .env | sed 's/#.*//g' | xargs)
fi
/**
* inspired from https://www.yld.io/blog/global-notifications-with-reacts-context-api/
*/
import React, { useState, useCallback } from 'react';
export const ToastContext = React.createContext({
toasts: null,
addToast: () => {},
removeToast: () => {},
});
import {useContext} from 'react';
import {ToastContext} from '../ToastContextProvider';
function useToast(timeout) {
const {toasts, addToast: originalAddToast, removeToast} = useContext(ToastContext);
function addToast(toast) {
originalAddToast(toast)
let appliedTimeout = toast.timeout ?? timeout
if (appliedTimeout > 0)