organize imports
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
import type { Request, Response } from "express";
|
||||
import type { User } from "@chessu/types";
|
||||
import xss from "xss";
|
||||
import { hash, verify } from "argon2";
|
||||
import type { Request, Response } from "express";
|
||||
import xss from "xss";
|
||||
|
||||
import { activeGames } from "../db/models/game.model.js";
|
||||
import { io } from "../server.js";
|
||||
import UserModel from "../db/models/user.model.js";
|
||||
import { io } from "../server.js";
|
||||
|
||||
export const getCurrentSession = async (req: Request, res: Response) => {
|
||||
try {
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import type { Request, Response } from "express";
|
||||
import GameModel, { activeGames } from "../db/models/game.model.js";
|
||||
import type { Game, User } from "@chessu/types";
|
||||
import type { Request, Response } from "express";
|
||||
import { nanoid } from "nanoid";
|
||||
|
||||
import GameModel, { activeGames } from "../db/models/game.model.js";
|
||||
|
||||
export const getGames = async (req: Request, res: Response) => {
|
||||
try {
|
||||
if (!req.query.id && !req.query.userid) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { db } from "../index.js";
|
||||
import type { Game, User } from "@chessu/types";
|
||||
import { db } from "../index.js";
|
||||
|
||||
export const activeGames: Array<Game> = [];
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { db } from "../index.js";
|
||||
import type { User } from "@chessu/types";
|
||||
import { db } from "../index.js";
|
||||
|
||||
export const create = async (user: User, password: string) => {
|
||||
if (user.name === "Guest" || user.email === undefined) {
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import { nanoid } from "nanoid";
|
||||
import type { User } from "@chessu/types";
|
||||
import PGSimple from "connect-pg-simple";
|
||||
import type { Session } from "express-session";
|
||||
import session from "express-session";
|
||||
import PGSimple from "connect-pg-simple";
|
||||
import { nanoid } from "nanoid";
|
||||
|
||||
import { db } from "../db/index.js";
|
||||
import type { User } from "@chessu/types";
|
||||
|
||||
const PGSession = PGSimple(session);
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { Router } from "express";
|
||||
|
||||
import * as controller from "../controllers/auth.controller.js";
|
||||
|
||||
const router = Router();
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { Router } from "express";
|
||||
|
||||
import * as controller from "../controllers/games.controller.js";
|
||||
|
||||
const router = Router();
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { Router } from "express";
|
||||
import games from "./games.route.js";
|
||||
|
||||
import auth from "./auth.route.js";
|
||||
import games from "./games.route.js";
|
||||
import users from "./users.route.js";
|
||||
|
||||
const router = Router();
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
import "dotenv/config";
|
||||
import cors from "cors";
|
||||
import type { Request, Response, NextFunction } from "express";
|
||||
import "dotenv/config";
|
||||
import type { NextFunction, Request, Response } from "express";
|
||||
import express from "express";
|
||||
import { createServer } from "http";
|
||||
import session from "./middleware/session.js";
|
||||
import { Server } from "socket.io";
|
||||
import { init as initSocket } from "./socket/index.js";
|
||||
import { db, INIT_TABLES } from "./db/index.js";
|
||||
|
||||
import { INIT_TABLES, db } from "./db/index.js";
|
||||
import session from "./middleware/session.js";
|
||||
import routes from "./routes/index.js";
|
||||
import { init as initSocket } from "./socket/index.js";
|
||||
|
||||
const corsConfig = {
|
||||
origin: process.env.CORS_ORIGIN || "http://localhost:3000",
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import GameModel, { activeGames } from "../db/models/game.model.js";
|
||||
import type { Game } from "@chessu/types";
|
||||
import type { DisconnectReason, Socket } from "socket.io";
|
||||
import { Chess } from "chess.js";
|
||||
import type { DisconnectReason, Socket } from "socket.io";
|
||||
|
||||
import GameModel, { activeGames } from "../db/models/game.model.js";
|
||||
import { io } from "../server.js";
|
||||
|
||||
export async function joinLobby(this: Socket, gameCode: string) {
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
import type { Socket } from "socket.io";
|
||||
|
||||
import { io } from "../server.js";
|
||||
import {
|
||||
chat,
|
||||
claimAbandoned,
|
||||
getLatestGame,
|
||||
joinAsPlayer,
|
||||
joinLobby,
|
||||
leaveLobby,
|
||||
getLatestGame,
|
||||
sendMove,
|
||||
joinAsPlayer,
|
||||
chat,
|
||||
claimAbandoned
|
||||
sendMove
|
||||
} from "./game.socket.js";
|
||||
|
||||
const socketConnect = (socket: Socket) => {
|
||||
|
||||
Reference in New Issue
Block a user