organize imports

This commit is contained in:
Nathaniel Tampus
2023-05-01 15:15:49 +08:00
parent e38420c390
commit da7b4c40a3
25 changed files with 56 additions and 46 deletions

View File

@@ -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 {

View File

@@ -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) {

View File

@@ -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> = [];

View File

@@ -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) {

View File

@@ -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);

View File

@@ -1,4 +1,5 @@
import { Router } from "express";
import * as controller from "../controllers/auth.controller.js";
const router = Router();

View File

@@ -1,4 +1,5 @@
import { Router } from "express";
import * as controller from "../controllers/games.controller.js";
const router = Router();

View File

@@ -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();

View File

@@ -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",

View File

@@ -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) {

View File

@@ -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) => {