add prettier

This commit is contained in:
Moriz Wahl 2023-11-30 11:51:56 +01:00
parent c7d1ed4adc
commit 98896a653d
2 changed files with 29 additions and 15 deletions

14
.prettierrc.json Normal file
View File

@ -0,0 +1,14 @@
{
"printWidth": 100,
"tabWidth": 2,
"useTabs": false,
"semi": false,
"singleQuote": true,
"quoteProps": "as-needed",
"jsxSingleQuote": true,
"trailingComma": "all",
"bracketSpacing": true,
"bracketSameLine": false,
"arrowParens": "always",
"endOfLine": "auto"
}

View File

@ -1,41 +1,41 @@
import { ApolloServer, gql } from "apollo-server-express"; import { ApolloServer, gql } from 'apollo-server-express'
import express from "express"; import express from 'express'
const typeDefs = gql` const typeDefs = gql`
type Query { type Query {
hello: String hello: String
} }
`; `
const resolvers = { const resolvers = {
Query: { Query: {
hello: () => "Hello world!", hello: () => 'Hello world!',
}, },
}; }
async function listen(port: number) { async function listen(port: number) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any // eslint-disable-next-line @typescript-eslint/no-explicit-any
const app: any = express(); const app: any = express()
const server = new ApolloServer({ const server = new ApolloServer({
typeDefs, typeDefs,
resolvers, resolvers,
}); })
await server.start(); await server.start()
server.applyMiddleware({ app, path: "/" }); server.applyMiddleware({ app, path: '/' })
return app.listen(port); return app.listen(port)
} }
async function main() { async function main() {
await listen(4000); await listen(4000)
// eslint-disable-next-line no-console // eslint-disable-next-line no-console
console.log("🚀 Server is ready at http://localhost:4000/graphql"); console.log('🚀 Server is ready at http://localhost:4000/graphql')
} }
main().catch((e) => { main().catch((e) => {
// eslint-disable-next-line no-console // eslint-disable-next-line no-console
console.error(e); console.error(e)
throw e; throw e
}); })