Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert to type module #52

Draft
wants to merge 2 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions app.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import express, { NextFunction, Request, Response } from "express";
import createError from "http-errors";
import AppMiddlewares from "./middlewares";
import indexRouter from "./routes/index";
import health from "./controllers/health";
import AppMiddlewares from "./middlewares/index.js";
import indexRouter from "./routes/index.js";
import health from "./controllers/health.js";

// Initialise express
const app = express();
Expand Down
4 changes: 2 additions & 2 deletions controllers/auth.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import passport from "passport";
import { NextFunction, Request, Response } from "express";
import logger from "../utils/logger";
import * as authService from "../services/authService";
import logger from "../utils/logger.js";
import * as authService from "../services/authService.js";

/**
* Fetches the user info from Google and authenticates User
Expand Down
2 changes: 1 addition & 1 deletion controllers/health.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Request, Response } from "express";
import { healthResponse } from "../@types/apiReponse";
import { healthResponse } from "../@types/apiReponse.js";
import { version } from "../package.json";

/**
Expand Down
2 changes: 1 addition & 1 deletion controllers/users.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Request, Response } from "express";
import prisma from "../prisma/prisma";
import prisma from "../prisma/prisma.js";
import { Users } from "@prisma/client";

/**
Expand Down
4 changes: 2 additions & 2 deletions middlewares/authenticate.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as authService from "../services/authService";
import prisma from "../prisma/prisma";
import * as authService from "../services/authService.js";
import prisma from "../prisma/prisma.js";
import { NextFunction, Request, Response } from "express";

/**
Expand Down
6 changes: 3 additions & 3 deletions middlewares/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import cors from "cors";
import config from "config";
import passport from "passport";
import * as dotenv from "dotenv";
import morganMiddleware from "../utils/httpLogger";
import "../providers/google";
import "../providers/microsoft";
import morganMiddleware from "../utils/httpLogger.js";
import "../providers/google.js";
import "../providers/microsoft.js";

const middleware = (app: express.Application): void => {
// Load vars from .env to process.env
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "0.0.1",
"private": true,
"main": "dist/server.js",
"type": "module",
"scripts": {
"lint": "eslint . && echo '✔ Your .js files look good.'",
"lint-fix": "eslint . --fix",
Expand Down
3 changes: 0 additions & 3 deletions prisma/migrations/migration_lock.toml

This file was deleted.

2 changes: 1 addition & 1 deletion routes/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
googleAuthCallback,
microsoftAuthCallback,
logOut,
} from "../controllers/auth";
} from "../controllers/auth.js";
import passport from "passport";

const router = Router();
Expand Down
4 changes: 2 additions & 2 deletions routes/calendar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import {
googleConnectHandler,
googleCallbackHandler,
getUserCalendar,
} from "../controllers/calendar";
import authenticate from "../middlewares/authenticate";
} from "../controllers/calendar.js";
import authenticate from "../middlewares/authenticate.js";

const router = Router();

Expand Down
2 changes: 1 addition & 1 deletion routes/health.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Router } from "express";
import health from "../controllers/health";
import health from "../controllers/health.js";

const router = Router();

Expand Down
8 changes: 4 additions & 4 deletions routes/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import express from "express";
import health from "./health";
import auth from "./auth";
import users from "./users";
import calendar from "./calendar";
import health from "./health.js";
import auth from "./auth.js";
import users from "./users.js";
import calendar from "./calendar.js";

const app = express();

Expand Down
8 changes: 4 additions & 4 deletions routes/users.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Router } from "express";
import { getSelfData, patchSelfData } from "../controllers/users";
import authenticate from "../middlewares/authenticate";
import { validate } from "../middlewares/validators/validator";
import { patchUserSelfSchema } from "../middlewares/validators/userSchema";
import { getSelfData, patchSelfData } from "../controllers/users.js";
import authenticate from "../middlewares/authenticate.js";
import { validate } from "../middlewares/validators/validator.js";
import { patchUserSelfSchema } from "../middlewares/validators/userSchema.js";

const router = Router();

Expand Down
4 changes: 2 additions & 2 deletions server.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import config from "config";
import logger from "./utils/logger";
import logger from "./utils/logger.js";
import * as http from "http";
import app from "./app";
import app from "./app.js";
import ErrnoException = NodeJS.ErrnoException;

// Initialise globals
Expand Down
6 changes: 3 additions & 3 deletions services/authService.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import jwt from "jsonwebtoken";
import { GoogleOAuthJson, MicrosoftOAuthJson } from "../@types/providers";
import prisma from "../prisma/prisma";
import { jwtPayload } from "../@types/services";
import { GoogleOAuthJson, MicrosoftOAuthJson } from "../@types/providers.js";
import prisma from "../prisma/prisma.js";
import { jwtPayload } from "../@types/services.js";
import { Users } from "@prisma/client";

/**
Expand Down
2 changes: 1 addition & 1 deletion test/integration/auth.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import chai from "chai";
import chaiHttp from "chai-http";

import app from "../../server";
import app from "../../server.js";
const { expect } = chai;
chai.use(chaiHttp);

Expand Down
2 changes: 1 addition & 1 deletion test/integration/health.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import chai from "chai";
import chaiHttp from "chai-http";

import app from "../../server";
import app from "../../server.js";
const { expect } = chai;
chai.use(chaiHttp);

Expand Down
2 changes: 1 addition & 1 deletion test/unit/security.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import chai from "chai";
import chaiHttp from "chai-http";

import app from "../../server";
import app from "../../server.js";
const { expect } = chai;
chai.use(chaiHttp);

Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
// "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */

/* Modules */
"module": "commonjs",
"module": "nodenext",
/* Specify what module code is generated. */
// "rootDir": "./", /* Specify the root folder within your source files. */
// "moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */
Expand Down