Skip to content

Commit

Permalink
First deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
itsmingjie committed Nov 19, 2021
1 parent cc38ca2 commit c35556f
Show file tree
Hide file tree
Showing 16 changed files with 3,986 additions and 88 deletions.
224 changes: 202 additions & 22 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,34 +1,214 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
# File created using '.gitignore Generator' for Visual Studio Code: https://bit.ly/vscode-gig

# dependencies
/node_modules
/.pnp
.pnp.js
# Created by https://www.toptal.com/developers/gitignore/api/dotenv,linux,macos,nextjs,node,windows
# Edit at https://www.toptal.com/developers/gitignore?templates=dotenv,linux,macos,nextjs,node,windows

# testing
/coverage
### dotenv ###
.env

# next.js
/.next/
/out/
### Linux ###
*~

# production
/build
# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*

# misc
# KDE directory preferences
.directory

# Linux trash folder which might appear on any partition or disk
.Trash-*

# .nfs files are created when an open file is removed but is still being accessed
.nfs*

### macOS ###
# General
.DS_Store
*.pem
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon


# Thumbnails
._*

# debug
# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

### NextJS ###
# Next build dir
.next/

### Node ###
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# Snowpack dependency directory (https://snowpack.dev/)
web_modules/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env.test
.env.production

# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache

# Next.js build output
.next
out

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port

# Stores VSCode versions used for testing VSCode extensions
.vscode-test

# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*

### Node Patch ###
# Serverless Webpack directories
.webpack/

# Optional stylelint cache
.stylelintcache

# SvelteKit build / generate output
.svelte-kit

### Windows ###
# Windows thumbnail cache files
Thumbs.db
Thumbs.db:encryptable
ehthumbs.db
ehthumbs_vista.db

# Dump file
*.stackdump

# Folder config file
[Dd]esktop.ini

# Recycle Bin used on file shares
$RECYCLE.BIN/

# Windows Installer files
*.cab
*.msi
*.msix
*.msm
*.msp

# Windows shortcuts
*.lnk

# local env files
.env.local
.env.development.local
.env.test.local
.env.production.local
# End of https://www.toptal.com/developers/gitignore/api/dotenv,linux,macos,nextjs,node,windows

# vercel
.vercel
# Custom rules (everything added below won't be overriden by 'Generate .gitignore File' if you use 'Update' option)
11 changes: 11 additions & 0 deletions .vercel/README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
> Why do I have a folder named ".vercel" in my project?
The ".vercel" folder is created when you link a directory to a Vercel project.

> What does the "project.json" file contain?
The "project.json" file contains:
- The ID of the Vercel project that you linked ("projectId")
- The ID of the user or team your Vercel project is owned by ("orgId")

> Should I commit the ".vercel" folder?
No, you should not share the ".vercel" folder with anyone.
Upon creation, it will be automatically added to your ".gitignore" file.
1 change: 1 addition & 0 deletions .vercel/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"projectId":"prj_S33RX7WQ7hndn0eXxuGUnPeJt6DG","orgId":"team_2XxmcBivAmGu3eiTiJ47XJKr"}
5 changes: 5 additions & 0 deletions helpers/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import cookie from "cookie";

export function parseCookies(req) {
return cookie.parse(req ? req.headers.cookie || "" : document.cookie);
}
7 changes: 7 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,15 @@
"lint": "next lint"
},
"dependencies": {
"@emotion/react": "^11.6.0",
"@emotion/styled": "^11.6.0",
"@mui/material": "^5.1.1",
"axios": "^0.24.0",
"cookie": "^0.4.1",
"deta": "^1.0.1",
"next": "12.0.4",
"react": "17.0.2",
"react-cookie": "^4.1.1",
"react-dom": "17.0.2"
},
"devDependencies": {
Expand Down
12 changes: 9 additions & 3 deletions pages/_app.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
import '../styles/globals.css'
import { CookiesProvider } from "react-cookie";

import "../styles/globals.css";

function MyApp({ Component, pageProps }) {
return <Component {...pageProps} />
return (
<CookiesProvider>
<Component {...pageProps} />
</CookiesProvider>
);
}

export default MyApp
export default MyApp;
4 changes: 4 additions & 0 deletions pages/api/_deta.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
const { Deta } = require("deta");
const deta = Deta(process.env.DETA_KEY);

module.exports = deta;
12 changes: 12 additions & 0 deletions pages/api/auth.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Next.js API route support: https://nextjs.org/docs/api-routes/introduction

const axios = require("axios");

export default function handler(req, res) {
// redirect to the authorization url
const redirect = process.env.APP_URL + "/api/callback";
const scope = encodeURIComponent("identify guilds email");

const url = `https://discord.com/api/oauth2/authorize?client_id=${process.env.DISCORD_CLIENT_ID}&redirect_uri=${redirect}&response_type=code&scope=${scope}`;
return res.redirect(url);
}
9 changes: 9 additions & 0 deletions pages/api/batches.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

const deta = require("./_deta");
const batches_db = deta.Base("batches");

export default async function handler(req, res) {
const batches = await batches_db.fetch({'active': true})

res.json(batches.count > 0 ? batches.items : {})
}
Loading

0 comments on commit c35556f

Please sign in to comment.