-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #28 from ozkeisar/build-server-from-swagger
Build server from swagger
- Loading branch information
Showing
30 changed files
with
1,052 additions
and
256 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import { RouteParent } from "../../types"; | ||
import { EVENT_KEYS } from "../../types/events"; | ||
import { isParentExist, parentsProperties } from "../../utils/parent"; | ||
import { projectsManager } from "../managers"; | ||
import { emitGlobalSocketMessage } from "../socket"; | ||
import { hasUncommittedChanges, updateRouteParentFile } from "../utils"; | ||
|
||
|
||
export const createParent = async (projectName: string, serverName: string, parent: RouteParent)=>{ | ||
|
||
const serversHash = await projectsManager.getProjectServersHash(projectName) | ||
const server = serversHash[serverName] | ||
|
||
if(!server){ | ||
throw new Error("server not exist"); | ||
} | ||
|
||
const { | ||
filenames, | ||
paths, | ||
graphQlNames, | ||
restPaths, | ||
graphQlPaths | ||
} = parentsProperties(server) | ||
|
||
|
||
const { | ||
parentExist, | ||
} = isParentExist(server, { | ||
filenames, | ||
paths, | ||
graphQlNames, | ||
restPaths, | ||
graphQlPaths | ||
}, parent) | ||
|
||
if(parentExist){ | ||
throw new Error("parent already exist"); | ||
} | ||
|
||
await updateRouteParentFile(projectName, serverName, parent); | ||
|
||
projectsManager.setProjectChanged(projectName) | ||
|
||
const hasDiffs = await hasUncommittedChanges(projectName); | ||
|
||
emitGlobalSocketMessage(EVENT_KEYS.UPDATE_ROUTES_FILE, { | ||
success: true, | ||
content: parent, | ||
filename: parent.filename, | ||
projectName, | ||
serverName, | ||
hasDiffs, | ||
}); | ||
|
||
return parent | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { Route } from "../../types"; | ||
import { EVENT_KEYS } from "../../types/events"; | ||
import { isRouteExist } from "../../utils/route"; | ||
import { projectsManager } from "../managers"; | ||
import { emitGlobalSocketMessage } from "../socket"; | ||
import { hasUncommittedChanges, updateRouteParentFile } from "../utils"; | ||
|
||
|
||
export const createRoute = async(projectName: string, serverName: string, parentId: string, route: Route)=>{ | ||
|
||
const serverHash = await projectsManager.getProjectServersHash(projectName); | ||
const server = serverHash[serverName] | ||
|
||
if(!server){ | ||
throw new Error("server not exist"); | ||
} | ||
|
||
const parent = server.parentRoutesHash[parentId] | ||
|
||
if(!parent){ | ||
throw new Error("parent not exist"); | ||
} | ||
|
||
const routeExist = isRouteExist(route, parent) | ||
|
||
if(routeExist){ | ||
throw new Error("route already exist"); | ||
} | ||
|
||
if(parent.routesHash){ | ||
parent.routesHash[route.id] = route | ||
}else{ | ||
parent.routesHash = { | ||
[route.id]: route | ||
} | ||
} | ||
|
||
await updateRouteParentFile(projectName, serverName, parent); | ||
|
||
projectsManager.setProjectChanged(projectName) | ||
|
||
const hasDiffs = await hasUncommittedChanges(projectName); | ||
|
||
emitGlobalSocketMessage(EVENT_KEYS.UPDATE_ROUTES_FILE, { | ||
success: true, | ||
content: parent, | ||
filename: parent.filename, | ||
projectName, | ||
serverName, | ||
hasDiffs, | ||
}); | ||
|
||
return route | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.