Skip to content

Commit

Permalink
Merge pull request #235 from Uconnect-Technologies/roadmap-1.9.7
Browse files Browse the repository at this point in the history
Roadmap 1.9.7 Beta
  • Loading branch information
ilyaskarim committed Oct 16, 2020
2 parents 5eb1e62 + 2536c2c commit 3f3d93e
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 17 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "wertik-js",
"version": "1.9.960",
"version": "1.9.97-beta",
"main": "lib/main.js",
"repository": "https://github.com/Uconnect-Technologies/wertik-js.git",
"welcomeResponse": "Welcome to wertik, You are successfully running Wertik.",
Expand Down
7 changes: 4 additions & 3 deletions src/framework/database/helpers/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
const sequelize = require("sequelize");

// mysql helpers

export const convertFieldsIntoSequelizeFields = (fields) => {
let k = Object.keys(fields);
k.forEach((element) => {
const t = fields[element].type;
let t = fields[element].type;
if (t.toLowerCase() === "number") {
t = "integer";
}
fields[element].type = sequelize[t.toUpperCase()];
fields[element].oldType = t;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,11 @@ export default {
},
restApi: {
showWertik404Page: true,
onCustomApiFailure: function ({ path, res }) {
onCustomApiFailure: function ({ path, res, err }) {
res.send("failed at " + path);
},
// Below function for custom 404 page or response.
// restApi404Handler: function () {}
},
modules: [
{
Expand Down Expand Up @@ -124,13 +126,13 @@ export default {
sockets: {
disable: false,
onClientConnected: function () {
console.log("onClientConnected")
console.log("onClientConnected");
},
onMessageReceived: function () {
console.log("onMessageReceived")
console.log("onMessageReceived");
},
onClientDisconnect: function () {
console.log("onClientDisconnect")
onClientDisconnect: function () {
console.log("onClientDisconnect");
},
},
storage: {
Expand Down
20 changes: 12 additions & 8 deletions src/framework/initialization/startServers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,20 @@ export default function (configuration: IConfiguration, servers: any) {

const expressAppPort = get(configuration, "port", defaultPort);
const showWertik404Page = get(configuration, "restApi.showWertik404Page", true);
const restApi404Handler = get(configuration, "restApi.restApi404Handler", function (req, res) {
res.status(404).json({
message: "Not found",
data: {
message: "Request page didn't found",
},
});
});
const restApiBeforeStart = get(configuration, "restApi.beforeStart", function () {});

const graphqlPath = get(configuration, "graphql.path", "/graphql");
const graphqlVoyagerPath = get(configuration, "graphql.graphqlVoyagerPath", "/graphql-voyager");
const disableGraphqlVoyager = get(configuration, "graphql.disableGraphqlVoyager", false);

const disableGraphql = get(configuration, "graphql.disable", false);
const disableSockets = get(configuration, "sockets.disable", false);

Expand All @@ -25,16 +34,11 @@ export default function (configuration: IConfiguration, servers: any) {
graphql.applyMiddleware({ app: restApi, path: graphqlPath });
graphql.installSubscriptionHandlers(httpServer);
}

restApiBeforeStart({ express: restApi });

if (showWertik404Page) {
restApi.get("*", function (req, res) {
res.status(404).json({
message: "Not found",
data: {
message: "Request page didn't found",
},
});
});
restApi.get("*", restApi404Handler);
}

httpServer.listen(expressAppPort, () => {
Expand Down
1 change: 1 addition & 0 deletions src/framework/types/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ export interface IConfigurationRestApi {
onCustomApiFailure: Function;
showWertik404Page: boolean;
beforeStart: Function;
restApi404Handler: Function;
}

export interface IConfigurationGraphql {
Expand Down

0 comments on commit 3f3d93e

Please sign in to comment.