forked from maticzav/graphql-shield
-
-
Notifications
You must be signed in to change notification settings - Fork 10
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 #9 from omar-dulaimi:namespaced-routers-support
Namespaced routers support
- Loading branch information
Showing
8 changed files
with
78 additions
and
41 deletions.
There are no files selected for viewing
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
Binary file not shown.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
import { PrismaClient } from '@prisma/client' | ||
import * as trpc from '@trpc/server' | ||
import { PrismaClient } from '@prisma/client'; | ||
import * as trpc from '@trpc/server'; | ||
|
||
export const createContext = () => { | ||
const prisma = new PrismaClient() | ||
const prisma = new PrismaClient(); | ||
return { | ||
prisma, | ||
user: null | ||
} | ||
} | ||
user: null, | ||
}; | ||
}; | ||
|
||
export type Context = trpc.inferAsyncReturnType<typeof createContext> | ||
export type Context = trpc.inferAsyncReturnType<typeof createContext>; |
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 |
---|---|---|
@@ -1,21 +1,21 @@ | ||
import * as trpcExpress from '@trpc/server/adapters/express' | ||
import express from 'express' | ||
import { appRouter } from '../prisma/trpc/routers/index' | ||
import { createContext } from './context' | ||
import * as trpcExpress from '@trpc/server/adapters/express'; | ||
import express from 'express'; | ||
import { appRouter } from '../prisma/trpc/routers/index'; | ||
import { createContext } from './context'; | ||
|
||
const PORT = 3001 | ||
const PORT = 3001; | ||
|
||
const app = express() | ||
const app = express(); | ||
|
||
app.use( | ||
'/trpc', | ||
trpcExpress.createExpressMiddleware({ | ||
router: appRouter, | ||
createContext, | ||
}), | ||
) | ||
app.get('/', (req, res) => res.send('Express + Prisma + tRPC + tRPC Shield')) | ||
); | ||
app.get('/', (req, res) => res.send('Express + Prisma + tRPC + tRPC Shield')); | ||
|
||
app.listen(PORT, () => { | ||
console.log(`server listening at http://localhost:${PORT}`) | ||
}) | ||
console.log(`server listening at http://localhost:${PORT}`); | ||
}); |
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
module.exports = { | ||
printWidth: 130, | ||
semi: false, | ||
semi: true, | ||
singleQuote: true, | ||
trailingComma: 'all', | ||
} |
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