This file contains 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
export default function flat () { | |
var depth = isNaN(arguments[0]) ? 1 : Number(arguments[0]); | |
return depth ? Array.prototype.reduce.call(this, function (acc, cur) { | |
if (Array.isArray(cur)) { | |
acc.push.apply(acc, flat.call(cur, depth - 1)); | |
} else { | |
acc.push(cur); | |
} |
This file contains 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
export default (sequelize, DataTypes) => { | |
const Groups = sequelize.define('Groups', { | |
name: { | |
allowNull: false, | |
type: DataTypes.STRING, | |
validate: { | |
notEmpty: true | |
} | |
}, | |
desc: { |
This file contains 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
export default (sequelize, DataTypes) => { | |
const GroupUsers = sequelize.define('GroupUsers', { | |
userId: { | |
type: DataTypes.INTEGER, | |
allowNull: false, | |
references: { | |
model: 'Users', | |
key: 'id' | |
} | |
}, |
This file contains 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 '../utils/db' | |
import Posts from './postsModel' | |
import { respondWith } from '../utils' | |
export const handler = async (event, context) => { | |
context.callbackWaitsForEmptyEventLoop = false | |
if (event.httpMethod !== 'GET') return respondWith({ statusCode: 200 }) |
This file contains 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 mongoose from 'mongoose' | |
import '../utils/db' | |
import Posts from './postsModel' | |
import { verifyToken, respondWith } from '../utils' | |
export const handler = async (event, context) => { |
This file contains 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 mongoose from 'mongoose' | |
// Set Posts Schema | |
const schema = new mongoose.Schema({ | |
_id: mongoose.Schema.Types.ObjectId, | |
username: { | |
type: String, | |
required: [true, 'Username field is required'], | |
}, | |
profile_image: { |
This file contains 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 jwt from 'jsonwebtoken' | |
import jwksClient from 'jwks-rsa' | |
export const respondWith = ({ statusCode, response = {} }) => { | |
return { | |
statusCode, | |
headers: { | |
"Content-Type": "application/json", | |
"Access-Control-Allow-Origin": "*", | |
"Access-Control-Allow-Headers": "*", |
This file contains 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 mongoose from 'mongoose' | |
const dotenv = require('dotenv') | |
dotenv.config() | |
const env = { ...process.env } | |
const isProduction = env.NODE_ENV === 'production' | |
// Initialize connection to database |
This file contains 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 React from 'react' | |
import Layout from '../components/layout' | |
import SEO from '../components/seo' | |
const NotFoundPage = () => ( | |
<Layout> | |
<SEO title="404: Not found" /> | |
<h1>NOT FOUND</h1> | |
<p>You just hit a route that doesn't exist... the sadness.</p> |
This file contains 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 React from 'react' | |
import styled from '@emotion/styled' | |
import axios from 'axios' | |
import { navigate } from 'gatsby' | |
import { getUserNickname, getUserProfileImage, logout, isLoggedIn } from '../../services/auth' | |
import RecentPosts from '../../components/recentPosts' | |
import Button from '../../components/button' | |
import Layout from '../../components/layout' |
NewerOlder