Last active
April 5, 2020 15:45
-
-
Save ilyaskarim/dd2248dbe30d797c216e4147c1cb60ff to your computer and use it in GitHub Desktop.
wertik-js-configuration-custom-module
This file contains hidden or 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
let otherConfiguration = {}; // Here other wertik configuration | |
let configuration = { | |
...otherConfiguration, | |
modules: [ | |
{ | |
name: "Article", | |
useDatabase: true, | |
fields: { | |
sql: { | |
title: { | |
type: "String", | |
}, | |
}, | |
}, | |
graphql: { | |
crud: { | |
query: { | |
generate: true, | |
operations: "*", | |
}, | |
mutation: { | |
generate: true, | |
operations: "*", | |
}, | |
}, | |
// Main schema for Article | |
schema: ` | |
type Article { | |
title: String | |
} | |
type ArticleInput { | |
title: String | |
} | |
`, | |
mutation: { | |
schema: ``, // Write mutation schema for your module Article | |
resolvers: {}, // Resolvers for article mutations | |
}, | |
query: { | |
schema: ``, // Write query schema for your module Article | |
resolvers: {}, // Resolvers for article query | |
}, | |
}, | |
restApi: { | |
endpoints: [ | |
{ | |
path: "/people/", // Will be available under http://localhost:port/api/v1/article/people/ | |
methodType: "get", // get,post,put,delete,copy,head,options,link,unlink,purge,lock,unlock,view | |
handler: async function (req, res, restApiSuccessResponse, restApiErrorResponse) { | |
let somethinWentFine = true; | |
if (somethinWentFine) { | |
restApiSuccessResponse({ | |
res: res, | |
data: { | |
success: true, | |
}, | |
message: `Went all fine`, | |
}); | |
} else { | |
restApiErrorResponse({ | |
err: Error, | |
res: res, | |
data: { | |
message: "Something went wrong", | |
message: "Detail", | |
}, | |
}); | |
} | |
}, | |
}, | |
], | |
}, | |
}, | |
], | |
}; | |
export default configuration; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment