Skip to content

Commit

Permalink
refactor: lint all files
Browse files Browse the repository at this point in the history
  • Loading branch information
TAnas0 committed Sep 11, 2024
1 parent 8089cb8 commit 243c8a7
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 32 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,11 @@ Please use the alias `npm run commit` for Commitizen friendly commits.
## Todos and roadmap

[NodeJS best practices checklist](https://github.com/i0natan/nodebestpractices):

- 1.5 Use environment aware, secure and hierarchical config

Using the [node-config] package with Webpack. See [](https://github.com/lorenwest/node-config/wiki/Webpack-Usage)

- Clean datasources
- Documentation and references
- GrahQL CLI scaffolding support
- GrahQL CLI scaffolding support
8 changes: 4 additions & 4 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ services:
POSTGRES_PASSWORD: password
POSTGRES_DB: prisma
networks:
- 'prisma'
- "prisma"

prisma:
container_name: "prisma"
image: prismagraphql/prisma:1.22
restart: always
ports:
- 7766:7766
- 7766:7766
environment:
PRISMA_CONFIG: |
port: 7766
Expand All @@ -31,7 +31,7 @@ services:
# - api
- db
networks:
- 'prisma'
- "prisma"

# The API is better launched using `npm run dev` for hot reloading
# api:
Expand All @@ -46,4 +46,4 @@ services:

networks:
prisma:
driver: "bridge"
driver: "bridge"
4 changes: 2 additions & 2 deletions src/api/modules/auth/types/auth.graphql
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
type User {
username: String
username: String
posts: [Post]!
comments: [Comment]!
}
Expand All @@ -15,5 +15,5 @@ type Comment {
}

type Query {
currentUser: User,
currentUser: User
}
20 changes: 8 additions & 12 deletions src/api/modules/auth/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,20 @@ export function tradeTokenForUser(token: string): object {
}

// eslint-disable-next-line
export const authenticated = () => (next: Function) => async (
root: any,
args: any,
context: any,
info: any,
) => {
if (!context.currentUser) {
throw new Error("You are not authenticated!")
export const authenticated =
() => (next: Function) => async (root: any, args: any, context: any, info: any) => {
if (!context.currentUser) {
throw new Error("You are not authenticated!")
}
return next(root, args, context, info)
}
return next(root, args, context, info)
}

/**
* validateRole guard
*/
// eslint-disable-next-line
export const validateRole = function(next: Function) {
return function(root: any, args: any, context: any, info: any) {
export const validateRole = function (next: Function) {
return function (root: any, args: any, context: any, info: any) {
if (context.currentUser.role !== "EDITOR") {
throw new Error("Unauthorized")
}
Expand Down
10 changes: 5 additions & 5 deletions src/api/modules/comment/types/comment.graphql
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
type Comment {
id: ID!
content: String!
id: ID!
content: String!
}

# Extending Post type
Expand All @@ -9,6 +9,6 @@ type Post {
}

type Query {
getComments: [Comment],
getCommentsFromDB: [Comment],
}
getComments: [Comment]
getCommentsFromDB: [Comment]
}
6 changes: 1 addition & 5 deletions src/api/modules/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,4 @@ export const application = createApplication({
})

export const typeDefs = mergeTypeDefs([postType, commentType, authType])
export const resolvers = mergeResolvers([
postResolvers,
commentResolvers,
authResolvers,
])
export const resolvers = mergeResolvers([postResolvers, commentResolvers, authResolvers])
4 changes: 2 additions & 2 deletions src/api/modules/post/types/post.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ type Post {
}

type Query {
getPosts: [Post],
getPostsFromDB: [Post],
getPosts: [Post]
getPostsFromDB: [Post]
}
2 changes: 1 addition & 1 deletion src/prisma/seed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ main()
.then(async () => {
await prisma.$disconnect()
})
.catch(async e => {
.catch(async (e) => {
console.error(e)
await prisma.$disconnect()
process.exit(1)
Expand Down

0 comments on commit 243c8a7

Please sign in to comment.