Skip to content
Snippets Groups Projects
Commit e894a984 authored by Leon A. Okida Gonçalves's avatar Leon A. Okida Gonçalves
Browse files

Create DBHandler

parent ccffd21b
No related branches found
No related tags found
No related merge requests found
...@@ -13,4 +13,5 @@ const resolvers = { ...@@ -13,4 +13,5 @@ const resolvers = {
}; };
const server = new ApolloServer({ typeDefs, resolvers }); const server = new ApolloServer({ typeDefs, resolvers });
server.listen().then(({ url }) => console.log(`Server started at ${url}`)); server.listen().then(({ url }) => console.log(`Server started at ${url}`));
\ No newline at end of file
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
"version": "1.0.0", "version": "1.0.0",
"description": "", "description": "",
"main": "index.js", "main": "index.js",
"type": "module",
"scripts": { "scripts": {
"test": "echo \"Error: no test specified\" && exit 1", "test": "echo \"Error: no test specified\" && exit 1",
"start": "node index" "start": "node index"
......
...@@ -4,13 +4,17 @@ export class ErrorHandler { ...@@ -4,13 +4,17 @@ export class ErrorHandler {
public static userHandler (input: any) { public static userHandler (input: any) {
if (typeof input.name !== "string") if ((typeof input.name !== "string") || (!input.name.length))
throw new Error("Invalid user name"); throw new Error("Invalid user name");
if (typeof input.email !== "string") if ((typeof input.email !== "string") || (!input.email.length))
throw new Error("Invalid user email"); throw new Error("Invalid user email");
if ((typeof input.id !== "number") || (isNaN(input.id)))
throw new Error("Invalid id");
const newUser: UserInterface = { const newUser: UserInterface = {
userId: input.id,
userName: input.name, userName: input.name,
userEmail: input.email userEmail: input.email
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment