refactor /data directory
This commit is contained in:
parent
40be1ad522
commit
4e45058d46
|
@ -11,7 +11,7 @@ import http from 'http';
|
||||||
import url from 'url';
|
import url from 'url';
|
||||||
import ppfunCaptcha from 'ppfun-captcha';
|
import ppfunCaptcha from 'ppfun-captcha';
|
||||||
|
|
||||||
import { connect as connectRedis } from './data/redis';
|
import { connect as connectRedis } from './data/redis/client';
|
||||||
import { getIPFromRequest } from './utils/ip';
|
import { getIPFromRequest } from './utils/ip';
|
||||||
import { setCaptchaSolution } from './utils/captcha';
|
import { setCaptchaSolution } from './utils/captcha';
|
||||||
import { getRandomString } from './core/utils';
|
import { getRandomString } from './core/utils';
|
||||||
|
|
|
@ -8,8 +8,8 @@ import {
|
||||||
getData,
|
getData,
|
||||||
setStatus,
|
setStatus,
|
||||||
getStatus,
|
getStatus,
|
||||||
} from '../data/models/CanvasCleaner';
|
} from '../data/redis/CanvasCleaner';
|
||||||
import RedisCanvas from '../data/models/RedisCanvas';
|
import RedisCanvas from '../data/redis/RedisCanvas';
|
||||||
import {
|
import {
|
||||||
getChunkOfPixel,
|
getChunkOfPixel,
|
||||||
getCornerOfChunk,
|
getCornerOfChunk,
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
import Sequelize from 'sequelize';
|
import Sequelize from 'sequelize';
|
||||||
import logger from './logger';
|
import logger from './logger';
|
||||||
|
|
||||||
import { Message, Channel } from '../data/models';
|
import { Message, Channel } from '../data/sql';
|
||||||
|
|
||||||
const MAX_BUFFER_TIME = 120000;
|
const MAX_BUFFER_TIME = 120000;
|
||||||
|
|
||||||
|
|
|
@ -3,12 +3,12 @@
|
||||||
*/
|
*/
|
||||||
import { Op } from 'sequelize';
|
import { Op } from 'sequelize';
|
||||||
import logger from './logger';
|
import logger from './logger';
|
||||||
import redis from '../data/redis';
|
import redis from '../data/redis/client';
|
||||||
import User from '../data/User';
|
import User from '../data/User';
|
||||||
import RateLimiter from '../utils/RateLimiter';
|
import RateLimiter from '../utils/RateLimiter';
|
||||||
import {
|
import {
|
||||||
Channel, RegUser, UserChannel, Message,
|
Channel, RegUser, UserChannel, Message,
|
||||||
} from '../data/models';
|
} from '../data/sql';
|
||||||
import ChatMessageBuffer from './ChatMessageBuffer';
|
import ChatMessageBuffer from './ChatMessageBuffer';
|
||||||
import socketEvents from '../socket/SocketEvents';
|
import socketEvents from '../socket/SocketEvents';
|
||||||
import { cheapDetector } from './isProxy';
|
import { cheapDetector } from './isProxy';
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
// Tile creation is allowed to be slow
|
// Tile creation is allowed to be slow
|
||||||
/* eslint-disable no-await-in-loop */
|
/* eslint-disable no-await-in-loop */
|
||||||
|
|
||||||
import RedisCanvas from '../data/models/RedisCanvas';
|
import RedisCanvas from '../data/redis/RedisCanvas';
|
||||||
import logger from './logger';
|
import logger from './logger';
|
||||||
import { getChunkOfPixel } from './utils';
|
import { getChunkOfPixel } from './utils';
|
||||||
import { TILE_SIZE } from './constants';
|
import { TILE_SIZE } from './constants';
|
||||||
|
|
|
@ -14,7 +14,7 @@ import {
|
||||||
getEventArea,
|
getEventArea,
|
||||||
clearOldEvent,
|
clearOldEvent,
|
||||||
CANVAS_ID,
|
CANVAS_ID,
|
||||||
} from '../data/models/Event';
|
} from '../data/redis/Event';
|
||||||
import { setCoolDownFactor } from './draw';
|
import { setCoolDownFactor } from './draw';
|
||||||
import Void from './Void';
|
import Void from './Void';
|
||||||
import { protectCanvasArea } from './Image';
|
import { protectCanvasArea } from './Image';
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
import sharp from 'sharp';
|
import sharp from 'sharp';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
|
|
||||||
import RedisCanvas from '../data/models/RedisCanvas';
|
import RedisCanvas from '../data/redis/RedisCanvas';
|
||||||
import Palette from './Palette';
|
import Palette from './Palette';
|
||||||
import { getMaxTiledZoom } from './utils';
|
import { getMaxTiledZoom } from './utils';
|
||||||
import { TILE_SIZE, TILE_ZOOM_LEVEL } from './constants';
|
import { TILE_SIZE, TILE_ZOOM_LEVEL } from './constants';
|
||||||
|
|
|
@ -9,7 +9,7 @@ import socketEvents from '../socket/SocketEvents';
|
||||||
import PixelUpdate from '../socket/packets/PixelUpdateServer';
|
import PixelUpdate from '../socket/packets/PixelUpdateServer';
|
||||||
import { setPixelByOffset } from './setPixel';
|
import { setPixelByOffset } from './setPixel';
|
||||||
import { TILE_SIZE } from './constants';
|
import { TILE_SIZE } from './constants';
|
||||||
import { CANVAS_ID } from '../data/models/Event';
|
import { CANVAS_ID } from '../data/redis/Event';
|
||||||
// eslint-disable-next-line import/no-unresolved
|
// eslint-disable-next-line import/no-unresolved
|
||||||
import canvases from './canvases.json';
|
import canvases from './canvases.json';
|
||||||
|
|
||||||
|
|
|
@ -7,12 +7,12 @@
|
||||||
|
|
||||||
import sharp from 'sharp';
|
import sharp from 'sharp';
|
||||||
import Sequelize from 'sequelize';
|
import Sequelize from 'sequelize';
|
||||||
import redis from '../data/redis';
|
import redis from '../data/redis/client';
|
||||||
|
|
||||||
import { getIPv6Subnet } from '../utils/ip';
|
import { getIPv6Subnet } from '../utils/ip';
|
||||||
import { validateCoorRange } from '../utils/validation';
|
import { validateCoorRange } from '../utils/validation';
|
||||||
import CanvasCleaner from './CanvasCleaner';
|
import CanvasCleaner from './CanvasCleaner';
|
||||||
import { Blacklist, Whitelist, RegUser } from '../data/models';
|
import { Blacklist, Whitelist, RegUser } from '../data/sql';
|
||||||
// eslint-disable-next-line import/no-unresolved
|
// eslint-disable-next-line import/no-unresolved
|
||||||
import canvases from './canvases.json';
|
import canvases from './canvases.json';
|
||||||
import {
|
import {
|
||||||
|
|
|
@ -6,7 +6,7 @@ import {
|
||||||
getPixelFromChunkOffset,
|
getPixelFromChunkOffset,
|
||||||
} from './utils';
|
} from './utils';
|
||||||
import logger, { pixelLogger } from './logger';
|
import logger, { pixelLogger } from './logger';
|
||||||
import RedisCanvas from '../data/models/RedisCanvas';
|
import RedisCanvas from '../data/redis/RedisCanvas';
|
||||||
import {
|
import {
|
||||||
setPixelByOffset,
|
setPixelByOffset,
|
||||||
setPixelByCoords,
|
setPixelByCoords,
|
||||||
|
|
|
@ -4,9 +4,9 @@
|
||||||
|
|
||||||
import fetch from '../utils/proxiedFetch';
|
import fetch from '../utils/proxiedFetch';
|
||||||
|
|
||||||
import redis from '../data/redis';
|
import redis from '../data/redis/client';
|
||||||
import { getIPv6Subnet } from '../utils/ip';
|
import { getIPv6Subnet } from '../utils/ip';
|
||||||
import { Blacklist, Whitelist } from '../data/models';
|
import { Blacklist, Whitelist } from '../data/sql';
|
||||||
import { proxyLogger as logger } from './logger';
|
import { proxyLogger as logger } from './logger';
|
||||||
|
|
||||||
import { USE_PROXYCHECK } from './config';
|
import { USE_PROXYCHECK } from './config';
|
||||||
|
|
|
@ -12,7 +12,7 @@ import { DailyCron, HourlyCron } from '../utils/cron';
|
||||||
import { getTTag } from './ttag';
|
import { getTTag } from './ttag';
|
||||||
import { GMAIL_USER, GMAIL_PW } from './config';
|
import { GMAIL_USER, GMAIL_PW } from './config';
|
||||||
|
|
||||||
import RegUser from '../data/models/RegUser';
|
import { RegUser } from '../data/sql';
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -15,7 +15,7 @@ import { OAuth2Strategy as GoogleStrategy } from 'passport-google-oauth';
|
||||||
import logger from './logger';
|
import logger from './logger';
|
||||||
import { sanitizeName } from '../utils/validation';
|
import { sanitizeName } from '../utils/validation';
|
||||||
|
|
||||||
import { RegUser } from '../data/models';
|
import { RegUser } from '../data/sql';
|
||||||
import User, { regUserQueryInclude as include } from '../data/User';
|
import User, { regUserQueryInclude as include } from '../data/User';
|
||||||
import { auth } from './config';
|
import { auth } from './config';
|
||||||
import { compareToHash } from '../utils/hash';
|
import { compareToHash } from '../utils/hash';
|
||||||
|
|
|
@ -4,9 +4,9 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import Sequelize from 'sequelize';
|
import Sequelize from 'sequelize';
|
||||||
import Model from '../data/sequelize';
|
import sequelize from '../data/sql/sequelize';
|
||||||
import RegUser from '../data/models/RegUser';
|
import RegUser from '../data/sql/RegUser';
|
||||||
import { saveDailyTop, loadDailyTop } from '../data/models/prevDayTop';
|
import { saveDailyTop, loadDailyTop } from '../data/redis/PrevDayTop';
|
||||||
import logger from './logger';
|
import logger from './logger';
|
||||||
|
|
||||||
import { MINUTE } from './constants';
|
import { MINUTE } from './constants';
|
||||||
|
@ -34,11 +34,11 @@ class Ranks {
|
||||||
async updateRanking() {
|
async updateRanking() {
|
||||||
logger.info('Update pixel rankings');
|
logger.info('Update pixel rankings');
|
||||||
// recalculate ranking column
|
// recalculate ranking column
|
||||||
await Model.query(
|
await sequelize.query(
|
||||||
// eslint-disable-next-line max-len
|
// eslint-disable-next-line max-len
|
||||||
'SET @r=0; UPDATE Users SET ranking= @r:= (@r + 1) ORDER BY totalPixels DESC;',
|
'SET @r=0; UPDATE Users SET ranking= @r:= (@r + 1) ORDER BY totalPixels DESC;',
|
||||||
);
|
);
|
||||||
await Model.query(
|
await sequelize.query(
|
||||||
// eslint-disable-next-line max-len
|
// eslint-disable-next-line max-len
|
||||||
'SET @r=0; UPDATE Users SET dailyRanking= @r:= (@r + 1) ORDER BY dailyTotalPixels DESC;',
|
'SET @r=0; UPDATE Users SET dailyRanking= @r:= (@r + 1) ORDER BY dailyTotalPixels DESC;',
|
||||||
);
|
);
|
||||||
|
|
|
@ -11,7 +11,7 @@ import fs from 'fs';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import sharp from 'sharp';
|
import sharp from 'sharp';
|
||||||
|
|
||||||
import RedisCanvas from '../data/models/RedisCanvas';
|
import RedisCanvas from '../data/redis/RedisCanvas';
|
||||||
import logger from './logger';
|
import logger from './logger';
|
||||||
import { getChunkOfPixel } from './utils';
|
import { getChunkOfPixel } from './utils';
|
||||||
import Palette from './Palette';
|
import Palette from './Palette';
|
||||||
|
|
|
@ -4,12 +4,12 @@
|
||||||
import expressSession from 'express-session';
|
import expressSession from 'express-session';
|
||||||
import RedisStore from '../utils/connectRedis';
|
import RedisStore from '../utils/connectRedis';
|
||||||
|
|
||||||
import redis from '../data/redis';
|
import client from '../data/redis/client';
|
||||||
import { HOUR, COOKIE_SESSION_NAME } from './constants';
|
import { HOUR, COOKIE_SESSION_NAME } from './constants';
|
||||||
import { SESSION_SECRET } from './config';
|
import { SESSION_SECRET } from './config';
|
||||||
|
|
||||||
|
|
||||||
export const store = new RedisStore({ client: redis });
|
export const store = new RedisStore({ client });
|
||||||
|
|
||||||
const session = expressSession({
|
const session = expressSession({
|
||||||
name: COOKIE_SESSION_NAME,
|
name: COOKIE_SESSION_NAME,
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
* Set pixels on canvas.
|
* Set pixels on canvas.
|
||||||
* Pixels get collected in a cache for 5ms and sent to players at once.
|
* Pixels get collected in a cache for 5ms and sent to players at once.
|
||||||
* */
|
* */
|
||||||
import RedisCanvas from '../data/models/RedisCanvas';
|
import RedisCanvas from '../data/redis/RedisCanvas';
|
||||||
import {
|
import {
|
||||||
getChunkOfPixel,
|
getChunkOfPixel,
|
||||||
getOffsetOfPixel,
|
getOffsetOfPixel,
|
||||||
|
|
|
@ -9,7 +9,7 @@ import { Worker } from 'worker_threads';
|
||||||
import logger from './logger';
|
import logger from './logger';
|
||||||
// eslint-disable-next-line import/no-unresolved
|
// eslint-disable-next-line import/no-unresolved
|
||||||
import canvases from './canvases.json';
|
import canvases from './canvases.json';
|
||||||
import RedisCanvas from '../data/models/RedisCanvas';
|
import RedisCanvas from '../data/redis/RedisCanvas';
|
||||||
|
|
||||||
import { TILE_FOLDER } from './config';
|
import { TILE_FOLDER } from './config';
|
||||||
import {
|
import {
|
||||||
|
|
|
@ -8,11 +8,11 @@
|
||||||
* */
|
* */
|
||||||
|
|
||||||
import Sequelize from 'sequelize';
|
import Sequelize from 'sequelize';
|
||||||
import redis from './redis';
|
import redis from './redis/client';
|
||||||
import logger from '../core/logger';
|
import logger from '../core/logger';
|
||||||
|
|
||||||
import Model from './sequelize';
|
import sequelize from './sql/sequelize';
|
||||||
import { RegUser, Channel, UserBlock } from './models';
|
import { RegUser, Channel, UserBlock } from './sql';
|
||||||
import { getIPv6Subnet } from '../utils/ip';
|
import { getIPv6Subnet } from '../utils/ip';
|
||||||
import { ADMIN_IDS } from '../core/config';
|
import { ADMIN_IDS } from '../core/config';
|
||||||
|
|
||||||
|
@ -95,13 +95,15 @@ class User {
|
||||||
|
|
||||||
static async name2Id(name: string) {
|
static async name2Id(name: string) {
|
||||||
try {
|
try {
|
||||||
const userq = await Model.query('SELECT id FROM Users WHERE name = $1',
|
const userq = await sequelize.query(
|
||||||
|
'SELECT id FROM Users WHERE name = $1',
|
||||||
{
|
{
|
||||||
bind: [name],
|
bind: [name],
|
||||||
type: Sequelize.QueryTypes.SELECT,
|
type: Sequelize.QueryTypes.SELECT,
|
||||||
raw: true,
|
raw: true,
|
||||||
plain: true,
|
plain: true,
|
||||||
});
|
},
|
||||||
|
);
|
||||||
return userq.id;
|
return userq.id;
|
||||||
} catch {
|
} catch {
|
||||||
return null;
|
return null;
|
||||||
|
@ -202,9 +204,9 @@ class User {
|
||||||
}
|
}
|
||||||
|
|
||||||
async getWait(canvasId: number): Promise<?number> {
|
async getWait(canvasId: number): Promise<?number> {
|
||||||
let ttl: number = await redis.pTTL(`cd:${canvasId}:ip:${this.ipSub}`);
|
let ttl = await redis.pTTL(`cd:${canvasId}:ip:${this.ipSub}`);
|
||||||
if (this.id != null) {
|
if (this.id != null) {
|
||||||
const ttlid: number = await redis.pTTL(
|
const ttlid = await redis.pTTL(
|
||||||
`cd:${canvasId}:id:${this.id}`,
|
`cd:${canvasId}:id:${this.id}`,
|
||||||
);
|
);
|
||||||
ttl = Math.max(ttl, ttlid);
|
ttl = Math.max(ttl, ttlid);
|
||||||
|
@ -238,7 +240,7 @@ class User {
|
||||||
return this.regUser.totalPixels;
|
return this.regUser.totalPixels;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
const userq = await Model.query(
|
const userq = await sequelize.query(
|
||||||
'SELECT totalPixels FROM Users WHERE id = $1',
|
'SELECT totalPixels FROM Users WHERE id = $1',
|
||||||
{
|
{
|
||||||
bind: [id],
|
bind: [id],
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
* storing Event data
|
* storing Event data
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import redis from '../redis';
|
import client from './client';
|
||||||
import logger from '../../core/logger';
|
import logger from '../../core/logger';
|
||||||
|
|
||||||
const DATA_KEY = 'clr:dat';
|
const DATA_KEY = 'clr:dat';
|
||||||
|
@ -14,7 +14,7 @@ const STAT_KEY = 'clr:sta';
|
||||||
* (check core/CanvasCleaner for the meaning)
|
* (check core/CanvasCleaner for the meaning)
|
||||||
*/
|
*/
|
||||||
export async function getData() {
|
export async function getData() {
|
||||||
const data = await redis.get(DATA_KEY);
|
const data = await client.get(DATA_KEY);
|
||||||
if (data) {
|
if (data) {
|
||||||
const parsedData = data.toString().split(':');
|
const parsedData = data.toString().split(':');
|
||||||
for (let i = 0; i < parsedData.length - 1; i += 1) {
|
for (let i = 0; i < parsedData.length - 1; i += 1) {
|
||||||
|
@ -56,7 +56,7 @@ export async function setData(canvasId, x, y, u, v, methodName) {
|
||||||
);
|
);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return redis.set(DATA_KEY, dataStr);
|
return client.set(DATA_KEY, dataStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -66,7 +66,7 @@ export async function setData(canvasId, x, y, u, v, methodName) {
|
||||||
* running: boolean if filter is running
|
* running: boolean if filter is running
|
||||||
*/
|
*/
|
||||||
export async function getStatus() {
|
export async function getStatus() {
|
||||||
const stat = await redis.get(STAT_KEY);
|
const stat = await client.get(STAT_KEY);
|
||||||
if (stat) {
|
if (stat) {
|
||||||
const parsedStat = stat.toString().split(':');
|
const parsedStat = stat.toString().split(':');
|
||||||
if (parsedStat.length !== 2) {
|
if (parsedStat.length !== 2) {
|
||||||
|
@ -103,5 +103,5 @@ export async function setStatus(cIter, running) {
|
||||||
);
|
);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return redis.set(STAT_KEY, statString);
|
return client.set(STAT_KEY, statString);
|
||||||
}
|
}
|
|
@ -8,7 +8,7 @@ import { commandOptions } from 'redis';
|
||||||
// its ok if its slow
|
// its ok if its slow
|
||||||
/* eslint-disable no-await-in-loop */
|
/* eslint-disable no-await-in-loop */
|
||||||
|
|
||||||
import redis from '../redis';
|
import client from './client';
|
||||||
import logger from '../../core/logger';
|
import logger from '../../core/logger';
|
||||||
import RedisCanvas from './RedisCanvas';
|
import RedisCanvas from './RedisCanvas';
|
||||||
|
|
||||||
|
@ -27,10 +27,10 @@ export const CANVAS_ID = '0';
|
||||||
* 2 = lost
|
* 2 = lost
|
||||||
*/
|
*/
|
||||||
export function setSuccess(success) {
|
export function setSuccess(success) {
|
||||||
return redis.set(EVENT_SUCCESS_KEY, success);
|
return client.set(EVENT_SUCCESS_KEY, success);
|
||||||
}
|
}
|
||||||
export async function getSuccess() {
|
export async function getSuccess() {
|
||||||
const success = await redis.get(EVENT_SUCCESS_KEY);
|
const success = await client.get(EVENT_SUCCESS_KEY);
|
||||||
return (success) ? parseInt(success, 10) : 0;
|
return (success) ? parseInt(success, 10) : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ export async function getSuccess() {
|
||||||
* @return time till next event in seconds
|
* @return time till next event in seconds
|
||||||
*/
|
*/
|
||||||
export async function nextEvent() {
|
export async function nextEvent() {
|
||||||
const timestamp = await redis.get(EVENT_TIMESTAMP_KEY);
|
const timestamp = await client.get(EVENT_TIMESTAMP_KEY);
|
||||||
if (timestamp) {
|
if (timestamp) {
|
||||||
return Number(timestamp.toString());
|
return Number(timestamp.toString());
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,7 @@ export async function nextEvent() {
|
||||||
* @return cell of chunk coordinates of event
|
* @return cell of chunk coordinates of event
|
||||||
*/
|
*/
|
||||||
export async function getEventArea() {
|
export async function getEventArea() {
|
||||||
const pos = await redis.get(EVENT_POSITION_KEY);
|
const pos = await client.get(EVENT_POSITION_KEY);
|
||||||
if (pos) {
|
if (pos) {
|
||||||
return pos.toString().split(':').map((z) => Number(z));
|
return pos.toString().split(':').map((z) => Number(z));
|
||||||
}
|
}
|
||||||
|
@ -69,7 +69,7 @@ export async function clearOldEvent() {
|
||||||
for (let ic = i - 1; ic <= i + 1; ic += 1) {
|
for (let ic = i - 1; ic <= i + 1; ic += 1) {
|
||||||
try {
|
try {
|
||||||
const chunkKey = `${EVENT_BACKUP_PREFIX}:${ic}:${jc}`;
|
const chunkKey = `${EVENT_BACKUP_PREFIX}:${ic}:${jc}`;
|
||||||
const chunk = await redis.get(
|
const chunk = await client.get(
|
||||||
commandOptions({ returnBuffers: true }),
|
commandOptions({ returnBuffers: true }),
|
||||||
chunkKey,
|
chunkKey,
|
||||||
);
|
);
|
||||||
|
@ -92,7 +92,7 @@ export async function clearOldEvent() {
|
||||||
);
|
);
|
||||||
await RedisCanvas.setChunk(ic, jc, chunk, CANVAS_ID);
|
await RedisCanvas.setChunk(ic, jc, chunk, CANVAS_ID);
|
||||||
}
|
}
|
||||||
await redis.del(chunkKey);
|
await client.del(chunkKey);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.error(
|
logger.error(
|
||||||
// eslint-disable-next-line max-len
|
// eslint-disable-next-line max-len
|
||||||
|
@ -101,7 +101,7 @@ export async function clearOldEvent() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
await redis.del(EVENT_POSITION_KEY);
|
await client.del(EVENT_POSITION_KEY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,10 +128,10 @@ export async function setNextEvent(minutes, i, j) {
|
||||||
chunk = Buffer.allocUnsafe(1);
|
chunk = Buffer.allocUnsafe(1);
|
||||||
}
|
}
|
||||||
const chunkKey = `${EVENT_BACKUP_PREFIX}:${ic}:${jc}`;
|
const chunkKey = `${EVENT_BACKUP_PREFIX}:${ic}:${jc}`;
|
||||||
await redis.set(chunkKey, chunk);
|
await client.set(chunkKey, chunk);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
await redis.set(EVENT_POSITION_KEY, `${i}:${j}`);
|
await client.set(EVENT_POSITION_KEY, `${i}:${j}`);
|
||||||
const timestamp = Date.now() + minutes * 60 * 1000;
|
const timestamp = Date.now() + minutes * 60 * 1000;
|
||||||
await redis.set(EVENT_TIMESTAMP_KEY, timestamp);
|
await client.set(EVENT_TIMESTAMP_KEY, timestamp);
|
||||||
}
|
}
|
|
@ -2,7 +2,7 @@
|
||||||
* saving and loading the top 10 of the previous day
|
* saving and loading the top 10 of the previous day
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import redis from '../redis';
|
import client from './client';
|
||||||
import logger from '../../core/logger';
|
import logger from '../../core/logger';
|
||||||
|
|
||||||
const PREV_DAILY_TOP_KEY = 'prevtop';
|
const PREV_DAILY_TOP_KEY = 'prevtop';
|
||||||
|
@ -15,7 +15,7 @@ export async function saveDailyTop(dailyRanking) {
|
||||||
const top10 = dailyRanking.slice(0, 10).map((user) => user.id);
|
const top10 = dailyRanking.slice(0, 10).map((user) => user.id);
|
||||||
const jsonTop = JSON.stringify(top10);
|
const jsonTop = JSON.stringify(top10);
|
||||||
logger.info(`Saving current daily top 10 into redis: ${jsonTop}`);
|
logger.info(`Saving current daily top 10 into redis: ${jsonTop}`);
|
||||||
await redis.set(PREV_DAILY_TOP_KEY, jsonTop);
|
await client.set(PREV_DAILY_TOP_KEY, jsonTop);
|
||||||
return top10;
|
return top10;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ export async function saveDailyTop(dailyRanking) {
|
||||||
* @return Promis<Array> Array of user IDs of the top 10
|
* @return Promis<Array> Array of user IDs of the top 10
|
||||||
*/
|
*/
|
||||||
export async function loadDailyTop() {
|
export async function loadDailyTop() {
|
||||||
const jsonTop = await redis.get(PREV_DAILY_TOP_KEY);
|
const jsonTop = await client.get(PREV_DAILY_TOP_KEY);
|
||||||
logger.info(`Loaded current daily top 10 into redis: ${jsonTop}`);
|
logger.info(`Loaded current daily top 10 into redis: ${jsonTop}`);
|
||||||
return (jsonTop) ? JSON.parse(jsonTop) : [];
|
return (jsonTop) ? JSON.parse(jsonTop) : [];
|
||||||
}
|
}
|
|
@ -4,7 +4,7 @@
|
||||||
import { commandOptions } from 'redis';
|
import { commandOptions } from 'redis';
|
||||||
|
|
||||||
import { getChunkOfPixel, getOffsetOfPixel } from '../../core/utils';
|
import { getChunkOfPixel, getOffsetOfPixel } from '../../core/utils';
|
||||||
import redis from '../redis';
|
import client from './client';
|
||||||
|
|
||||||
|
|
||||||
const UINT_SIZE = 'u8';
|
const UINT_SIZE = 'u8';
|
||||||
|
@ -38,7 +38,7 @@ class RedisCanvas {
|
||||||
// this key is also hardcoded into
|
// this key is also hardcoded into
|
||||||
// core/tilesBackup.js
|
// core/tilesBackup.js
|
||||||
const key = `ch:${canvasId}:${i}:${j}`;
|
const key = `ch:${canvasId}:${i}:${j}`;
|
||||||
let chunk = await redis.get(
|
let chunk = await client.get(
|
||||||
commandOptions({ returnBuffers: true }),
|
commandOptions({ returnBuffers: true }),
|
||||||
key,
|
key,
|
||||||
);
|
);
|
||||||
|
@ -51,14 +51,14 @@ class RedisCanvas {
|
||||||
|
|
||||||
static async setChunk(i, j, chunk, canvasId) {
|
static async setChunk(i, j, chunk, canvasId) {
|
||||||
const key = `ch:${canvasId}:${i}:${j}`;
|
const key = `ch:${canvasId}:${i}:${j}`;
|
||||||
await redis.set(key, Buffer.from(chunk.buffer));
|
await client.set(key, Buffer.from(chunk.buffer));
|
||||||
RedisCanvas.execChunkChangeCallback(canvasId, [i, j]);
|
RedisCanvas.execChunkChangeCallback(canvasId, [i, j]);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static async delChunk(i, j, canvasId) {
|
static async delChunk(i, j, canvasId) {
|
||||||
const key = `ch:${canvasId}:${i}:${j}`;
|
const key = `ch:${canvasId}:${i}:${j}`;
|
||||||
await redis.del(key);
|
await client.del(key);
|
||||||
RedisCanvas.execChunkChangeCallback(canvasId, [i, j]);
|
RedisCanvas.execChunkChangeCallback(canvasId, [i, j]);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -76,7 +76,7 @@ class RedisCanvas {
|
||||||
* TODO what if chunk does not exist?
|
* TODO what if chunk does not exist?
|
||||||
*/
|
*/
|
||||||
if (!RedisCanvas.multi) {
|
if (!RedisCanvas.multi) {
|
||||||
RedisCanvas.multi = redis.multi();
|
RedisCanvas.multi = client.multi();
|
||||||
setTimeout(RedisCanvas.flushPixels, 100);
|
setTimeout(RedisCanvas.flushPixels, 100);
|
||||||
}
|
}
|
||||||
RedisCanvas.multi.addCommand(
|
RedisCanvas.multi.addCommand(
|
||||||
|
@ -124,7 +124,7 @@ class RedisCanvas {
|
||||||
UINT_SIZE,
|
UINT_SIZE,
|
||||||
`#${offset}`,
|
`#${offset}`,
|
||||||
];
|
];
|
||||||
const result = await redis.sendCommand(args);
|
const result = await client.sendCommand(args);
|
||||||
if (!result) return null;
|
if (!result) return null;
|
||||||
const color = result[0];
|
const color = result[0];
|
||||||
return color;
|
return color;
|
|
@ -5,9 +5,9 @@
|
||||||
|
|
||||||
import { createClient } from 'redis';
|
import { createClient } from 'redis';
|
||||||
|
|
||||||
import { REDIS_URL } from '../core/config';
|
import { REDIS_URL } from '../../core/config';
|
||||||
|
|
||||||
const redis = createClient(REDIS_URL.startsWith('redis://')
|
const client = createClient(REDIS_URL.startsWith('redis://')
|
||||||
? {
|
? {
|
||||||
url: REDIS_URL,
|
url: REDIS_URL,
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ const redis = createClient(REDIS_URL.startsWith('redis://')
|
||||||
export const connect = async () => {
|
export const connect = async () => {
|
||||||
// eslint-disable-next-line no-console
|
// eslint-disable-next-line no-console
|
||||||
console.log(`Connecting to redis server at ${REDIS_URL}`);
|
console.log(`Connecting to redis server at ${REDIS_URL}`);
|
||||||
await redis.connect();
|
await client.connect();
|
||||||
};
|
};
|
||||||
|
|
||||||
export default redis;
|
export default client;
|
|
@ -2,17 +2,16 @@
|
||||||
*
|
*
|
||||||
* https://github.com/sequelize/sequelize/issues/1485#issuecomment-243822779
|
* https://github.com/sequelize/sequelize/issues/1485#issuecomment-243822779
|
||||||
*
|
*
|
||||||
* @flow
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import DataType from 'sequelize';
|
import { DataTypes } from 'sequelize';
|
||||||
import Model from '../sequelize';
|
import sequelize from './sequelize';
|
||||||
|
|
||||||
|
|
||||||
const Blacklist = Model.define('Blacklist', {
|
const Blacklist = sequelize.define('Blacklist', {
|
||||||
|
|
||||||
ip: {
|
ip: {
|
||||||
type: DataType.CHAR(39),
|
type: DataTypes.CHAR(39),
|
||||||
allowNull: false,
|
allowNull: false,
|
||||||
primaryKey: true,
|
primaryKey: true,
|
||||||
},
|
},
|
|
@ -2,25 +2,23 @@
|
||||||
*
|
*
|
||||||
* Database layout for Chat Channels
|
* Database layout for Chat Channels
|
||||||
*
|
*
|
||||||
* @flow
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import DataType from 'sequelize';
|
import { DataTypes, Utils } from 'sequelize';
|
||||||
|
|
||||||
import Model from '../sequelize';
|
import sequelize from './sequelize';
|
||||||
import RegUser from './RegUser';
|
import RegUser from './RegUser';
|
||||||
|
|
||||||
const Channel = Model.define('Channel', {
|
const Channel = sequelize.define('Channel', {
|
||||||
// Channel ID
|
// Channel ID
|
||||||
id: {
|
id: {
|
||||||
type: DataType.INTEGER.UNSIGNED,
|
type: DataTypes.INTEGER.UNSIGNED,
|
||||||
autoIncrement: true,
|
autoIncrement: true,
|
||||||
primaryKey: true,
|
primaryKey: true,
|
||||||
},
|
},
|
||||||
|
|
||||||
name: {
|
name: {
|
||||||
type: `${DataType.CHAR(32)} CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci`,
|
type: `${DataTypes.CHAR(32)} CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci`,
|
||||||
allowNull: true,
|
allowNull: true,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -31,14 +29,14 @@ const Channel = Model.define('Channel', {
|
||||||
* 3: faction (not implemented)
|
* 3: faction (not implemented)
|
||||||
*/
|
*/
|
||||||
type: {
|
type: {
|
||||||
type: DataType.TINYINT,
|
type: DataTypes.TINYINT,
|
||||||
allowNull: false,
|
allowNull: false,
|
||||||
defaultValue: 0,
|
defaultValue: 0,
|
||||||
},
|
},
|
||||||
|
|
||||||
lastMessage: {
|
lastMessage: {
|
||||||
type: DataType.DATE,
|
type: DataTypes.DATE,
|
||||||
defaultValue: DataType.literal('CURRENT_TIMESTAMP'),
|
defaultValue: new Utils.Literal('CURRENT_TIMESTAMP'),
|
||||||
allowNull: false,
|
allowNull: false,
|
||||||
},
|
},
|
||||||
}, {
|
}, {
|
|
@ -4,33 +4,33 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import DataType from 'sequelize';
|
import { DataTypes } from 'sequelize';
|
||||||
import Model from '../sequelize';
|
import sequelize from './sequelize';
|
||||||
import Channel from './Channel';
|
import Channel from './Channel';
|
||||||
import RegUser from './RegUser';
|
import RegUser from './RegUser';
|
||||||
|
|
||||||
const Message = Model.define('Message', {
|
const Message = sequelize.define('Message', {
|
||||||
// Message ID
|
// Message ID
|
||||||
id: {
|
id: {
|
||||||
type: DataType.INTEGER.UNSIGNED,
|
type: DataTypes.INTEGER.UNSIGNED,
|
||||||
autoIncrement: true,
|
autoIncrement: true,
|
||||||
primaryKey: true,
|
primaryKey: true,
|
||||||
},
|
},
|
||||||
|
|
||||||
name: {
|
name: {
|
||||||
type: `${DataType.CHAR(32)} CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci`,
|
type: `${DataTypes.CHAR(32)} CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci`,
|
||||||
defaultValue: 'mx',
|
defaultValue: 'mx',
|
||||||
allowNull: false,
|
allowNull: false,
|
||||||
},
|
},
|
||||||
|
|
||||||
flag: {
|
flag: {
|
||||||
type: DataType.CHAR(2),
|
type: DataTypes.CHAR(2),
|
||||||
defaultValue: 'xx',
|
defaultValue: 'xx',
|
||||||
allowNull: false,
|
allowNull: false,
|
||||||
},
|
},
|
||||||
|
|
||||||
message: {
|
message: {
|
||||||
type: `${DataType.CHAR(200)} CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci`,
|
type: `${DataTypes.CHAR(200)} CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci`,
|
||||||
allowNull: false,
|
allowNull: false,
|
||||||
},
|
},
|
||||||
}, {
|
}, {
|
|
@ -3,107 +3,106 @@
|
||||||
*
|
*
|
||||||
* This is the database of the data for registered Users
|
* This is the database of the data for registered Users
|
||||||
*
|
*
|
||||||
* @flow
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import DataType from 'sequelize';
|
import { DataTypes } from 'sequelize';
|
||||||
import Model from '../sequelize';
|
import sequelize from './sequelize';
|
||||||
|
|
||||||
import { generateHash } from '../../utils/hash';
|
import { generateHash } from '../../utils/hash';
|
||||||
|
|
||||||
|
|
||||||
const RegUser = Model.define('User', {
|
const RegUser = sequelize.define('User', {
|
||||||
id: {
|
id: {
|
||||||
type: DataType.INTEGER.UNSIGNED,
|
type: DataTypes.INTEGER.UNSIGNED,
|
||||||
autoIncrement: true,
|
autoIncrement: true,
|
||||||
primaryKey: true,
|
primaryKey: true,
|
||||||
},
|
},
|
||||||
|
|
||||||
email: {
|
email: {
|
||||||
type: DataType.CHAR(40),
|
type: DataTypes.CHAR(40),
|
||||||
allowNull: true,
|
allowNull: true,
|
||||||
},
|
},
|
||||||
|
|
||||||
name: {
|
name: {
|
||||||
type: `${DataType.CHAR(32)} CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci`,
|
type: `${DataTypes.CHAR(32)} CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci`,
|
||||||
allowNull: false,
|
allowNull: false,
|
||||||
},
|
},
|
||||||
|
|
||||||
// currently just moderator
|
// currently just moderator
|
||||||
roles: {
|
roles: {
|
||||||
type: DataType.TINYINT,
|
type: DataTypes.TINYINT,
|
||||||
allowNull: false,
|
allowNull: false,
|
||||||
defaultValue: 0,
|
defaultValue: 0,
|
||||||
},
|
},
|
||||||
|
|
||||||
// null if external oauth authentification
|
// null if external oauth authentification
|
||||||
password: {
|
password: {
|
||||||
type: DataType.CHAR(60),
|
type: DataTypes.CHAR(60),
|
||||||
allowNull: true,
|
allowNull: true,
|
||||||
},
|
},
|
||||||
|
|
||||||
totalPixels: {
|
totalPixels: {
|
||||||
type: DataType.INTEGER.UNSIGNED,
|
type: DataTypes.INTEGER.UNSIGNED,
|
||||||
allowNull: false,
|
allowNull: false,
|
||||||
defaultValue: 0,
|
defaultValue: 0,
|
||||||
},
|
},
|
||||||
|
|
||||||
dailyTotalPixels: {
|
dailyTotalPixels: {
|
||||||
type: DataType.INTEGER.UNSIGNED,
|
type: DataTypes.INTEGER.UNSIGNED,
|
||||||
allowNull: false,
|
allowNull: false,
|
||||||
defaultValue: 0,
|
defaultValue: 0,
|
||||||
},
|
},
|
||||||
|
|
||||||
ranking: {
|
ranking: {
|
||||||
type: DataType.INTEGER.UNSIGNED,
|
type: DataTypes.INTEGER.UNSIGNED,
|
||||||
allowNull: true,
|
allowNull: true,
|
||||||
},
|
},
|
||||||
|
|
||||||
dailyRanking: {
|
dailyRanking: {
|
||||||
type: DataType.INTEGER.UNSIGNED,
|
type: DataTypes.INTEGER.UNSIGNED,
|
||||||
allowNull: true,
|
allowNull: true,
|
||||||
},
|
},
|
||||||
|
|
||||||
// mail and Minecraft verified
|
// mail and Minecraft verified
|
||||||
verified: {
|
verified: {
|
||||||
type: DataType.TINYINT,
|
type: DataTypes.TINYINT,
|
||||||
allowNull: false,
|
allowNull: false,
|
||||||
defaultValue: false,
|
defaultValue: false,
|
||||||
},
|
},
|
||||||
|
|
||||||
// currently just blockDm
|
// currently just blockDm
|
||||||
blocks: {
|
blocks: {
|
||||||
type: DataType.TINYINT,
|
type: DataTypes.TINYINT,
|
||||||
allowNull: false,
|
allowNull: false,
|
||||||
defaultValue: 0,
|
defaultValue: 0,
|
||||||
},
|
},
|
||||||
|
|
||||||
discordid: {
|
discordid: {
|
||||||
type: DataType.CHAR(18),
|
type: DataTypes.CHAR(18),
|
||||||
allowNull: true,
|
allowNull: true,
|
||||||
},
|
},
|
||||||
|
|
||||||
redditid: {
|
redditid: {
|
||||||
type: DataType.CHAR(10),
|
type: DataTypes.CHAR(10),
|
||||||
allowNull: true,
|
allowNull: true,
|
||||||
},
|
},
|
||||||
|
|
||||||
// when mail verification got requested,
|
// when mail verification got requested,
|
||||||
// used for purging unverified accounts
|
// used for purging unverified accounts
|
||||||
verificationReqAt: {
|
verificationReqAt: {
|
||||||
type: DataType.DATE,
|
type: DataTypes.DATE,
|
||||||
allowNull: true,
|
allowNull: true,
|
||||||
},
|
},
|
||||||
|
|
||||||
// flag == country code
|
// flag == country code
|
||||||
flag: {
|
flag: {
|
||||||
type: DataType.CHAR(2),
|
type: DataTypes.CHAR(2),
|
||||||
defaultValue: 'xx',
|
defaultValue: 'xx',
|
||||||
allowNull: false,
|
allowNull: false,
|
||||||
},
|
},
|
||||||
|
|
||||||
lastLogIn: {
|
lastLogIn: {
|
||||||
type: DataType.DATE,
|
type: DataTypes.DATE,
|
||||||
allowNull: true,
|
allowNull: true,
|
||||||
},
|
},
|
||||||
}, {
|
}, {
|
|
@ -3,13 +3,11 @@
|
||||||
* Junction table for User -> Blocked User
|
* Junction table for User -> Blocked User
|
||||||
* Relations defined in ./index.js
|
* Relations defined in ./index.js
|
||||||
*
|
*
|
||||||
* @flow
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import Model from '../sequelize';
|
import sequelize from './sequelize';
|
||||||
|
|
||||||
const UserBlock = Model.define('UserBlock', {
|
const UserBlock = sequelize.define('UserBlock', {
|
||||||
}, {
|
}, {
|
||||||
timestamps: false,
|
timestamps: false,
|
||||||
});
|
});
|
|
@ -4,16 +4,14 @@
|
||||||
* A channel can be anything,
|
* A channel can be anything,
|
||||||
* Group, Public Chat, DM, etc.
|
* Group, Public Chat, DM, etc.
|
||||||
*
|
*
|
||||||
* @flow
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import DataType from 'sequelize';
|
import { DataTypes } from 'sequelize';
|
||||||
import Model from '../sequelize';
|
import sequelize from './sequelize';
|
||||||
|
|
||||||
const UserChannel = Model.define('UserChannel', {
|
const UserChannel = sequelize.define('UserChannel', {
|
||||||
lastRead: {
|
lastRead: {
|
||||||
type: DataType.DATE,
|
type: DataTypes.DATE,
|
||||||
allowNull: true,
|
allowNull: true,
|
||||||
},
|
},
|
||||||
}, {
|
}, {
|
|
@ -2,18 +2,16 @@
|
||||||
* Created by HF
|
* Created by HF
|
||||||
*
|
*
|
||||||
* https://github.com/sequelize/sequelize/issues/1485#issuecomment-243822779
|
* https://github.com/sequelize/sequelize/issues/1485#issuecomment-243822779
|
||||||
*
|
|
||||||
* @flow
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import DataType from 'sequelize';
|
import { DataTypes } from 'sequelize';
|
||||||
import Model from '../sequelize';
|
import sequelize from './sequelize';
|
||||||
|
|
||||||
|
|
||||||
const Whitelist = Model.define('Whitelist', {
|
const Whitelist = sequelize.define('Whitelist', {
|
||||||
|
|
||||||
ip: {
|
ip: {
|
||||||
type: DataType.CHAR(39),
|
type: DataTypes.CHAR(39),
|
||||||
allowNull: false,
|
allowNull: false,
|
||||||
primaryKey: true,
|
primaryKey: true,
|
||||||
},
|
},
|
|
@ -1,4 +1,3 @@
|
||||||
import sequelize from '../sequelize';
|
|
||||||
import Blacklist from './Blacklist';
|
import Blacklist from './Blacklist';
|
||||||
import Whitelist from './Whitelist';
|
import Whitelist from './Whitelist';
|
||||||
import RegUser from './RegUser';
|
import RegUser from './RegUser';
|
||||||
|
@ -36,11 +35,6 @@ RegUser.belongsToMany(RegUser, {
|
||||||
foreignKey: 'buid',
|
foreignKey: 'buid',
|
||||||
});
|
});
|
||||||
|
|
||||||
function sync(...args) {
|
|
||||||
return sequelize.sync(...args);
|
|
||||||
}
|
|
||||||
|
|
||||||
export default { sync };
|
|
||||||
export {
|
export {
|
||||||
Whitelist,
|
Whitelist,
|
||||||
Blacklist,
|
Blacklist,
|
|
@ -1,14 +1,13 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @flow
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import Sequelize from 'sequelize';
|
import Sequelize from 'sequelize';
|
||||||
|
|
||||||
import logger from '../core/logger';
|
import logger from '../../core/logger';
|
||||||
import {
|
import {
|
||||||
MYSQL_HOST, MYSQL_DATABASE, MYSQL_USER, MYSQL_PW, LOG_MYSQL,
|
MYSQL_HOST, MYSQL_DATABASE, MYSQL_USER, MYSQL_PW, LOG_MYSQL,
|
||||||
} from '../core/config';
|
} from '../../core/config';
|
||||||
|
|
||||||
const sequelize = new Sequelize(MYSQL_DATABASE, MYSQL_USER, MYSQL_PW, {
|
const sequelize = new Sequelize(MYSQL_DATABASE, MYSQL_USER, MYSQL_PW, {
|
||||||
host: MYSQL_HOST,
|
host: MYSQL_HOST,
|
|
@ -1,7 +1,7 @@
|
||||||
import express from 'express';
|
import express from 'express';
|
||||||
|
|
||||||
import logger from '../core/logger';
|
import logger from '../core/logger';
|
||||||
import RegUser from '../data/models/RegUser';
|
import { RegUser } from '../data/sql';
|
||||||
import { getIPFromRequest } from '../utils/ip';
|
import { getIPFromRequest } from '../utils/ip';
|
||||||
import { compareToHash } from '../utils/hash';
|
import { compareToHash } from '../utils/hash';
|
||||||
import { APISOCKET_KEY } from '../core/config';
|
import { APISOCKET_KEY } from '../core/config';
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
import type { Request, Response } from 'express';
|
import type { Request, Response } from 'express';
|
||||||
|
|
||||||
import socketEvents from '../../../socket/SocketEvents';
|
import socketEvents from '../../../socket/SocketEvents';
|
||||||
import { RegUser } from '../../../data/models';
|
import { RegUser } from '../../../data/sql';
|
||||||
import { validateName } from '../../../utils/validation';
|
import { validateName } from '../../../utils/validation';
|
||||||
|
|
||||||
async function validate(oldname, name) {
|
async function validate(oldname, name) {
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
import type { Request, Response } from 'express';
|
import type { Request, Response } from 'express';
|
||||||
|
|
||||||
import { RegUser } from '../../../data/models';
|
import { RegUser } from '../../../data/sql';
|
||||||
import { validatePassword } from '../../../utils/validation';
|
import { validatePassword } from '../../../utils/validation';
|
||||||
import { compareToHash } from '../../../utils/hash';
|
import { compareToHash } from '../../../utils/hash';
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ import type { Request, Response } from 'express';
|
||||||
import Sequelize from 'sequelize';
|
import Sequelize from 'sequelize';
|
||||||
|
|
||||||
import logger from '../../../core/logger';
|
import logger from '../../../core/logger';
|
||||||
import { RegUser } from '../../../data/models';
|
import { RegUser } from '../../../data/sql';
|
||||||
import mailProvider from '../../../core/mail';
|
import mailProvider from '../../../core/mail';
|
||||||
import getMe from '../../../core/me';
|
import getMe from '../../../core/me';
|
||||||
import { getIPFromRequest, getHostFromRequest } from '../../../utils/ip';
|
import { getIPFromRequest, getHostFromRequest } from '../../../utils/ip';
|
||||||
|
|
|
@ -9,7 +9,7 @@ import type { Request, Response } from 'express';
|
||||||
|
|
||||||
import logger from '../../core/logger';
|
import logger from '../../core/logger';
|
||||||
import socketEvents from '../../socket/SocketEvents';
|
import socketEvents from '../../socket/SocketEvents';
|
||||||
import { RegUser, UserBlock, Channel } from '../../data/models';
|
import { RegUser, UserBlock, Channel } from '../../data/sql';
|
||||||
|
|
||||||
async function block(req: Request, res: Response) {
|
async function block(req: Request, res: Response) {
|
||||||
let userId = parseInt(req.body.userId, 10);
|
let userId = parseInt(req.body.userId, 10);
|
||||||
|
|
|
@ -9,8 +9,8 @@ import type { Request, Response } from 'express';
|
||||||
|
|
||||||
import logger from '../../core/logger';
|
import logger from '../../core/logger';
|
||||||
import { ChatProvider } from '../../core/ChatProvider';
|
import { ChatProvider } from '../../core/ChatProvider';
|
||||||
import { Channel, RegUser } from '../../data/models';
|
import { Channel, RegUser } from '../../data/sql';
|
||||||
import { isUserBlockedBy } from '../../data/models/UserBlock';
|
import { isUserBlockedBy } from '../../data/sql/UserBlock';
|
||||||
|
|
||||||
async function startDm(req: Request, res: Response) {
|
async function startDm(req: Request, res: Response) {
|
||||||
let userId = parseInt(req.body.userId, 10);
|
let userId = parseInt(req.body.userId, 10);
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import etag from 'etag';
|
import etag from 'etag';
|
||||||
import RedisCanvas from '../data/models/RedisCanvas';
|
import RedisCanvas from '../data/redis/RedisCanvas';
|
||||||
import logger from '../core/logger';
|
import logger from '../core/logger';
|
||||||
|
|
||||||
const chunkEtags = new Map();
|
const chunkEtags = new Map();
|
||||||
|
|
|
@ -12,7 +12,7 @@ import logger from '../core/logger';
|
||||||
import getPasswordResetHtml from '../ssr-components/PasswordReset';
|
import getPasswordResetHtml from '../ssr-components/PasswordReset';
|
||||||
|
|
||||||
import mailProvider from '../core/mail';
|
import mailProvider from '../core/mail';
|
||||||
import { RegUser } from '../data/models';
|
import { RegUser } from '../data/sql';
|
||||||
|
|
||||||
|
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
|
|
|
@ -11,8 +11,8 @@ import http from 'http';
|
||||||
import forceGC from './core/forceGC';
|
import forceGC from './core/forceGC';
|
||||||
import logger from './core/logger';
|
import logger from './core/logger';
|
||||||
import rankings from './core/ranking';
|
import rankings from './core/ranking';
|
||||||
import models from './data/models';
|
import sequelize from './data/sql/sequelize';
|
||||||
import { connect as connectRedis } from './data/redis';
|
import { connect as connectRedis } from './data/redis/client';
|
||||||
import routes from './routes';
|
import routes from './routes';
|
||||||
import chatProvider from './core/ChatProvider';
|
import chatProvider from './core/ChatProvider';
|
||||||
import RpgEvent from './core/RpgEvent';
|
import RpgEvent from './core/RpgEvent';
|
||||||
|
@ -85,9 +85,9 @@ const rpgEvent = new RpgEvent();
|
||||||
// ip config
|
// ip config
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// sync sql models
|
// sync sql models
|
||||||
models.sync({ alter: { drop: false } })
|
sequelize.sync({ alter: { drop: false } })
|
||||||
// connect to redis
|
// connect to redis
|
||||||
.then(() => connectRedis())
|
.then(connectRedis)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
rankings.initialize();
|
rankings.initialize();
|
||||||
chatProvider.initialize();
|
chatProvider.initialize();
|
||||||
|
|
|
@ -12,7 +12,7 @@ import WebSocket from 'ws';
|
||||||
|
|
||||||
import socketEvents from './SocketEvents';
|
import socketEvents from './SocketEvents';
|
||||||
import chatProvider from '../core/ChatProvider';
|
import chatProvider from '../core/ChatProvider';
|
||||||
import RegUser from '../data/models/RegUser';
|
import { RegUser } from '../data/sql';
|
||||||
import { getIPFromRequest } from '../utils/ip';
|
import { getIPFromRequest } from '../utils/ip';
|
||||||
import { setPixelByCoords } from '../core/setPixel';
|
import { setPixelByCoords } from '../core/setPixel';
|
||||||
import logger from '../core/logger';
|
import logger from '../core/logger';
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import logger from '../core/logger';
|
import logger from '../core/logger';
|
||||||
import redis from '../data/redis';
|
import redis from '../data/redis/client';
|
||||||
import { getIPv6Subnet } from './ip';
|
import { getIPv6Subnet } from './ip';
|
||||||
import {
|
import {
|
||||||
CAPTCHA_URL,
|
CAPTCHA_URL,
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
import { isMainThread, parentPort } from 'worker_threads';
|
import { isMainThread, parentPort } from 'worker_threads';
|
||||||
|
|
||||||
import { connect as connectRedis } from '../data/redis';
|
import { connect as connectRedis } from '../data/redis/client';
|
||||||
import {
|
import {
|
||||||
createZoomTileFromChunk,
|
createZoomTileFromChunk,
|
||||||
createZoomedTile,
|
createZoomedTile,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user