Skip to content

Instantly share code, notes, and snippets.

View zawie's full-sized avatar
🧊
Chillin'

Adam Zawierucha zawie

🧊
Chillin'
View GitHub Profile
@zawie
zawie / auth-middleware.ts
Created November 5, 2022 18:32
Middleware that uses the authentication handler
import { NextFunction, Request, Response, RequestHandler } from 'express';
import HttpException from '../model/HttpException'
import { isAuthorized } from '../utils/auth-utils'
import { aliasExists } from '../accessor/database.mongo'
export function authorizationMiddleware(): RequestHandler {
return async (
request: Request,
response: Response,
next: NextFunction) => {
@zawie
zawie / auth-utils.ts
Created November 5, 2022 18:29
An example of using the Google API to authenticate.
import { GoogleUserInfo } from '../model/definitions'
import HttpException from '../model/HttpException'
import { Request } from 'express';
import { getEmail } from '../accessor/database.mongo'
const fetch = require('node-fetch')
require('dotenv').config()
const { AUTH_CLIENT_ID, AUTH_CLIENT_SECRET, JWT_SECRET, AUTH_REDIRECT_URI } = process.env;
const SCOPES = ['https://www.googleapis.com/auth/userinfo.email', 'https://www.googleapis.com/auth/userinfo.profile']
/* ===== Backend GET ===== */
// ...
router.get('/endPoint', (request, response) => {
// Send some info
return response.send({
message: "RiceApps rocks!"
})
})
app.use('/endpoint', someRouter);
// ...
@zawie
zawie / tasks.md
Last active February 10, 2021 13:27 — forked from akanshgulati/tasks.md
Visual Studio Code task to compile and run C programs

Introduction

The below code is the configuration for the Microsoft Visual Code tasks which will enable you to compile and run C program

Steps

  1. Press Cmd + Shift + P
  2. Type Configure task ( A task.json file will be created for that project )
  3. Copy below configuration code and save it.

Usage

Simple press Cmd + Shift + B to compile and run.

Note: Make sure you select the tab having C program as below tasks run on active tab in VS Code.

@zawie
zawie / FizzBuzz.gist
Created September 5, 2020 20:39
Just seeing how GiHub Gist's work
int FizzBuzz() {
int x,y,n;
std::cin >> x >> y >> n;
for (int i=1; i <= n; i++) {
if (i % x == 0){
std::cout << "Fizz";
}
if (i % y == 0) {
std::cout << "Buzz";
}