Skip to content

Commit

Permalink
feat(core): ⚡ new changes based on WrappidApp implementation
Browse files Browse the repository at this point in the history
new changes based on WrappidApp implementation in server.ts

Ref #117
  • Loading branch information
techoneel committed May 5, 2024
1 parent fc25923 commit 9600e7f
Show file tree
Hide file tree
Showing 11 changed files with 1,859 additions and 260 deletions.
1,868 changes: 1,817 additions & 51 deletions package-lock.json

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@
"eslint-plugin-unused-imports": "~3.0.0",
"husky": "~8.0.3",
"jest": "~29.7.0",
"license-checker": "~25.0.1",
"nodemon": "~2.0.22",
"standard-version": "~9.5.0",
"supertest": "~6.3.3",
"ts-jest": "^29.1.2",
"license-checker": "~25.0.1"
"ts-jest": "^29.1.2"
}
}
}
1 change: 1 addition & 0 deletions src/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
2 changes: 0 additions & 2 deletions src/registry/ControllersRegistry.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { CoreControllersRegistry } from "@wrappid/service-core";
import * as modulesControllersRegistry from "../modules/modules.controllers.registry";

const ControllersRegistry: any = {

Check warning on line 3 in src/registry/ControllersRegistry.ts

View workflow job for this annotation

GitHub Actions / Validate code style

Unexpected any. Specify a different type
...modulesControllersRegistry.default,
...CoreControllersRegistry,
};
export default ControllersRegistry;
2 changes: 0 additions & 2 deletions src/registry/FunctionsRegistry.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { CoreFunctionsRegistry } from "@wrappid/service-core";
import * as modulesFunctionsRegistry from "../modules/modules.functions.registry";

const FunctionsRegistry = {
...modulesFunctionsRegistry.default,
...CoreFunctionsRegistry,
};
export default FunctionsRegistry;
3 changes: 1 addition & 2 deletions src/registry/MiddlewaresRegistry.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { CoreMiddlewaresRegistry } from "@wrappid/service-core";
import * as modulesMiddlewaresRegistry from "../modules/modules.middlewares.registry";

const MiddlewaresRegistry = {
...modulesMiddlewaresRegistry.default,
...CoreMiddlewaresRegistry,
};

export default MiddlewaresRegistry;
2 changes: 0 additions & 2 deletions src/registry/ModelsRegistry.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { CoreModelsRegistry } from "@wrappid/service-core";
import * as modulesModelsRegistry from "../modules/modules.models.registry";

const ModelsRegistry = {
...modulesModelsRegistry.default,
...CoreModelsRegistry,
};
export default ModelsRegistry;
2 changes: 0 additions & 2 deletions src/registry/TasksRegistry.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { CoreTasksRegistry } from "@wrappid/service-core";
import * as modulesTasksRegistry from "../modules/modules.tasks.registry";

const TasksRegistry = {
...modulesTasksRegistry.default,
...CoreTasksRegistry,
};
export default TasksRegistry;
2 changes: 0 additions & 2 deletions src/registry/ValidationsRegistry.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { CoreValidationsRegistry } from "@wrappid/service-core";
import * as modulesValidationsRegistry from "../modules/modules.validations.registry";

const ValidationsRegistry = {
...modulesValidationsRegistry,
...CoreValidationsRegistry,
};
export default ValidationsRegistry;
56 changes: 37 additions & 19 deletions src/server.ts
Original file line number Diff line number Diff line change
@@ -1,35 +1,53 @@
console.log("###########################################");
console.log("server.js start");
console.log("###########################################");
import { DEFAULT_PORT, WrappidApp } from "@wrappid/service-core";

import { DEFAULT_PORT, app } from "@wrappid/service-core";
import express from "express";
import applicationConfig from "./config.json";
import ControllersRegistry from "./registry/ControllersRegistry";
import FunctionsRegistry from "./registry/FunctionsRegistry";
import MiddlewaresRegistry from "./registry/MiddlewaresRegistry";
import ModelsRegistry from "./registry/ModelsRegistry";
import RoutesRegistry from "./registry/Routes.Registry";
import TasksRegistry from "./registry/TasksRegistry";
import swaggerJsonFile from "./swagger-output.json";
import ValidationsRegistry from "./registry/ValidationsRegistry";
import swaggerJson from "./swagger-output.json";

const wrappidApp: any = express();
try {

app(wrappidApp,ControllersRegistry, FunctionsRegistry, ModelsRegistry, RoutesRegistry, TasksRegistry, swaggerJsonFile);
console.log("###########################################");
console.log("server.js start");
console.log("###########################################");

const __PORT = process.env.PORT || DEFAULT_PORT;

const wrappidApp = new WrappidApp({
port: __PORT,
cors: { origin: "*" },
bodyPerser: {
json: { limit: "50mb" },
raw: {
inflate: true,
limit: "50mb",
type: "application/octet-stream",
},
urlencoded: { extended: true }
},
registry: {
ControllersRegistry,
FunctionsRegistry,
ModelsRegistry,
RoutesRegistry,
TasksRegistry,
MiddlewaresRegistry,
ValidationsRegistry
},
swagger: { ...swaggerJson },
config: { ...applicationConfig }
});

const serverInit = () => {
console.log("###########################################");
console.log(`Server is up and running on port ${__PORT}...`);
console.log("###########################################");
};

wrappidApp.listen(__PORT, serverInit);
wrappidApp.init();

} catch (error: any) {

Check warning on line 47 in src/server.ts

View workflow job for this annotation

GitHub Actions / Validate code style

Unexpected any. Specify a different type
console.error(error);
} finally {
console.log("###########################################");
console.log("server.js end");
console.log("###########################################");

} catch (error: any) {
console.log(error);
}
175 changes: 0 additions & 175 deletions src/swagger-output.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,184 +8,9 @@
"servers": [
{
"url": "http://localhost:8080"
},
{
"url": "https://demoapi.wrappid.dev"
}
],
"paths": {
"/login": {
"post": {
"tags": [
"Auth"
],
"summary": "Login ",
"description": "Login",
"operationId": "PostLogin",
"requestBody": {
"description": "Login into your account",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"emailOrPhone": {
"type": "string"
},
"password": {
"type": "string"
}
}
}
}
},
"required": true
},
"responses": {
"200": {
"description": "Successful operation",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"status": {
"type": "integer"
},
"message": {
"type": "string"
},
"id": {
"type": "integer"
},
"personId": {
"type": "integer"
},
"accessToken": {
"type": "string"
},
"refreshToken": {
"type": "string"
},
"sessionId": {
"type": "integer"
}
}
},
"examples": {
"PostLogin": {
"value": {
"status": 200,
"message": "Successfully login",
"id": 587,
"personId": 45,
"accessToken": "eyJhbGciOiJIUzI1I6IkpXVCJ9.eyJ1c2VySWQiOjQxOCwiZW1haWwiOiJwcml0YW1AcnhlZnkuY25JZCI6MSwicm9sZUlkIjTcwOTU",
"refreshToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOjQxOCwiZW1haWwiOiJwcml0YW1AcnhlZnkuY29tIiwicGhvbmUiOiIiLCJwZXJzb25JZCI6MSwi",
"sessionId": 343
}
}
}
}
}
},
"401": {
"description": "Successful operation",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"status": {
"type": "integer"
},
"message": {
"type": "string"
}
}
},
"examples": {
"PostLogin": {
"value": {
"status": 401,
"message": "Invalid password"
}
}
}
}
}
},
"404": {
"description": "Request API Not Found!!"
},
"403": {
"description": "Forbidden!!",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"message": {
"type": "string"
}
}
},
"examples": {
"GetDatabaseTables": {
"value": {
"message": "Invalid request"
}
}
}
}
}
},
"406": {
"description": "Not Acceptable",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"message": {
"type": "string"
}
}
},
"examples": {
"PostLogin": {
"value": {
"message": "emailOrPhone must match the following: \"/^([0-9]{10}|[a-zA-Z0-9+_.-]+@[a-zA-Z0-9.-]+)$/\""
}
}
}
}
}
},
"500": {
"description": "Internal Server Error",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"message": {
"type": "string"
}
}
},
"examples": {
"PostLogin": {
"value": {
"message": "Server Error"
}
}
}
}
}
}
}
}
},
"/business/tables/{database}": {
"get": {
"tags": [
Expand Down

0 comments on commit 9600e7f

Please sign in to comment.