-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6bdc630
commit 0b29f85
Showing
23 changed files
with
221 additions
and
76 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,3 +61,6 @@ build-linux-deb/ | |
svgs/ | ||
compile_commands.json | ||
resources/fontvers/ | ||
|
||
notas.h | ||
resources/gatos/ |
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
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
Binary file not shown.
Binary file not shown.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export interface MacroData { | ||
timestamp: string; | ||
userID: number; | ||
name: string; | ||
levelID: string; | ||
data: string; | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
export interface ThemeData { | ||
timestamp: string; | ||
userID: number; | ||
name: string; | ||
desc: string; | ||
screenshots?: Array<string>; | ||
data: string; | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export default interface UserData { | ||
userID: number; | ||
userName: string; | ||
token: string; // based on a hashed ip addr | ||
timestamp: string; | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import redis from 'redis' | ||
import crypto from 'crypto'; | ||
import User from '../components/User'; | ||
|
||
const client = redis.createClient(); // switch to cache | ||
|
||
export function hashIP(ip: string): string { | ||
const hash = crypto.createHash('sha256'); | ||
hash.update(ip); | ||
return hash.digest('hex'); | ||
} | ||
|
||
export async function getUser(hashIP: string): Promise<User | null> { | ||
try { | ||
const userData = (await client.hGetAll(`users:${hashIP}`) as unknown) as User; | ||
if (userData) return userData; | ||
return null; | ||
} catch (e) { | ||
console.error(e); | ||
return null; | ||
} | ||
} | ||
|
||
export async function createUser(name: string, hashIP: string): Promise<User | null> { | ||
return new Promise((resolve, reject) => { | ||
return getUser(hashIP).then(user => { | ||
if (user != null) return reject("Already created an account."); | ||
resolve(); | ||
}).catch(reject); | ||
}) | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { Router, Request, Response } from 'express' | ||
import crypto from 'crypto' | ||
import multer from 'multer' | ||
|
||
const router = Router(); | ||
|
||
router.post('/api/themes', (req: Request, res: Response) => { | ||
const { token, data } = req.body; | ||
|
||
}) | ||
|
||
export default router; |
Empty file.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// taken from my discord bot | ||
|
||
// https://stackoverflow.com/a/74535407 | ||
import type { RedisClientType } from 'redis' | ||
import { createClient } from 'redis' | ||
|
||
let redisClient: RedisClientType | ||
let isReady: boolean | ||
async function getCache(): Promise<RedisClientType> { | ||
if (!isReady) { | ||
redisClient = createClient({ | ||
url: 'redis://127.0.0.1:6379', | ||
}) | ||
redisClient.on('error', err => console.error(`[Redis] Error: ${err}`)) | ||
redisClient.on('connect', () => console.log('[Redis] Connected!')) | ||
redisClient.on('reconnecting', () => console.log('[Redis] Reconnecting...')) | ||
redisClient.on('ready', () => { | ||
isReady = true | ||
console.log('[Redis] Ready!') | ||
}) | ||
await redisClient.connect(); | ||
} | ||
return redisClient | ||
} | ||
getCache().then(connection => { | ||
redisClient = connection | ||
}).catch(err => { | ||
console.error('Failed to connect to Redis', err) | ||
}) | ||
export { getCache } |
This file was deleted.
Oops, something went wrong.
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
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
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
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
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
Oops, something went wrong.