Merge pull request #2974 from bluewave-labs/fix/cleanup
move v1 to v1 dir, add build workflow
This commit is contained in:
46 files changed
+136
-64
No files matched your search
@@ -0,0 +1,23 @@
|
|||||||
|
name: Build Check (Server)
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-server:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Set up Node
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: 22
|
||||||
|
|
||||||
|
- name: Install server dependencies
|
||||||
|
working-directory: server
|
||||||
|
run: npm install
|
||||||
|
|
||||||
|
- name: Check server formatting
|
||||||
|
working-directory: server
|
||||||
|
run: npm run build
|
||||||
+5
-5
@@ -1,16 +1,16 @@
|
|||||||
import express from "express";
|
import express from "express";
|
||||||
import path from "path";
|
import path from "path";
|
||||||
import { responseHandler } from "./middleware/responseHandler.js";
|
import { responseHandler } from "./middleware/v1/responseHandler.js";
|
||||||
import cors from "cors";
|
import cors from "cors";
|
||||||
import helmet from "helmet";
|
import helmet from "helmet";
|
||||||
import compression from "compression";
|
import compression from "compression";
|
||||||
import cookieParser from "cookie-parser";
|
import cookieParser from "cookie-parser";
|
||||||
import languageMiddleware from "./middleware/languageMiddleware.js";
|
import languageMiddleware from "./middleware/v1/languageMiddleware.js";
|
||||||
import swaggerUi from "swagger-ui-express";
|
import swaggerUi from "swagger-ui-express";
|
||||||
import { handleErrors } from "./middleware/handleErrors.js";
|
import { handleErrors } from "./middleware/v1/handleErrors.js";
|
||||||
import { setupRoutes } from "./config/routes.js";
|
import { setupRoutes } from "./config/routes.js";
|
||||||
import { generalApiLimiter } from "./middleware/rateLimiter.js";
|
import { generalApiLimiter } from "./middleware/v1/rateLimiter.js";
|
||||||
import { sanitizeBody, sanitizeQuery } from "./middleware/sanitization.js";
|
import { sanitizeBody, sanitizeQuery } from "./middleware/v1/sanitization.js";
|
||||||
|
|
||||||
export const createApp = ({ services, controllers, envSettings, frontendPath, openApiSpec }) => {
|
export const createApp = ({ services, controllers, envSettings, frontendPath, openApiSpec }) => {
|
||||||
const allowedOrigin = envSettings.clientHost;
|
const allowedOrigin = envSettings.clientHost;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { verifyJWT } from "../middleware/verifyJWT.js";
|
import { verifyJWT } from "../middleware/v1/verifyJWT.js";
|
||||||
import { authApiLimiter } from "../middleware/rateLimiter.js";
|
import { authApiLimiter } from "../middleware/v1/rateLimiter.js";
|
||||||
|
|
||||||
import AuthRoutes from "../routes/v1/authRoute.js";
|
import AuthRoutes from "../routes/v1/authRoute.js";
|
||||||
import InviteRoutes from "../routes/v1//inviteRoute.js";
|
import InviteRoutes from "../routes/v1//inviteRoute.js";
|
||||||
|
|||||||
@@ -1,22 +1,22 @@
|
|||||||
import ServiceRegistry from "../service/system/serviceRegistry.js";
|
import ServiceRegistry from "../service/v1/system/serviceRegistry.js";
|
||||||
import TranslationService from "../service/system/translationService.js";
|
import TranslationService from "../service/v1/system/translationService.js";
|
||||||
import StringService from "../service/system/stringService.js";
|
import StringService from "../service/v1/system/stringService.js";
|
||||||
import MongoDB from "../db/mongo/MongoDB.js";
|
import MongoDB from "../db/mongo/MongoDB.js";
|
||||||
import NetworkService from "../service/infrastructure/networkService.js";
|
import NetworkService from "../service/v1/infrastructure/networkService.js";
|
||||||
import EmailService from "../service/infrastructure/emailService.js";
|
import EmailService from "../service/v1/infrastructure/emailService.js";
|
||||||
import BufferService from "../service/infrastructure/bufferService.js";
|
import BufferService from "../service/v1/infrastructure/bufferService.js";
|
||||||
import StatusService from "../service/infrastructure/statusService.js";
|
import StatusService from "../service/v1/infrastructure/statusService.js";
|
||||||
import NotificationUtils from "../service/infrastructure/notificationUtils.js";
|
import NotificationUtils from "../service/v1/infrastructure/notificationUtils.js";
|
||||||
import NotificationService from "../service/infrastructure/notificationService.js";
|
import NotificationService from "../service/v1/infrastructure/notificationService.js";
|
||||||
import ErrorService from "../service/infrastructure/errorService.js";
|
import ErrorService from "../service/v1/infrastructure/errorService.js";
|
||||||
import SuperSimpleQueueHelper from "../service/infrastructure/SuperSimpleQueue/SuperSimpleQueueHelper.js";
|
import SuperSimpleQueueHelper from "../service/v1/infrastructure/SuperSimpleQueue/SuperSimpleQueueHelper.js";
|
||||||
import SuperSimpleQueue from "../service/infrastructure/SuperSimpleQueue/SuperSimpleQueue.js";
|
import SuperSimpleQueue from "../service/v1/infrastructure/SuperSimpleQueue/SuperSimpleQueue.js";
|
||||||
import UserService from "../service/business/userService.js";
|
import UserService from "../service/v1/business/userService.js";
|
||||||
import CheckService from "../service/business/checkService.js";
|
import CheckService from "../service/v1/business/checkService.js";
|
||||||
import DiagnosticService from "../service/business/diagnosticService.js";
|
import DiagnosticService from "../service/v1/business/diagnosticService.js";
|
||||||
import InviteService from "../service/business/inviteService.js";
|
import InviteService from "../service/v1/business/inviteService.js";
|
||||||
import MaintenanceWindowService from "../service/business/maintenanceWindowService.js";
|
import MaintenanceWindowService from "../service/v1/business/maintenanceWindowService.js";
|
||||||
import MonitorService from "../service/business/monitorService.js";
|
import MonitorService from "../service/v1/business/monitorService.js";
|
||||||
import papaparse from "papaparse";
|
import papaparse from "papaparse";
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import got from "got";
|
import got from "got";
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { AppError } from "../../service/infrastructure/errorService.js";
|
import { AppError } from "../../service/v1/infrastructure/errorService.js";
|
||||||
|
|
||||||
export const createCommonDependencies = (db, errorService, logger, stringService) => {
|
export const createCommonDependencies = (db, errorService, logger, stringService) => {
|
||||||
return {
|
return {
|
||||||
|
|||||||
+1
-1
@@ -7,7 +7,7 @@ import path from "path";
|
|||||||
import fs from "fs";
|
import fs from "fs";
|
||||||
|
|
||||||
import Logger from "./utils/logger.js";
|
import Logger from "./utils/logger.js";
|
||||||
import SettingsService from "./service/system/settingsService.js";
|
import SettingsService from "./service/v1/system/settingsService.js";
|
||||||
import AppSettings from "./db/models/AppSettings.js";
|
import AppSettings from "./db/models/AppSettings.js";
|
||||||
|
|
||||||
const SERVICE_NAME = "Server";
|
const SERVICE_NAME = "Server";
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { logger } from "../utils/logger.js";
|
import { logger } from "../../utils/logger.js";
|
||||||
import ServiceRegistry from "../service/system/serviceRegistry.js";
|
import ServiceRegistry from "../../service/v1/system/serviceRegistry.js";
|
||||||
import StringService from "../service/system/stringService.js";
|
import StringService from "../../service/v1/system/stringService.js";
|
||||||
|
|
||||||
const handleErrors = (error, req, res, next) => {
|
const handleErrors = (error, req, res, next) => {
|
||||||
const status = error.status || 500;
|
const status = error.status || 500;
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
import jwt from "jsonwebtoken";
|
import jwt from "jsonwebtoken";
|
||||||
const TOKEN_PREFIX = "Bearer ";
|
const TOKEN_PREFIX = "Bearer ";
|
||||||
const SERVICE_NAME = "allowedRoles";
|
const SERVICE_NAME = "allowedRoles";
|
||||||
import ServiceRegistry from "../service/system/serviceRegistry.js";
|
import ServiceRegistry from "../../service/v1/system/serviceRegistry.js";
|
||||||
import StringService from "../service/system/stringService.js";
|
import StringService from "../../service/v1/system/stringService.js";
|
||||||
import SettingsService from "../service/system/settingsService.js";
|
import SettingsService from "../../service/v1/system/settingsService.js";
|
||||||
|
|
||||||
const isAllowed = (allowedRoles) => {
|
const isAllowed = (allowedRoles) => {
|
||||||
return (req, res, next) => {
|
return (req, res, next) => {
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
import { logger } from "../utils/logger.js";
|
import { logger } from "../../utils/logger.js";
|
||||||
|
|
||||||
const languageMiddleware = (stringService, translationService) => async (req, res, next) => {
|
const languageMiddleware = (stringService, translationService) => async (req, res, next) => {
|
||||||
try {
|
try {
|
||||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -1,7 +1,7 @@
|
|||||||
import jwt from "jsonwebtoken";
|
import jwt from "jsonwebtoken";
|
||||||
import ServiceRegistry from "../service/system/serviceRegistry.js";
|
import ServiceRegistry from "../../service/v1/system/serviceRegistry.js";
|
||||||
import SettingsService from "../service/system/settingsService.js";
|
import SettingsService from "../../service/v1/system/settingsService.js";
|
||||||
import StringService from "../service/system/stringService.js";
|
import StringService from "../../service/v1/system/stringService.js";
|
||||||
const SERVICE_NAME = "verifyJWT";
|
const SERVICE_NAME = "verifyJWT";
|
||||||
const TOKEN_PREFIX = "Bearer ";
|
const TOKEN_PREFIX = "Bearer ";
|
||||||
|
|
||||||
+3
-3
@@ -1,6 +1,6 @@
|
|||||||
import { logger } from "../utils/logger.js";
|
import { logger } from "../../utils/logger.js";
|
||||||
import ServiceRegistry from "../service/system/serviceRegistry.js";
|
import ServiceRegistry from "../../service/v1/system/serviceRegistry.js";
|
||||||
import StringService from "../service/system/stringService.js";
|
import StringService from "../../service/v1/system/stringService.js";
|
||||||
import { ObjectId } from "mongodb";
|
import { ObjectId } from "mongodb";
|
||||||
|
|
||||||
const SERVICE_NAME = "verifyOwnership";
|
const SERVICE_NAME = "verifyOwnership";
|
||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
const jwt = require("jsonwebtoken");
|
const jwt = require("jsonwebtoken");
|
||||||
const logger = require("../utils/logger");
|
const logger = require("../../utils/logger.js");
|
||||||
const SERVICE_NAME = "verifyAdmin";
|
const SERVICE_NAME = "verifyAdmin";
|
||||||
const TOKEN_PREFIX = "Bearer ";
|
const TOKEN_PREFIX = "Bearer ";
|
||||||
import ServiceRegistry from "../service/serviceRegistry.js";
|
import ServiceRegistry from "../service/serviceRegistry.js";
|
||||||
File renamed without changes.
@@ -1,6 +1,6 @@
|
|||||||
import { Router } from "express";
|
import { Router } from "express";
|
||||||
import { verifyJWT } from "../../middleware/verifyJWT.js";
|
import { verifyJWT } from "../../middleware/v1/verifyJWT.js";
|
||||||
import { isAllowed } from "../../middleware/isAllowed.js";
|
import { isAllowed } from "../../middleware/v1/isAllowed.js";
|
||||||
import multer from "multer";
|
import multer from "multer";
|
||||||
|
|
||||||
const upload = multer();
|
const upload = multer();
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { Router } from "express";
|
import { Router } from "express";
|
||||||
|
|
||||||
import { isAllowed } from "../../middleware/isAllowed.js";
|
import { isAllowed } from "../../middleware/v1/isAllowed.js";
|
||||||
|
|
||||||
class CheckRoutes {
|
class CheckRoutes {
|
||||||
constructor(checkController) {
|
constructor(checkController) {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { Router } from "express";
|
import { Router } from "express";
|
||||||
import { verifyJWT } from "../../middleware/verifyJWT.js";
|
import { verifyJWT } from "../../middleware/v1/verifyJWT.js";
|
||||||
import { isAllowed } from "../../middleware/isAllowed.js";
|
import { isAllowed } from "../../middleware/v1/isAllowed.js";
|
||||||
|
|
||||||
class DiagnosticRoutes {
|
class DiagnosticRoutes {
|
||||||
constructor(diagnosticController) {
|
constructor(diagnosticController) {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { Router } from "express";
|
import { Router } from "express";
|
||||||
import { verifyJWT } from "../../middleware/verifyJWT.js";
|
import { verifyJWT } from "../../middleware/v1/verifyJWT.js";
|
||||||
import { isAllowed } from "../../middleware/isAllowed.js";
|
import { isAllowed } from "../../middleware/v1/isAllowed.js";
|
||||||
|
|
||||||
class InviteRoutes {
|
class InviteRoutes {
|
||||||
constructor(inviteController) {
|
constructor(inviteController) {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { Router } from "express";
|
import { Router } from "express";
|
||||||
import { isAllowed } from "../../middleware/isAllowed.js";
|
import { isAllowed } from "../../middleware/v1/isAllowed.js";
|
||||||
class LogRoutes {
|
class LogRoutes {
|
||||||
constructor(logController) {
|
constructor(logController) {
|
||||||
this.router = Router();
|
this.router = Router();
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { Router } from "express";
|
import { Router } from "express";
|
||||||
import { isAllowed } from "../../middleware/isAllowed.js";
|
import { isAllowed } from "../../middleware/v1/isAllowed.js";
|
||||||
import multer from "multer";
|
import multer from "multer";
|
||||||
import { fetchMonitorCertificate } from "../../controllers/v1/controllerUtils.js";
|
import { fetchMonitorCertificate } from "../../controllers/v1/controllerUtils.js";
|
||||||
const upload = multer({
|
const upload = multer({
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { Router } from "express";
|
import { Router } from "express";
|
||||||
import { isAllowed } from "../../middleware/isAllowed.js";
|
import { isAllowed } from "../../middleware/v1/isAllowed.js";
|
||||||
class QueueRoutes {
|
class QueueRoutes {
|
||||||
constructor(queueController) {
|
constructor(queueController) {
|
||||||
this.router = Router();
|
this.router = Router();
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { Router } from "express";
|
import { Router } from "express";
|
||||||
import { isAllowed } from "../../middleware/isAllowed.js";
|
import { isAllowed } from "../../middleware/v1/isAllowed.js";
|
||||||
|
|
||||||
class SettingsRoutes {
|
class SettingsRoutes {
|
||||||
constructor(settingsController) {
|
constructor(settingsController) {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { Router } from "express";
|
import { Router } from "express";
|
||||||
import { verifyJWT } from "../../middleware/verifyJWT.js";
|
import { verifyJWT } from "../../middleware/v1/verifyJWT.js";
|
||||||
import multer from "multer";
|
import multer from "multer";
|
||||||
const upload = multer();
|
const upload = multer();
|
||||||
|
|
||||||
|
|||||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
import { createMonitorsBodyValidation } from "../../validation/joi.js";
|
import { createMonitorsBodyValidation } from "../../../validation/joi.js";
|
||||||
|
|
||||||
const SERVICE_NAME = "MonitorService";
|
const SERVICE_NAME = "MonitorService";
|
||||||
class MonitorService {
|
class MonitorService {
|
||||||
File renamed without changes.
File renamed without changes.
+5
-5
@@ -5,11 +5,11 @@ class SuperSimpleQueueHelper {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {{
|
* @param {{
|
||||||
* db: import("../database").Database,
|
* db: import("../database.js").Database,
|
||||||
* logger: import("../logger").Logger,
|
* logger: import("../logger.js").Logger,
|
||||||
* networkService: import("../networkService").NetworkService,
|
* networkService: import("../networkService.js").NetworkService,
|
||||||
* statusService: import("../statusService").StatusService,
|
* statusService: import("../statusService.js").StatusService,
|
||||||
* notificationService: import("../notificationService").NotificationService
|
* notificationService: import("../notificationService.js").NotificationService
|
||||||
* }}
|
* }}
|
||||||
*/
|
*/
|
||||||
constructor({ db, logger, networkService, statusService, notificationService }) {
|
constructor({ db, logger, networkService, statusService, notificationService }) {
|
||||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
import MonitorStats from "../../db/models/MonitorStats.js";
|
import MonitorStats from "../../../db/models/MonitorStats.js";
|
||||||
const SERVICE_NAME = "StatusService";
|
const SERVICE_NAME = "StatusService";
|
||||||
|
|
||||||
class StatusService {
|
class StatusService {
|
||||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -3,6 +3,45 @@ import { User, Role, ITokenizedUser } from "../../../db/models/index.js";
|
|||||||
import ApiError from "../../../utils/ApiError.js";
|
import ApiError from "../../../utils/ApiError.js";
|
||||||
import { Types } from "mongoose";
|
import { Types } from "mongoose";
|
||||||
|
|
||||||
|
export const PERMISSIONS = {
|
||||||
|
users: {
|
||||||
|
all: "users.*",
|
||||||
|
create: "users.create",
|
||||||
|
view: "users.view",
|
||||||
|
update: "users.update",
|
||||||
|
delete: "users.delete",
|
||||||
|
},
|
||||||
|
|
||||||
|
monitors: {
|
||||||
|
all: "monitors.*",
|
||||||
|
create: "monitors.create",
|
||||||
|
view: "monitors.view",
|
||||||
|
update: "monitors.update",
|
||||||
|
delete: "monitors.delete",
|
||||||
|
},
|
||||||
|
notifications: {
|
||||||
|
all: "notifications.*",
|
||||||
|
create: "notifications.create",
|
||||||
|
view: "notifications.view",
|
||||||
|
update: "notifications.update",
|
||||||
|
delete: "notifications.delete",
|
||||||
|
},
|
||||||
|
checks: {
|
||||||
|
all: "checks.*",
|
||||||
|
create: "checks.create",
|
||||||
|
view: "checks.view",
|
||||||
|
update: "checks.update",
|
||||||
|
delete: "checks.delete",
|
||||||
|
},
|
||||||
|
statusPages: {
|
||||||
|
all: "statusPages.*",
|
||||||
|
create: "statusPages.create",
|
||||||
|
view: "statusPages.view",
|
||||||
|
update: "statusPages.update",
|
||||||
|
delete: "statusPages.delete",
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
export const DEFAULT_ROLES = [
|
export const DEFAULT_ROLES = [
|
||||||
{
|
{
|
||||||
name: "SuperAdmin",
|
name: "SuperAdmin",
|
||||||
@@ -13,19 +52,19 @@ export const DEFAULT_ROLES = [
|
|||||||
{
|
{
|
||||||
name: "Admin",
|
name: "Admin",
|
||||||
description: "Admin with full permissions",
|
description: "Admin with full permissions",
|
||||||
permissions: ["monitor.*", "users.*"],
|
permissions: [PERMISSIONS.monitors.all, PERMISSIONS.users.all],
|
||||||
isSystem: true,
|
isSystem: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Manager",
|
name: "Manager",
|
||||||
description: "Can manage users",
|
description: "Can manage users",
|
||||||
permissions: ["users.create", "users.update", "monitors.*"],
|
permissions: [PERMISSIONS.users.create, PERMISSIONS.users.update, PERMISSIONS.monitors.all],
|
||||||
isSystem: true,
|
isSystem: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Member",
|
name: "Member",
|
||||||
description: "Basic team member",
|
description: "Basic team member",
|
||||||
permissions: ["users.update", "monitors.create", "monitors.view", "monitors.update"],
|
permissions: [PERMISSIONS.users.update, PERMISSIONS.monitors.create, PERMISSIONS.monitors.view, PERMISSIONS.monitors.update],
|
||||||
isSystem: true,
|
isSystem: true,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
@@ -126,7 +165,7 @@ class AuthService implements IAuthService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check password
|
// Check password
|
||||||
const isPasswordValid = await bcrypt.compare(password, user.passwordHash);
|
const isPasswordValid = await bcrypt.compare(password, user.password);
|
||||||
if (!isPasswordValid) {
|
if (!isPasswordValid) {
|
||||||
throw new Error("Invalid email or password");
|
throw new Error("Invalid email or password");
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
+10
@@ -0,0 +1,10 @@
|
|||||||
|
import { ITokenizedUser } from "../db/models/index.ts";
|
||||||
|
|
||||||
|
declare global {
|
||||||
|
namespace Express {
|
||||||
|
interface Request {
|
||||||
|
user?: ITokenizedUser;
|
||||||
|
resource?: any;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in new issue
Block a user